blob: ab8f30bc48b0275f0526715a0e42464b9fd34cd3 [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
11import const
Rich Lane7dcdf022013-12-11 14:45:27 -080012import action
Rich Lane7dcdf022013-12-11 14:45:27 -080013import oxm
Harshmeet Singh1db46332014-10-14 16:29:13 -070014import message
15import instruction
16import common
Rich Lanec2ee4b82013-04-24 17:12:38 -070017import util
18import loxi.generic_util
19
Rich Lane7dcdf022013-12-11 14:45:27 -080020class message(loxi.OFObject):
21 subtypes = {}
Rich Lanec2ee4b82013-04-24 17:12:38 -070022
Rich Lane95f7fc92014-01-27 17:08:16 -080023 version = 3
24
25 def __init__(self, type=None, xid=None):
26 if type != None:
27 self.type = type
28 else:
29 self.type = 0
30 if xid != None:
31 self.xid = xid
32 else:
33 self.xid = None
34 return
35
36 def pack(self):
37 packed = []
38 packed.append(struct.pack("!B", self.version))
39 packed.append(struct.pack("!B", self.type))
40 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
41 packed.append(struct.pack("!L", self.xid))
42 length = sum([len(x) for x in packed])
43 packed[2] = struct.pack("!H", length)
44 return ''.join(packed)
45
Rich Lane7dcdf022013-12-11 14:45:27 -080046 @staticmethod
47 def unpack(reader):
48 subtype, = reader.peek('B', 1)
Rich Lane95f7fc92014-01-27 17:08:16 -080049 subclass = message.subtypes.get(subtype)
50 if subclass:
51 return subclass.unpack(reader)
52
53 obj = message()
54 _version = reader.read("!B")[0]
55 assert(_version == 3)
56 obj.type = reader.read("!B")[0]
57 _length = reader.read("!H")[0]
58 orig_reader = reader
59 reader = orig_reader.slice(_length - (2 + 2))
60 obj.xid = reader.read("!L")[0]
61 return obj
62
63 def __eq__(self, other):
64 if type(self) != type(other): return False
65 if self.type != other.type: return False
66 if self.xid != other.xid: return False
67 return True
68
69 def pretty_print(self, q):
70 q.text("message {")
71 with q.group():
72 with q.indent(2):
73 q.breakable()
74 q.text("xid = ");
75 if self.xid != None:
76 q.text("%#x" % self.xid)
77 else:
78 q.text('None')
79 q.breakable()
80 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -080081
82
83class stats_reply(message):
84 subtypes = {}
85
Rich Lane95f7fc92014-01-27 17:08:16 -080086 version = 3
87 type = 19
88
89 def __init__(self, xid=None, stats_type=None, flags=None):
90 if xid != None:
91 self.xid = xid
92 else:
93 self.xid = None
94 if stats_type != None:
95 self.stats_type = stats_type
96 else:
97 self.stats_type = 0
98 if flags != None:
99 self.flags = flags
100 else:
101 self.flags = 0
102 return
103
104 def pack(self):
105 packed = []
106 packed.append(struct.pack("!B", self.version))
107 packed.append(struct.pack("!B", self.type))
108 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
109 packed.append(struct.pack("!L", self.xid))
110 packed.append(struct.pack("!H", self.stats_type))
111 packed.append(struct.pack("!H", self.flags))
112 packed.append('\x00' * 4)
113 length = sum([len(x) for x in packed])
114 packed[2] = struct.pack("!H", length)
115 return ''.join(packed)
116
Rich Lane7dcdf022013-12-11 14:45:27 -0800117 @staticmethod
118 def unpack(reader):
119 subtype, = reader.peek('!H', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800120 subclass = stats_reply.subtypes.get(subtype)
121 if subclass:
122 return subclass.unpack(reader)
123
124 obj = stats_reply()
125 _version = reader.read("!B")[0]
126 assert(_version == 3)
127 _type = reader.read("!B")[0]
128 assert(_type == 19)
129 _length = reader.read("!H")[0]
130 orig_reader = reader
131 reader = orig_reader.slice(_length - (2 + 2))
132 obj.xid = reader.read("!L")[0]
133 obj.stats_type = reader.read("!H")[0]
134 obj.flags = reader.read("!H")[0]
135 reader.skip(4)
136 return obj
137
138 def __eq__(self, other):
139 if type(self) != type(other): return False
140 if self.xid != other.xid: return False
141 if self.stats_type != other.stats_type: return False
142 if self.flags != other.flags: return False
143 return True
144
145 def pretty_print(self, q):
146 q.text("stats_reply {")
147 with q.group():
148 with q.indent(2):
149 q.breakable()
150 q.text("xid = ");
151 if self.xid != None:
152 q.text("%#x" % self.xid)
153 else:
154 q.text('None')
155 q.text(","); q.breakable()
156 q.text("flags = ");
157 q.text("%#x" % self.flags)
158 q.breakable()
159 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800160
161message.subtypes[19] = stats_reply
162
163class aggregate_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -0700164 version = 3
165 type = 19
166 stats_type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -0700167
168 def __init__(self, xid=None, flags=None, packet_count=None, byte_count=None, flow_count=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800169 if xid != None:
170 self.xid = xid
171 else:
172 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -0700173 if flags != None:
174 self.flags = flags
175 else:
176 self.flags = 0
177 if packet_count != None:
178 self.packet_count = packet_count
179 else:
180 self.packet_count = 0
181 if byte_count != None:
182 self.byte_count = byte_count
183 else:
184 self.byte_count = 0
185 if flow_count != None:
186 self.flow_count = flow_count
187 else:
188 self.flow_count = 0
Rich Lane7dcdf022013-12-11 14:45:27 -0800189 return
Rich Lanec2ee4b82013-04-24 17:12:38 -0700190
191 def pack(self):
192 packed = []
193 packed.append(struct.pack("!B", self.version))
194 packed.append(struct.pack("!B", self.type))
195 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
196 packed.append(struct.pack("!L", self.xid))
197 packed.append(struct.pack("!H", self.stats_type))
198 packed.append(struct.pack("!H", self.flags))
199 packed.append('\x00' * 4)
200 packed.append(struct.pack("!Q", self.packet_count))
201 packed.append(struct.pack("!Q", self.byte_count))
202 packed.append(struct.pack("!L", self.flow_count))
203 packed.append('\x00' * 4)
204 length = sum([len(x) for x in packed])
205 packed[2] = struct.pack("!H", length)
206 return ''.join(packed)
207
208 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800209 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700210 obj = aggregate_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -0700211 _version = reader.read("!B")[0]
212 assert(_version == 3)
213 _type = reader.read("!B")[0]
214 assert(_type == 19)
215 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800216 orig_reader = reader
217 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700218 obj.xid = reader.read("!L")[0]
219 _stats_type = reader.read("!H")[0]
220 assert(_stats_type == 2)
221 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700222 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -0700223 obj.packet_count = reader.read("!Q")[0]
224 obj.byte_count = reader.read("!Q")[0]
225 obj.flow_count = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700226 reader.skip(4)
227 return obj
228
229 def __eq__(self, other):
230 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700231 if self.xid != other.xid: return False
232 if self.flags != other.flags: return False
233 if self.packet_count != other.packet_count: return False
234 if self.byte_count != other.byte_count: return False
235 if self.flow_count != other.flow_count: return False
236 return True
237
Rich Lanec2ee4b82013-04-24 17:12:38 -0700238 def pretty_print(self, q):
239 q.text("aggregate_stats_reply {")
240 with q.group():
241 with q.indent(2):
242 q.breakable()
243 q.text("xid = ");
244 if self.xid != None:
245 q.text("%#x" % self.xid)
246 else:
247 q.text('None')
248 q.text(","); q.breakable()
249 q.text("flags = ");
250 q.text("%#x" % self.flags)
251 q.text(","); q.breakable()
252 q.text("packet_count = ");
253 q.text("%#x" % self.packet_count)
254 q.text(","); q.breakable()
255 q.text("byte_count = ");
256 q.text("%#x" % self.byte_count)
257 q.text(","); q.breakable()
258 q.text("flow_count = ");
259 q.text("%#x" % self.flow_count)
260 q.breakable()
261 q.text('}')
262
Rich Lane7dcdf022013-12-11 14:45:27 -0800263stats_reply.subtypes[2] = aggregate_stats_reply
264
265class stats_request(message):
266 subtypes = {}
267
Rich Lane95f7fc92014-01-27 17:08:16 -0800268 version = 3
269 type = 18
270
271 def __init__(self, xid=None, stats_type=None, flags=None):
272 if xid != None:
273 self.xid = xid
274 else:
275 self.xid = None
276 if stats_type != None:
277 self.stats_type = stats_type
278 else:
279 self.stats_type = 0
280 if flags != None:
281 self.flags = flags
282 else:
283 self.flags = 0
284 return
285
286 def pack(self):
287 packed = []
288 packed.append(struct.pack("!B", self.version))
289 packed.append(struct.pack("!B", self.type))
290 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
291 packed.append(struct.pack("!L", self.xid))
292 packed.append(struct.pack("!H", self.stats_type))
293 packed.append(struct.pack("!H", self.flags))
294 packed.append('\x00' * 4)
295 length = sum([len(x) for x in packed])
296 packed[2] = struct.pack("!H", length)
297 return ''.join(packed)
298
Rich Lane7dcdf022013-12-11 14:45:27 -0800299 @staticmethod
300 def unpack(reader):
301 subtype, = reader.peek('!H', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800302 subclass = stats_request.subtypes.get(subtype)
303 if subclass:
304 return subclass.unpack(reader)
305
306 obj = stats_request()
307 _version = reader.read("!B")[0]
308 assert(_version == 3)
309 _type = reader.read("!B")[0]
310 assert(_type == 18)
311 _length = reader.read("!H")[0]
312 orig_reader = reader
313 reader = orig_reader.slice(_length - (2 + 2))
314 obj.xid = reader.read("!L")[0]
315 obj.stats_type = reader.read("!H")[0]
316 obj.flags = reader.read("!H")[0]
317 reader.skip(4)
318 return obj
319
320 def __eq__(self, other):
321 if type(self) != type(other): return False
322 if self.xid != other.xid: return False
323 if self.stats_type != other.stats_type: return False
324 if self.flags != other.flags: return False
325 return True
326
327 def pretty_print(self, q):
328 q.text("stats_request {")
329 with q.group():
330 with q.indent(2):
331 q.breakable()
332 q.text("xid = ");
333 if self.xid != None:
334 q.text("%#x" % self.xid)
335 else:
336 q.text('None')
337 q.text(","); q.breakable()
338 q.text("flags = ");
339 q.text("%#x" % self.flags)
340 q.breakable()
341 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800342
343message.subtypes[18] = stats_request
344
345class aggregate_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -0700346 version = 3
347 type = 18
348 stats_type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -0700349
350 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 -0800351 if xid != None:
352 self.xid = xid
353 else:
354 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -0700355 if flags != None:
356 self.flags = flags
357 else:
358 self.flags = 0
359 if table_id != None:
360 self.table_id = table_id
361 else:
362 self.table_id = 0
363 if out_port != None:
364 self.out_port = out_port
365 else:
366 self.out_port = 0
367 if out_group != None:
368 self.out_group = out_group
369 else:
370 self.out_group = 0
371 if cookie != None:
372 self.cookie = cookie
373 else:
374 self.cookie = 0
375 if cookie_mask != None:
376 self.cookie_mask = cookie_mask
377 else:
378 self.cookie_mask = 0
379 if match != None:
380 self.match = match
381 else:
382 self.match = common.match()
Rich Lane7dcdf022013-12-11 14:45:27 -0800383 return
Rich Lanec2ee4b82013-04-24 17:12:38 -0700384
385 def pack(self):
386 packed = []
387 packed.append(struct.pack("!B", self.version))
388 packed.append(struct.pack("!B", self.type))
389 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
390 packed.append(struct.pack("!L", self.xid))
391 packed.append(struct.pack("!H", self.stats_type))
392 packed.append(struct.pack("!H", self.flags))
393 packed.append('\x00' * 4)
394 packed.append(struct.pack("!B", self.table_id))
395 packed.append('\x00' * 3)
Dan Talaycof6202252013-07-02 01:00:29 -0700396 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700397 packed.append(struct.pack("!L", self.out_group))
398 packed.append('\x00' * 4)
399 packed.append(struct.pack("!Q", self.cookie))
400 packed.append(struct.pack("!Q", self.cookie_mask))
401 packed.append(self.match.pack())
402 length = sum([len(x) for x in packed])
403 packed[2] = struct.pack("!H", length)
404 return ''.join(packed)
405
406 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800407 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700408 obj = aggregate_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -0700409 _version = reader.read("!B")[0]
410 assert(_version == 3)
411 _type = reader.read("!B")[0]
412 assert(_type == 18)
413 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800414 orig_reader = reader
415 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700416 obj.xid = reader.read("!L")[0]
417 _stats_type = reader.read("!H")[0]
418 assert(_stats_type == 2)
419 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700420 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -0700421 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700422 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -0700423 obj.out_port = util.unpack_port_no(reader)
424 obj.out_group = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700425 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -0700426 obj.cookie = reader.read("!Q")[0]
427 obj.cookie_mask = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700428 obj.match = common.match.unpack(reader)
429 return obj
430
431 def __eq__(self, other):
432 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700433 if self.xid != other.xid: return False
434 if self.flags != other.flags: return False
435 if self.table_id != other.table_id: return False
436 if self.out_port != other.out_port: return False
437 if self.out_group != other.out_group: return False
438 if self.cookie != other.cookie: return False
439 if self.cookie_mask != other.cookie_mask: return False
440 if self.match != other.match: return False
441 return True
442
Rich Lanec2ee4b82013-04-24 17:12:38 -0700443 def pretty_print(self, q):
444 q.text("aggregate_stats_request {")
445 with q.group():
446 with q.indent(2):
447 q.breakable()
448 q.text("xid = ");
449 if self.xid != None:
450 q.text("%#x" % self.xid)
451 else:
452 q.text('None')
453 q.text(","); q.breakable()
454 q.text("flags = ");
455 q.text("%#x" % self.flags)
456 q.text(","); q.breakable()
457 q.text("table_id = ");
458 q.text("%#x" % self.table_id)
459 q.text(","); q.breakable()
460 q.text("out_port = ");
461 q.text(util.pretty_port(self.out_port))
462 q.text(","); q.breakable()
463 q.text("out_group = ");
464 q.text("%#x" % self.out_group)
465 q.text(","); q.breakable()
466 q.text("cookie = ");
467 q.text("%#x" % self.cookie)
468 q.text(","); q.breakable()
469 q.text("cookie_mask = ");
470 q.text("%#x" % self.cookie_mask)
471 q.text(","); q.breakable()
472 q.text("match = ");
473 q.pp(self.match)
474 q.breakable()
475 q.text('}')
476
Rich Lane7dcdf022013-12-11 14:45:27 -0800477stats_request.subtypes[2] = aggregate_stats_request
478
479class error_msg(message):
480 subtypes = {}
481
Rich Lane95f7fc92014-01-27 17:08:16 -0800482 version = 3
483 type = 1
484
485 def __init__(self, xid=None, err_type=None):
486 if xid != None:
487 self.xid = xid
488 else:
489 self.xid = None
490 if err_type != None:
491 self.err_type = err_type
492 else:
493 self.err_type = 0
494 return
495
496 def pack(self):
497 packed = []
498 packed.append(struct.pack("!B", self.version))
499 packed.append(struct.pack("!B", self.type))
500 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
501 packed.append(struct.pack("!L", self.xid))
502 packed.append(struct.pack("!H", self.err_type))
503 length = sum([len(x) for x in packed])
504 packed[2] = struct.pack("!H", length)
505 return ''.join(packed)
506
Rich Lane7dcdf022013-12-11 14:45:27 -0800507 @staticmethod
508 def unpack(reader):
509 subtype, = reader.peek('!H', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800510 subclass = error_msg.subtypes.get(subtype)
511 if subclass:
512 return subclass.unpack(reader)
513
514 obj = error_msg()
515 _version = reader.read("!B")[0]
516 assert(_version == 3)
517 _type = reader.read("!B")[0]
518 assert(_type == 1)
519 _length = reader.read("!H")[0]
520 orig_reader = reader
521 reader = orig_reader.slice(_length - (2 + 2))
522 obj.xid = reader.read("!L")[0]
523 obj.err_type = reader.read("!H")[0]
524 return obj
525
526 def __eq__(self, other):
527 if type(self) != type(other): return False
528 if self.xid != other.xid: return False
529 if self.err_type != other.err_type: return False
530 return True
531
532 def pretty_print(self, q):
533 q.text("error_msg {")
534 with q.group():
535 with q.indent(2):
536 q.breakable()
537 q.text("xid = ");
538 if self.xid != None:
539 q.text("%#x" % self.xid)
540 else:
541 q.text('None')
542 q.breakable()
543 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800544
545message.subtypes[1] = error_msg
546
547class bad_action_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -0700548 version = 3
549 type = 1
550 err_type = 2
551
552 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800553 if xid != None:
554 self.xid = xid
555 else:
556 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -0700557 if code != None:
558 self.code = code
559 else:
560 self.code = 0
561 if data != None:
562 self.data = data
563 else:
564 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -0800565 return
Rich Lane6f4978c2013-10-20 21:33:52 -0700566
567 def pack(self):
568 packed = []
569 packed.append(struct.pack("!B", self.version))
570 packed.append(struct.pack("!B", self.type))
571 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
572 packed.append(struct.pack("!L", self.xid))
573 packed.append(struct.pack("!H", self.err_type))
574 packed.append(struct.pack("!H", self.code))
575 packed.append(self.data)
576 length = sum([len(x) for x in packed])
577 packed[2] = struct.pack("!H", length)
578 return ''.join(packed)
579
580 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800581 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -0700582 obj = bad_action_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -0700583 _version = reader.read("!B")[0]
584 assert(_version == 3)
585 _type = reader.read("!B")[0]
586 assert(_type == 1)
587 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800588 orig_reader = reader
589 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -0700590 obj.xid = reader.read("!L")[0]
591 _err_type = reader.read("!H")[0]
592 assert(_err_type == 2)
593 obj.code = reader.read("!H")[0]
594 obj.data = str(reader.read_all())
595 return obj
596
597 def __eq__(self, other):
598 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -0700599 if self.xid != other.xid: return False
600 if self.code != other.code: return False
601 if self.data != other.data: return False
602 return True
603
Rich Lane6f4978c2013-10-20 21:33:52 -0700604 def pretty_print(self, q):
605 q.text("bad_action_error_msg {")
606 with q.group():
607 with q.indent(2):
608 q.breakable()
609 q.text("xid = ");
610 if self.xid != None:
611 q.text("%#x" % self.xid)
612 else:
613 q.text('None')
614 q.text(","); q.breakable()
615 q.text("code = ");
616 q.text("%#x" % self.code)
617 q.text(","); q.breakable()
618 q.text("data = ");
619 q.pp(self.data)
620 q.breakable()
621 q.text('}')
622
Rich Lane7dcdf022013-12-11 14:45:27 -0800623error_msg.subtypes[2] = bad_action_error_msg
624
625class bad_instruction_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -0700626 version = 3
627 type = 1
628 err_type = 3
629
630 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800631 if xid != None:
632 self.xid = xid
633 else:
634 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -0700635 if code != None:
636 self.code = code
637 else:
638 self.code = 0
639 if data != None:
640 self.data = data
641 else:
642 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -0800643 return
Rich Lane6f4978c2013-10-20 21:33:52 -0700644
645 def pack(self):
646 packed = []
647 packed.append(struct.pack("!B", self.version))
648 packed.append(struct.pack("!B", self.type))
649 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
650 packed.append(struct.pack("!L", self.xid))
651 packed.append(struct.pack("!H", self.err_type))
652 packed.append(struct.pack("!H", self.code))
653 packed.append(self.data)
654 length = sum([len(x) for x in packed])
655 packed[2] = struct.pack("!H", length)
656 return ''.join(packed)
657
658 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800659 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -0700660 obj = bad_instruction_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -0700661 _version = reader.read("!B")[0]
662 assert(_version == 3)
663 _type = reader.read("!B")[0]
664 assert(_type == 1)
665 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800666 orig_reader = reader
667 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -0700668 obj.xid = reader.read("!L")[0]
669 _err_type = reader.read("!H")[0]
670 assert(_err_type == 3)
671 obj.code = reader.read("!H")[0]
672 obj.data = str(reader.read_all())
673 return obj
674
675 def __eq__(self, other):
676 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -0700677 if self.xid != other.xid: return False
678 if self.code != other.code: return False
679 if self.data != other.data: return False
680 return True
681
Rich Lane6f4978c2013-10-20 21:33:52 -0700682 def pretty_print(self, q):
683 q.text("bad_instruction_error_msg {")
684 with q.group():
685 with q.indent(2):
686 q.breakable()
687 q.text("xid = ");
688 if self.xid != None:
689 q.text("%#x" % self.xid)
690 else:
691 q.text('None')
692 q.text(","); q.breakable()
693 q.text("code = ");
694 q.text("%#x" % self.code)
695 q.text(","); q.breakable()
696 q.text("data = ");
697 q.pp(self.data)
698 q.breakable()
699 q.text('}')
700
Rich Lane7dcdf022013-12-11 14:45:27 -0800701error_msg.subtypes[3] = bad_instruction_error_msg
702
703class bad_match_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -0700704 version = 3
705 type = 1
706 err_type = 4
707
708 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800709 if xid != None:
710 self.xid = xid
711 else:
712 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -0700713 if code != None:
714 self.code = code
715 else:
716 self.code = 0
717 if data != None:
718 self.data = data
719 else:
720 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -0800721 return
Rich Lane6f4978c2013-10-20 21:33:52 -0700722
723 def pack(self):
724 packed = []
725 packed.append(struct.pack("!B", self.version))
726 packed.append(struct.pack("!B", self.type))
727 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
728 packed.append(struct.pack("!L", self.xid))
729 packed.append(struct.pack("!H", self.err_type))
730 packed.append(struct.pack("!H", self.code))
731 packed.append(self.data)
732 length = sum([len(x) for x in packed])
733 packed[2] = struct.pack("!H", length)
734 return ''.join(packed)
735
736 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800737 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -0700738 obj = bad_match_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -0700739 _version = reader.read("!B")[0]
740 assert(_version == 3)
741 _type = reader.read("!B")[0]
742 assert(_type == 1)
743 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800744 orig_reader = reader
745 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -0700746 obj.xid = reader.read("!L")[0]
747 _err_type = reader.read("!H")[0]
748 assert(_err_type == 4)
749 obj.code = reader.read("!H")[0]
750 obj.data = str(reader.read_all())
751 return obj
752
753 def __eq__(self, other):
754 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -0700755 if self.xid != other.xid: return False
756 if self.code != other.code: return False
757 if self.data != other.data: return False
758 return True
759
Rich Lane6f4978c2013-10-20 21:33:52 -0700760 def pretty_print(self, q):
761 q.text("bad_match_error_msg {")
762 with q.group():
763 with q.indent(2):
764 q.breakable()
765 q.text("xid = ");
766 if self.xid != None:
767 q.text("%#x" % self.xid)
768 else:
769 q.text('None')
770 q.text(","); q.breakable()
771 q.text("code = ");
772 q.text("%#x" % self.code)
773 q.text(","); q.breakable()
774 q.text("data = ");
775 q.pp(self.data)
776 q.breakable()
777 q.text('}')
778
Rich Lane7dcdf022013-12-11 14:45:27 -0800779error_msg.subtypes[4] = bad_match_error_msg
780
781class bad_request_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -0700782 version = 3
783 type = 1
784 err_type = 1
785
786 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800787 if xid != None:
788 self.xid = xid
789 else:
790 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -0700791 if code != None:
792 self.code = code
793 else:
794 self.code = 0
795 if data != None:
796 self.data = data
797 else:
798 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -0800799 return
Rich Lane6f4978c2013-10-20 21:33:52 -0700800
801 def pack(self):
802 packed = []
803 packed.append(struct.pack("!B", self.version))
804 packed.append(struct.pack("!B", self.type))
805 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
806 packed.append(struct.pack("!L", self.xid))
807 packed.append(struct.pack("!H", self.err_type))
808 packed.append(struct.pack("!H", self.code))
809 packed.append(self.data)
810 length = sum([len(x) for x in packed])
811 packed[2] = struct.pack("!H", length)
812 return ''.join(packed)
813
814 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800815 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -0700816 obj = bad_request_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -0700817 _version = reader.read("!B")[0]
818 assert(_version == 3)
819 _type = reader.read("!B")[0]
820 assert(_type == 1)
821 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800822 orig_reader = reader
823 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -0700824 obj.xid = reader.read("!L")[0]
825 _err_type = reader.read("!H")[0]
826 assert(_err_type == 1)
827 obj.code = reader.read("!H")[0]
828 obj.data = str(reader.read_all())
829 return obj
830
831 def __eq__(self, other):
832 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -0700833 if self.xid != other.xid: return False
834 if self.code != other.code: return False
835 if self.data != other.data: return False
836 return True
837
Rich Lane6f4978c2013-10-20 21:33:52 -0700838 def pretty_print(self, q):
839 q.text("bad_request_error_msg {")
840 with q.group():
841 with q.indent(2):
842 q.breakable()
843 q.text("xid = ");
844 if self.xid != None:
845 q.text("%#x" % self.xid)
846 else:
847 q.text('None')
848 q.text(","); q.breakable()
849 q.text("code = ");
850 q.text("%#x" % self.code)
851 q.text(","); q.breakable()
852 q.text("data = ");
853 q.pp(self.data)
854 q.breakable()
855 q.text('}')
856
Rich Lane7dcdf022013-12-11 14:45:27 -0800857error_msg.subtypes[1] = bad_request_error_msg
858
859class barrier_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -0700860 version = 3
861 type = 21
Rich Lanec2ee4b82013-04-24 17:12:38 -0700862
863 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800864 if xid != None:
865 self.xid = xid
866 else:
867 self.xid = None
868 return
Rich Lanec2ee4b82013-04-24 17:12:38 -0700869
870 def pack(self):
871 packed = []
872 packed.append(struct.pack("!B", self.version))
873 packed.append(struct.pack("!B", self.type))
874 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
875 packed.append(struct.pack("!L", self.xid))
876 length = sum([len(x) for x in packed])
877 packed[2] = struct.pack("!H", length)
878 return ''.join(packed)
879
880 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800881 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700882 obj = barrier_reply()
Dan Talaycof6202252013-07-02 01:00:29 -0700883 _version = reader.read("!B")[0]
884 assert(_version == 3)
885 _type = reader.read("!B")[0]
886 assert(_type == 21)
887 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800888 orig_reader = reader
889 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700890 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700891 return obj
892
893 def __eq__(self, other):
894 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700895 if self.xid != other.xid: return False
896 return True
897
Rich Lanec2ee4b82013-04-24 17:12:38 -0700898 def pretty_print(self, q):
899 q.text("barrier_reply {")
900 with q.group():
901 with q.indent(2):
902 q.breakable()
903 q.text("xid = ");
904 if self.xid != None:
905 q.text("%#x" % self.xid)
906 else:
907 q.text('None')
908 q.breakable()
909 q.text('}')
910
Rich Lane7dcdf022013-12-11 14:45:27 -0800911message.subtypes[21] = barrier_reply
912
913class barrier_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -0700914 version = 3
915 type = 20
Rich Lanec2ee4b82013-04-24 17:12:38 -0700916
917 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800918 if xid != None:
919 self.xid = xid
920 else:
921 self.xid = None
922 return
Rich Lanec2ee4b82013-04-24 17:12:38 -0700923
924 def pack(self):
925 packed = []
926 packed.append(struct.pack("!B", self.version))
927 packed.append(struct.pack("!B", self.type))
928 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
929 packed.append(struct.pack("!L", self.xid))
930 length = sum([len(x) for x in packed])
931 packed[2] = struct.pack("!H", length)
932 return ''.join(packed)
933
934 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800935 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700936 obj = barrier_request()
Dan Talaycof6202252013-07-02 01:00:29 -0700937 _version = reader.read("!B")[0]
938 assert(_version == 3)
939 _type = reader.read("!B")[0]
940 assert(_type == 20)
941 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800942 orig_reader = reader
943 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700944 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700945 return obj
946
947 def __eq__(self, other):
948 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700949 if self.xid != other.xid: return False
950 return True
951
Rich Lanec2ee4b82013-04-24 17:12:38 -0700952 def pretty_print(self, q):
953 q.text("barrier_request {")
954 with q.group():
955 with q.indent(2):
956 q.breakable()
957 q.text("xid = ");
958 if self.xid != None:
959 q.text("%#x" % self.xid)
960 else:
961 q.text('None')
962 q.breakable()
963 q.text('}')
964
Rich Lane7dcdf022013-12-11 14:45:27 -0800965message.subtypes[20] = barrier_request
966
967class experimenter(message):
968 subtypes = {}
969
Rich Lane95f7fc92014-01-27 17:08:16 -0800970 version = 3
971 type = 4
972
973 def __init__(self, xid=None, experimenter=None, subtype=None, data=None):
974 if xid != None:
975 self.xid = xid
976 else:
977 self.xid = None
978 if experimenter != None:
979 self.experimenter = experimenter
980 else:
981 self.experimenter = 0
982 if subtype != None:
983 self.subtype = subtype
984 else:
985 self.subtype = 0
986 if data != None:
987 self.data = data
988 else:
989 self.data = ''
990 return
991
992 def pack(self):
993 packed = []
994 packed.append(struct.pack("!B", self.version))
995 packed.append(struct.pack("!B", self.type))
996 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
997 packed.append(struct.pack("!L", self.xid))
998 packed.append(struct.pack("!L", self.experimenter))
999 packed.append(struct.pack("!L", self.subtype))
1000 packed.append(self.data)
1001 length = sum([len(x) for x in packed])
1002 packed[2] = struct.pack("!H", length)
1003 return ''.join(packed)
1004
Rich Lane7dcdf022013-12-11 14:45:27 -08001005 @staticmethod
1006 def unpack(reader):
1007 subtype, = reader.peek('!L', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -08001008 subclass = experimenter.subtypes.get(subtype)
1009 if subclass:
1010 return subclass.unpack(reader)
1011
1012 obj = experimenter()
1013 _version = reader.read("!B")[0]
1014 assert(_version == 3)
1015 _type = reader.read("!B")[0]
1016 assert(_type == 4)
1017 _length = reader.read("!H")[0]
1018 orig_reader = reader
1019 reader = orig_reader.slice(_length - (2 + 2))
1020 obj.xid = reader.read("!L")[0]
1021 obj.experimenter = reader.read("!L")[0]
1022 obj.subtype = reader.read("!L")[0]
1023 obj.data = str(reader.read_all())
1024 return obj
1025
1026 def __eq__(self, other):
1027 if type(self) != type(other): return False
1028 if self.xid != other.xid: return False
1029 if self.experimenter != other.experimenter: return False
1030 if self.subtype != other.subtype: return False
1031 if self.data != other.data: return False
1032 return True
1033
1034 def pretty_print(self, q):
1035 q.text("experimenter {")
1036 with q.group():
1037 with q.indent(2):
1038 q.breakable()
1039 q.text("xid = ");
1040 if self.xid != None:
1041 q.text("%#x" % self.xid)
1042 else:
1043 q.text('None')
1044 q.text(","); q.breakable()
1045 q.text("subtype = ");
1046 q.text("%#x" % self.subtype)
1047 q.text(","); q.breakable()
1048 q.text("data = ");
1049 q.pp(self.data)
1050 q.breakable()
1051 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08001052
1053message.subtypes[4] = experimenter
1054
1055class bsn_header(experimenter):
1056 subtypes = {}
1057
Rich Lane95f7fc92014-01-27 17:08:16 -08001058 version = 3
1059 type = 4
1060 experimenter = 6035143
1061
1062 def __init__(self, xid=None, subtype=None):
1063 if xid != None:
1064 self.xid = xid
1065 else:
1066 self.xid = None
1067 if subtype != None:
1068 self.subtype = subtype
1069 else:
1070 self.subtype = 0
1071 return
1072
1073 def pack(self):
1074 packed = []
1075 packed.append(struct.pack("!B", self.version))
1076 packed.append(struct.pack("!B", self.type))
1077 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1078 packed.append(struct.pack("!L", self.xid))
1079 packed.append(struct.pack("!L", self.experimenter))
1080 packed.append(struct.pack("!L", self.subtype))
1081 length = sum([len(x) for x in packed])
1082 packed[2] = struct.pack("!H", length)
1083 return ''.join(packed)
1084
Rich Lane7dcdf022013-12-11 14:45:27 -08001085 @staticmethod
1086 def unpack(reader):
1087 subtype, = reader.peek('!L', 12)
Rich Lane95f7fc92014-01-27 17:08:16 -08001088 subclass = bsn_header.subtypes.get(subtype)
1089 if subclass:
1090 return subclass.unpack(reader)
1091
1092 obj = bsn_header()
1093 _version = reader.read("!B")[0]
1094 assert(_version == 3)
1095 _type = reader.read("!B")[0]
1096 assert(_type == 4)
1097 _length = reader.read("!H")[0]
1098 orig_reader = reader
1099 reader = orig_reader.slice(_length - (2 + 2))
1100 obj.xid = reader.read("!L")[0]
1101 _experimenter = reader.read("!L")[0]
1102 assert(_experimenter == 6035143)
1103 obj.subtype = reader.read("!L")[0]
1104 return obj
1105
1106 def __eq__(self, other):
1107 if type(self) != type(other): return False
1108 if self.xid != other.xid: return False
1109 if self.subtype != other.subtype: return False
1110 return True
1111
1112 def pretty_print(self, q):
1113 q.text("bsn_header {")
1114 with q.group():
1115 with q.indent(2):
1116 q.breakable()
1117 q.text("xid = ");
1118 if self.xid != None:
1119 q.text("%#x" % self.xid)
1120 else:
1121 q.text('None')
1122 q.breakable()
1123 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08001124
1125experimenter.subtypes[6035143] = bsn_header
1126
1127class bsn_bw_clear_data_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001128 version = 3
1129 type = 4
1130 experimenter = 6035143
1131 subtype = 22
1132
1133 def __init__(self, xid=None, status=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001134 if xid != None:
1135 self.xid = xid
1136 else:
1137 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07001138 if status != None:
1139 self.status = status
1140 else:
1141 self.status = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001142 return
Dan Talaycof6202252013-07-02 01:00:29 -07001143
1144 def pack(self):
1145 packed = []
1146 packed.append(struct.pack("!B", self.version))
1147 packed.append(struct.pack("!B", self.type))
1148 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1149 packed.append(struct.pack("!L", self.xid))
1150 packed.append(struct.pack("!L", self.experimenter))
1151 packed.append(struct.pack("!L", self.subtype))
1152 packed.append(struct.pack("!L", self.status))
1153 length = sum([len(x) for x in packed])
1154 packed[2] = struct.pack("!H", length)
1155 return ''.join(packed)
1156
1157 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001158 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001159 obj = bsn_bw_clear_data_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07001160 _version = reader.read("!B")[0]
1161 assert(_version == 3)
1162 _type = reader.read("!B")[0]
1163 assert(_type == 4)
1164 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001165 orig_reader = reader
1166 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001167 obj.xid = reader.read("!L")[0]
1168 _experimenter = reader.read("!L")[0]
1169 assert(_experimenter == 6035143)
1170 _subtype = reader.read("!L")[0]
1171 assert(_subtype == 22)
1172 obj.status = reader.read("!L")[0]
1173 return obj
1174
1175 def __eq__(self, other):
1176 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07001177 if self.xid != other.xid: return False
1178 if self.status != other.status: return False
1179 return True
1180
Dan Talaycof6202252013-07-02 01:00:29 -07001181 def pretty_print(self, q):
1182 q.text("bsn_bw_clear_data_reply {")
1183 with q.group():
1184 with q.indent(2):
1185 q.breakable()
1186 q.text("xid = ");
1187 if self.xid != None:
1188 q.text("%#x" % self.xid)
1189 else:
1190 q.text('None')
1191 q.text(","); q.breakable()
1192 q.text("status = ");
1193 q.text("%#x" % self.status)
1194 q.breakable()
1195 q.text('}')
1196
Rich Lane7dcdf022013-12-11 14:45:27 -08001197bsn_header.subtypes[22] = bsn_bw_clear_data_reply
1198
1199class bsn_bw_clear_data_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001200 version = 3
1201 type = 4
1202 experimenter = 6035143
1203 subtype = 21
1204
1205 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001206 if xid != None:
1207 self.xid = xid
1208 else:
1209 self.xid = None
1210 return
Dan Talaycof6202252013-07-02 01:00:29 -07001211
1212 def pack(self):
1213 packed = []
1214 packed.append(struct.pack("!B", self.version))
1215 packed.append(struct.pack("!B", self.type))
1216 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1217 packed.append(struct.pack("!L", self.xid))
1218 packed.append(struct.pack("!L", self.experimenter))
1219 packed.append(struct.pack("!L", self.subtype))
1220 length = sum([len(x) for x in packed])
1221 packed[2] = struct.pack("!H", length)
1222 return ''.join(packed)
1223
1224 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001225 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001226 obj = bsn_bw_clear_data_request()
Dan Talaycof6202252013-07-02 01:00:29 -07001227 _version = reader.read("!B")[0]
1228 assert(_version == 3)
1229 _type = reader.read("!B")[0]
1230 assert(_type == 4)
1231 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001232 orig_reader = reader
1233 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001234 obj.xid = reader.read("!L")[0]
1235 _experimenter = reader.read("!L")[0]
1236 assert(_experimenter == 6035143)
1237 _subtype = reader.read("!L")[0]
1238 assert(_subtype == 21)
1239 return obj
1240
1241 def __eq__(self, other):
1242 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07001243 if self.xid != other.xid: return False
1244 return True
1245
Dan Talaycof6202252013-07-02 01:00:29 -07001246 def pretty_print(self, q):
1247 q.text("bsn_bw_clear_data_request {")
1248 with q.group():
1249 with q.indent(2):
1250 q.breakable()
1251 q.text("xid = ");
1252 if self.xid != None:
1253 q.text("%#x" % self.xid)
1254 else:
1255 q.text('None')
1256 q.breakable()
1257 q.text('}')
1258
Rich Lane7dcdf022013-12-11 14:45:27 -08001259bsn_header.subtypes[21] = bsn_bw_clear_data_request
1260
1261class bsn_bw_enable_get_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001262 version = 3
1263 type = 4
1264 experimenter = 6035143
1265 subtype = 20
1266
1267 def __init__(self, xid=None, enabled=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001268 if xid != None:
1269 self.xid = xid
1270 else:
1271 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07001272 if enabled != None:
1273 self.enabled = enabled
1274 else:
1275 self.enabled = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001276 return
Dan Talaycof6202252013-07-02 01:00:29 -07001277
1278 def pack(self):
1279 packed = []
1280 packed.append(struct.pack("!B", self.version))
1281 packed.append(struct.pack("!B", self.type))
1282 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1283 packed.append(struct.pack("!L", self.xid))
1284 packed.append(struct.pack("!L", self.experimenter))
1285 packed.append(struct.pack("!L", self.subtype))
1286 packed.append(struct.pack("!L", self.enabled))
1287 length = sum([len(x) for x in packed])
1288 packed[2] = struct.pack("!H", length)
1289 return ''.join(packed)
1290
1291 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001292 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001293 obj = bsn_bw_enable_get_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07001294 _version = reader.read("!B")[0]
1295 assert(_version == 3)
1296 _type = reader.read("!B")[0]
1297 assert(_type == 4)
1298 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001299 orig_reader = reader
1300 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001301 obj.xid = reader.read("!L")[0]
1302 _experimenter = reader.read("!L")[0]
1303 assert(_experimenter == 6035143)
1304 _subtype = reader.read("!L")[0]
1305 assert(_subtype == 20)
1306 obj.enabled = reader.read("!L")[0]
1307 return obj
1308
1309 def __eq__(self, other):
1310 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07001311 if self.xid != other.xid: return False
1312 if self.enabled != other.enabled: return False
1313 return True
1314
Dan Talaycof6202252013-07-02 01:00:29 -07001315 def pretty_print(self, q):
1316 q.text("bsn_bw_enable_get_reply {")
1317 with q.group():
1318 with q.indent(2):
1319 q.breakable()
1320 q.text("xid = ");
1321 if self.xid != None:
1322 q.text("%#x" % self.xid)
1323 else:
1324 q.text('None')
1325 q.text(","); q.breakable()
1326 q.text("enabled = ");
1327 q.text("%#x" % self.enabled)
1328 q.breakable()
1329 q.text('}')
1330
Rich Lane7dcdf022013-12-11 14:45:27 -08001331bsn_header.subtypes[20] = bsn_bw_enable_get_reply
1332
1333class bsn_bw_enable_get_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001334 version = 3
1335 type = 4
1336 experimenter = 6035143
1337 subtype = 19
1338
1339 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001340 if xid != None:
1341 self.xid = xid
1342 else:
1343 self.xid = None
1344 return
Dan Talaycof6202252013-07-02 01:00:29 -07001345
1346 def pack(self):
1347 packed = []
1348 packed.append(struct.pack("!B", self.version))
1349 packed.append(struct.pack("!B", self.type))
1350 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1351 packed.append(struct.pack("!L", self.xid))
1352 packed.append(struct.pack("!L", self.experimenter))
1353 packed.append(struct.pack("!L", self.subtype))
1354 length = sum([len(x) for x in packed])
1355 packed[2] = struct.pack("!H", length)
1356 return ''.join(packed)
1357
1358 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001359 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001360 obj = bsn_bw_enable_get_request()
Dan Talaycof6202252013-07-02 01:00:29 -07001361 _version = reader.read("!B")[0]
1362 assert(_version == 3)
1363 _type = reader.read("!B")[0]
1364 assert(_type == 4)
1365 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001366 orig_reader = reader
1367 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001368 obj.xid = reader.read("!L")[0]
1369 _experimenter = reader.read("!L")[0]
1370 assert(_experimenter == 6035143)
1371 _subtype = reader.read("!L")[0]
1372 assert(_subtype == 19)
1373 return obj
1374
1375 def __eq__(self, other):
1376 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07001377 if self.xid != other.xid: return False
1378 return True
1379
Dan Talaycof6202252013-07-02 01:00:29 -07001380 def pretty_print(self, q):
1381 q.text("bsn_bw_enable_get_request {")
1382 with q.group():
1383 with q.indent(2):
1384 q.breakable()
1385 q.text("xid = ");
1386 if self.xid != None:
1387 q.text("%#x" % self.xid)
1388 else:
1389 q.text('None')
1390 q.breakable()
1391 q.text('}')
1392
Rich Lane7dcdf022013-12-11 14:45:27 -08001393bsn_header.subtypes[19] = bsn_bw_enable_get_request
1394
1395class bsn_bw_enable_set_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001396 version = 3
1397 type = 4
1398 experimenter = 6035143
1399 subtype = 23
1400
1401 def __init__(self, xid=None, enable=None, status=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001402 if xid != None:
1403 self.xid = xid
1404 else:
1405 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07001406 if enable != None:
1407 self.enable = enable
1408 else:
1409 self.enable = 0
1410 if status != None:
1411 self.status = status
1412 else:
1413 self.status = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001414 return
Dan Talaycof6202252013-07-02 01:00:29 -07001415
1416 def pack(self):
1417 packed = []
1418 packed.append(struct.pack("!B", self.version))
1419 packed.append(struct.pack("!B", self.type))
1420 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1421 packed.append(struct.pack("!L", self.xid))
1422 packed.append(struct.pack("!L", self.experimenter))
1423 packed.append(struct.pack("!L", self.subtype))
1424 packed.append(struct.pack("!L", self.enable))
1425 packed.append(struct.pack("!L", self.status))
1426 length = sum([len(x) for x in packed])
1427 packed[2] = struct.pack("!H", length)
1428 return ''.join(packed)
1429
1430 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001431 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001432 obj = bsn_bw_enable_set_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07001433 _version = reader.read("!B")[0]
1434 assert(_version == 3)
1435 _type = reader.read("!B")[0]
1436 assert(_type == 4)
1437 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001438 orig_reader = reader
1439 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001440 obj.xid = reader.read("!L")[0]
1441 _experimenter = reader.read("!L")[0]
1442 assert(_experimenter == 6035143)
1443 _subtype = reader.read("!L")[0]
1444 assert(_subtype == 23)
1445 obj.enable = reader.read("!L")[0]
1446 obj.status = reader.read("!L")[0]
1447 return obj
1448
1449 def __eq__(self, other):
1450 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07001451 if self.xid != other.xid: return False
1452 if self.enable != other.enable: return False
1453 if self.status != other.status: return False
1454 return True
1455
Dan Talaycof6202252013-07-02 01:00:29 -07001456 def pretty_print(self, q):
1457 q.text("bsn_bw_enable_set_reply {")
1458 with q.group():
1459 with q.indent(2):
1460 q.breakable()
1461 q.text("xid = ");
1462 if self.xid != None:
1463 q.text("%#x" % self.xid)
1464 else:
1465 q.text('None')
1466 q.text(","); q.breakable()
1467 q.text("enable = ");
1468 q.text("%#x" % self.enable)
1469 q.text(","); q.breakable()
1470 q.text("status = ");
1471 q.text("%#x" % self.status)
1472 q.breakable()
1473 q.text('}')
1474
Rich Lane7dcdf022013-12-11 14:45:27 -08001475bsn_header.subtypes[23] = bsn_bw_enable_set_reply
1476
1477class bsn_bw_enable_set_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001478 version = 3
1479 type = 4
1480 experimenter = 6035143
1481 subtype = 18
1482
1483 def __init__(self, xid=None, enable=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001484 if xid != None:
1485 self.xid = xid
1486 else:
1487 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07001488 if enable != None:
1489 self.enable = enable
1490 else:
1491 self.enable = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001492 return
Dan Talaycof6202252013-07-02 01:00:29 -07001493
1494 def pack(self):
1495 packed = []
1496 packed.append(struct.pack("!B", self.version))
1497 packed.append(struct.pack("!B", self.type))
1498 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1499 packed.append(struct.pack("!L", self.xid))
1500 packed.append(struct.pack("!L", self.experimenter))
1501 packed.append(struct.pack("!L", self.subtype))
1502 packed.append(struct.pack("!L", self.enable))
1503 length = sum([len(x) for x in packed])
1504 packed[2] = struct.pack("!H", length)
1505 return ''.join(packed)
1506
1507 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001508 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001509 obj = bsn_bw_enable_set_request()
Dan Talaycof6202252013-07-02 01:00:29 -07001510 _version = reader.read("!B")[0]
1511 assert(_version == 3)
1512 _type = reader.read("!B")[0]
1513 assert(_type == 4)
1514 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001515 orig_reader = reader
1516 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001517 obj.xid = reader.read("!L")[0]
1518 _experimenter = reader.read("!L")[0]
1519 assert(_experimenter == 6035143)
1520 _subtype = reader.read("!L")[0]
1521 assert(_subtype == 18)
1522 obj.enable = reader.read("!L")[0]
1523 return obj
1524
1525 def __eq__(self, other):
1526 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07001527 if self.xid != other.xid: return False
1528 if self.enable != other.enable: return False
1529 return True
1530
Dan Talaycof6202252013-07-02 01:00:29 -07001531 def pretty_print(self, q):
1532 q.text("bsn_bw_enable_set_request {")
1533 with q.group():
1534 with q.indent(2):
1535 q.breakable()
1536 q.text("xid = ");
1537 if self.xid != None:
1538 q.text("%#x" % self.xid)
1539 else:
1540 q.text('None')
1541 q.text(","); q.breakable()
1542 q.text("enable = ");
1543 q.text("%#x" % self.enable)
1544 q.breakable()
1545 q.text('}')
1546
Rich Lane7dcdf022013-12-11 14:45:27 -08001547bsn_header.subtypes[18] = bsn_bw_enable_set_request
1548
1549class bsn_get_interfaces_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001550 version = 3
1551 type = 4
1552 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07001553 subtype = 10
1554
1555 def __init__(self, xid=None, interfaces=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001556 if xid != None:
1557 self.xid = xid
1558 else:
1559 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07001560 if interfaces != None:
1561 self.interfaces = interfaces
1562 else:
1563 self.interfaces = []
Rich Lane7dcdf022013-12-11 14:45:27 -08001564 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07001565
1566 def pack(self):
1567 packed = []
1568 packed.append(struct.pack("!B", self.version))
1569 packed.append(struct.pack("!B", self.type))
1570 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1571 packed.append(struct.pack("!L", self.xid))
1572 packed.append(struct.pack("!L", self.experimenter))
1573 packed.append(struct.pack("!L", self.subtype))
Rich Lane7dcdf022013-12-11 14:45:27 -08001574 packed.append(loxi.generic_util.pack_list(self.interfaces))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001575 length = sum([len(x) for x in packed])
1576 packed[2] = struct.pack("!H", length)
1577 return ''.join(packed)
1578
1579 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001580 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001581 obj = bsn_get_interfaces_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07001582 _version = reader.read("!B")[0]
1583 assert(_version == 3)
1584 _type = reader.read("!B")[0]
1585 assert(_type == 4)
1586 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001587 orig_reader = reader
1588 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001589 obj.xid = reader.read("!L")[0]
1590 _experimenter = reader.read("!L")[0]
1591 assert(_experimenter == 6035143)
1592 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001593 assert(_subtype == 10)
1594 obj.interfaces = loxi.generic_util.unpack_list(reader, common.bsn_interface.unpack)
1595 return obj
1596
1597 def __eq__(self, other):
1598 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001599 if self.xid != other.xid: return False
1600 if self.interfaces != other.interfaces: return False
1601 return True
1602
Rich Lanec2ee4b82013-04-24 17:12:38 -07001603 def pretty_print(self, q):
1604 q.text("bsn_get_interfaces_reply {")
1605 with q.group():
1606 with q.indent(2):
1607 q.breakable()
1608 q.text("xid = ");
1609 if self.xid != None:
1610 q.text("%#x" % self.xid)
1611 else:
1612 q.text('None')
1613 q.text(","); q.breakable()
1614 q.text("interfaces = ");
1615 q.pp(self.interfaces)
1616 q.breakable()
1617 q.text('}')
1618
Rich Lane7dcdf022013-12-11 14:45:27 -08001619bsn_header.subtypes[10] = bsn_get_interfaces_reply
1620
1621class bsn_get_interfaces_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001622 version = 3
1623 type = 4
1624 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07001625 subtype = 9
1626
1627 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001628 if xid != None:
1629 self.xid = xid
1630 else:
1631 self.xid = None
1632 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07001633
1634 def pack(self):
1635 packed = []
1636 packed.append(struct.pack("!B", self.version))
1637 packed.append(struct.pack("!B", self.type))
1638 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1639 packed.append(struct.pack("!L", self.xid))
1640 packed.append(struct.pack("!L", self.experimenter))
1641 packed.append(struct.pack("!L", self.subtype))
1642 length = sum([len(x) for x in packed])
1643 packed[2] = struct.pack("!H", length)
1644 return ''.join(packed)
1645
1646 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001647 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001648 obj = bsn_get_interfaces_request()
Dan Talaycof6202252013-07-02 01:00:29 -07001649 _version = reader.read("!B")[0]
1650 assert(_version == 3)
1651 _type = reader.read("!B")[0]
1652 assert(_type == 4)
1653 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001654 orig_reader = reader
1655 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001656 obj.xid = reader.read("!L")[0]
1657 _experimenter = reader.read("!L")[0]
1658 assert(_experimenter == 6035143)
1659 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001660 assert(_subtype == 9)
1661 return obj
1662
1663 def __eq__(self, other):
1664 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001665 if self.xid != other.xid: return False
1666 return True
1667
Rich Lanec2ee4b82013-04-24 17:12:38 -07001668 def pretty_print(self, q):
1669 q.text("bsn_get_interfaces_request {")
1670 with q.group():
1671 with q.indent(2):
1672 q.breakable()
1673 q.text("xid = ");
1674 if self.xid != None:
1675 q.text("%#x" % self.xid)
1676 else:
1677 q.text('None')
1678 q.breakable()
1679 q.text('}')
1680
Rich Lane7dcdf022013-12-11 14:45:27 -08001681bsn_header.subtypes[9] = bsn_get_interfaces_request
1682
1683class bsn_get_mirroring_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001684 version = 3
1685 type = 4
1686 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07001687 subtype = 5
1688
1689 def __init__(self, xid=None, report_mirror_ports=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001690 if xid != None:
1691 self.xid = xid
1692 else:
1693 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07001694 if report_mirror_ports != None:
1695 self.report_mirror_ports = report_mirror_ports
1696 else:
1697 self.report_mirror_ports = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001698 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07001699
1700 def pack(self):
1701 packed = []
1702 packed.append(struct.pack("!B", self.version))
1703 packed.append(struct.pack("!B", self.type))
1704 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1705 packed.append(struct.pack("!L", self.xid))
1706 packed.append(struct.pack("!L", self.experimenter))
1707 packed.append(struct.pack("!L", self.subtype))
1708 packed.append(struct.pack("!B", self.report_mirror_ports))
1709 packed.append('\x00' * 3)
1710 length = sum([len(x) for x in packed])
1711 packed[2] = struct.pack("!H", length)
1712 return ''.join(packed)
1713
1714 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001715 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001716 obj = bsn_get_mirroring_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07001717 _version = reader.read("!B")[0]
1718 assert(_version == 3)
1719 _type = reader.read("!B")[0]
1720 assert(_type == 4)
1721 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001722 orig_reader = reader
1723 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001724 obj.xid = reader.read("!L")[0]
1725 _experimenter = reader.read("!L")[0]
1726 assert(_experimenter == 6035143)
1727 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001728 assert(_subtype == 5)
Dan Talaycof6202252013-07-02 01:00:29 -07001729 obj.report_mirror_ports = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001730 reader.skip(3)
1731 return obj
1732
1733 def __eq__(self, other):
1734 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001735 if self.xid != other.xid: return False
1736 if self.report_mirror_ports != other.report_mirror_ports: return False
1737 return True
1738
Rich Lanec2ee4b82013-04-24 17:12:38 -07001739 def pretty_print(self, q):
1740 q.text("bsn_get_mirroring_reply {")
1741 with q.group():
1742 with q.indent(2):
1743 q.breakable()
1744 q.text("xid = ");
1745 if self.xid != None:
1746 q.text("%#x" % self.xid)
1747 else:
1748 q.text('None')
1749 q.text(","); q.breakable()
1750 q.text("report_mirror_ports = ");
1751 q.text("%#x" % self.report_mirror_ports)
1752 q.breakable()
1753 q.text('}')
1754
Rich Lane7dcdf022013-12-11 14:45:27 -08001755bsn_header.subtypes[5] = bsn_get_mirroring_reply
1756
1757class bsn_get_mirroring_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001758 version = 3
1759 type = 4
1760 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07001761 subtype = 4
1762
1763 def __init__(self, xid=None, report_mirror_ports=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001764 if xid != None:
1765 self.xid = xid
1766 else:
1767 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07001768 if report_mirror_ports != None:
1769 self.report_mirror_ports = report_mirror_ports
1770 else:
1771 self.report_mirror_ports = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001772 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07001773
1774 def pack(self):
1775 packed = []
1776 packed.append(struct.pack("!B", self.version))
1777 packed.append(struct.pack("!B", self.type))
1778 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1779 packed.append(struct.pack("!L", self.xid))
1780 packed.append(struct.pack("!L", self.experimenter))
1781 packed.append(struct.pack("!L", self.subtype))
1782 packed.append(struct.pack("!B", self.report_mirror_ports))
1783 packed.append('\x00' * 3)
1784 length = sum([len(x) for x in packed])
1785 packed[2] = struct.pack("!H", length)
1786 return ''.join(packed)
1787
1788 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001789 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001790 obj = bsn_get_mirroring_request()
Dan Talaycof6202252013-07-02 01:00:29 -07001791 _version = reader.read("!B")[0]
1792 assert(_version == 3)
1793 _type = reader.read("!B")[0]
1794 assert(_type == 4)
1795 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001796 orig_reader = reader
1797 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001798 obj.xid = reader.read("!L")[0]
1799 _experimenter = reader.read("!L")[0]
1800 assert(_experimenter == 6035143)
1801 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001802 assert(_subtype == 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001803 obj.report_mirror_ports = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001804 reader.skip(3)
1805 return obj
1806
1807 def __eq__(self, other):
1808 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001809 if self.xid != other.xid: return False
1810 if self.report_mirror_ports != other.report_mirror_ports: return False
1811 return True
1812
Rich Lanec2ee4b82013-04-24 17:12:38 -07001813 def pretty_print(self, q):
1814 q.text("bsn_get_mirroring_request {")
1815 with q.group():
1816 with q.indent(2):
1817 q.breakable()
1818 q.text("xid = ");
1819 if self.xid != None:
1820 q.text("%#x" % self.xid)
1821 else:
1822 q.text('None')
1823 q.text(","); q.breakable()
1824 q.text("report_mirror_ports = ");
1825 q.text("%#x" % self.report_mirror_ports)
1826 q.breakable()
1827 q.text('}')
1828
Rich Lane7dcdf022013-12-11 14:45:27 -08001829bsn_header.subtypes[4] = bsn_get_mirroring_request
1830
1831class bsn_pdu_rx_reply(bsn_header):
Rich Lane6f4978c2013-10-20 21:33:52 -07001832 version = 3
1833 type = 4
1834 experimenter = 6035143
1835 subtype = 34
1836
Rich Lane7b0f2012013-11-22 14:15:26 -08001837 def __init__(self, xid=None, status=None, port_no=None, slot_num=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001838 if xid != None:
1839 self.xid = xid
1840 else:
1841 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07001842 if status != None:
1843 self.status = status
1844 else:
1845 self.status = 0
Rich Lane7b0f2012013-11-22 14:15:26 -08001846 if port_no != None:
1847 self.port_no = port_no
1848 else:
1849 self.port_no = 0
1850 if slot_num != None:
1851 self.slot_num = slot_num
1852 else:
1853 self.slot_num = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001854 return
Rich Lane6f4978c2013-10-20 21:33:52 -07001855
1856 def pack(self):
1857 packed = []
1858 packed.append(struct.pack("!B", self.version))
1859 packed.append(struct.pack("!B", self.type))
1860 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1861 packed.append(struct.pack("!L", self.xid))
1862 packed.append(struct.pack("!L", self.experimenter))
1863 packed.append(struct.pack("!L", self.subtype))
1864 packed.append(struct.pack("!L", self.status))
Rich Lane7b0f2012013-11-22 14:15:26 -08001865 packed.append(util.pack_port_no(self.port_no))
1866 packed.append(struct.pack("!B", self.slot_num))
Rich Lane6f4978c2013-10-20 21:33:52 -07001867 length = sum([len(x) for x in packed])
1868 packed[2] = struct.pack("!H", length)
1869 return ''.join(packed)
1870
1871 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001872 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07001873 obj = bsn_pdu_rx_reply()
Rich Lane6f4978c2013-10-20 21:33:52 -07001874 _version = reader.read("!B")[0]
1875 assert(_version == 3)
1876 _type = reader.read("!B")[0]
1877 assert(_type == 4)
1878 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001879 orig_reader = reader
1880 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07001881 obj.xid = reader.read("!L")[0]
1882 _experimenter = reader.read("!L")[0]
1883 assert(_experimenter == 6035143)
1884 _subtype = reader.read("!L")[0]
1885 assert(_subtype == 34)
1886 obj.status = reader.read("!L")[0]
Rich Lane7b0f2012013-11-22 14:15:26 -08001887 obj.port_no = util.unpack_port_no(reader)
1888 obj.slot_num = reader.read("!B")[0]
Rich Lane6f4978c2013-10-20 21:33:52 -07001889 return obj
1890
1891 def __eq__(self, other):
1892 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001893 if self.xid != other.xid: return False
1894 if self.status != other.status: return False
Rich Lane7b0f2012013-11-22 14:15:26 -08001895 if self.port_no != other.port_no: return False
1896 if self.slot_num != other.slot_num: return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001897 return True
1898
Rich Lane6f4978c2013-10-20 21:33:52 -07001899 def pretty_print(self, q):
1900 q.text("bsn_pdu_rx_reply {")
1901 with q.group():
1902 with q.indent(2):
1903 q.breakable()
1904 q.text("xid = ");
1905 if self.xid != None:
1906 q.text("%#x" % self.xid)
1907 else:
1908 q.text('None')
1909 q.text(","); q.breakable()
1910 q.text("status = ");
1911 q.text("%#x" % self.status)
Rich Lane7b0f2012013-11-22 14:15:26 -08001912 q.text(","); q.breakable()
1913 q.text("port_no = ");
1914 q.text(util.pretty_port(self.port_no))
1915 q.text(","); q.breakable()
1916 q.text("slot_num = ");
1917 q.text("%#x" % self.slot_num)
Rich Lane6f4978c2013-10-20 21:33:52 -07001918 q.breakable()
1919 q.text('}')
1920
Rich Lane7dcdf022013-12-11 14:45:27 -08001921bsn_header.subtypes[34] = bsn_pdu_rx_reply
1922
1923class bsn_pdu_rx_request(bsn_header):
Rich Lane6f4978c2013-10-20 21:33:52 -07001924 version = 3
1925 type = 4
1926 experimenter = 6035143
1927 subtype = 33
1928
1929 def __init__(self, xid=None, timeout_ms=None, port_no=None, slot_num=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001930 if xid != None:
1931 self.xid = xid
1932 else:
1933 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07001934 if timeout_ms != None:
1935 self.timeout_ms = timeout_ms
1936 else:
1937 self.timeout_ms = 0
1938 if port_no != None:
1939 self.port_no = port_no
1940 else:
1941 self.port_no = 0
1942 if slot_num != None:
1943 self.slot_num = slot_num
1944 else:
1945 self.slot_num = 0
1946 if data != None:
1947 self.data = data
1948 else:
1949 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08001950 return
Rich Lane6f4978c2013-10-20 21:33:52 -07001951
1952 def pack(self):
1953 packed = []
1954 packed.append(struct.pack("!B", self.version))
1955 packed.append(struct.pack("!B", self.type))
1956 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1957 packed.append(struct.pack("!L", self.xid))
1958 packed.append(struct.pack("!L", self.experimenter))
1959 packed.append(struct.pack("!L", self.subtype))
1960 packed.append(struct.pack("!L", self.timeout_ms))
1961 packed.append(util.pack_port_no(self.port_no))
1962 packed.append(struct.pack("!B", self.slot_num))
1963 packed.append('\x00' * 3)
1964 packed.append(self.data)
1965 length = sum([len(x) for x in packed])
1966 packed[2] = struct.pack("!H", length)
1967 return ''.join(packed)
1968
1969 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001970 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07001971 obj = bsn_pdu_rx_request()
Rich Lane6f4978c2013-10-20 21:33:52 -07001972 _version = reader.read("!B")[0]
1973 assert(_version == 3)
1974 _type = reader.read("!B")[0]
1975 assert(_type == 4)
1976 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001977 orig_reader = reader
1978 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07001979 obj.xid = reader.read("!L")[0]
1980 _experimenter = reader.read("!L")[0]
1981 assert(_experimenter == 6035143)
1982 _subtype = reader.read("!L")[0]
1983 assert(_subtype == 33)
1984 obj.timeout_ms = reader.read("!L")[0]
1985 obj.port_no = util.unpack_port_no(reader)
1986 obj.slot_num = reader.read("!B")[0]
1987 reader.skip(3)
1988 obj.data = str(reader.read_all())
1989 return obj
1990
1991 def __eq__(self, other):
1992 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001993 if self.xid != other.xid: return False
1994 if self.timeout_ms != other.timeout_ms: return False
1995 if self.port_no != other.port_no: return False
1996 if self.slot_num != other.slot_num: return False
1997 if self.data != other.data: return False
1998 return True
1999
Rich Lane6f4978c2013-10-20 21:33:52 -07002000 def pretty_print(self, q):
2001 q.text("bsn_pdu_rx_request {")
2002 with q.group():
2003 with q.indent(2):
2004 q.breakable()
2005 q.text("xid = ");
2006 if self.xid != None:
2007 q.text("%#x" % self.xid)
2008 else:
2009 q.text('None')
2010 q.text(","); q.breakable()
2011 q.text("timeout_ms = ");
2012 q.text("%#x" % self.timeout_ms)
2013 q.text(","); q.breakable()
2014 q.text("port_no = ");
2015 q.text(util.pretty_port(self.port_no))
2016 q.text(","); q.breakable()
2017 q.text("slot_num = ");
2018 q.text("%#x" % self.slot_num)
2019 q.text(","); q.breakable()
2020 q.text("data = ");
2021 q.pp(self.data)
2022 q.breakable()
2023 q.text('}')
2024
Rich Lane7dcdf022013-12-11 14:45:27 -08002025bsn_header.subtypes[33] = bsn_pdu_rx_request
2026
2027class bsn_pdu_rx_timeout(bsn_header):
Rich Lane6f4978c2013-10-20 21:33:52 -07002028 version = 3
2029 type = 4
2030 experimenter = 6035143
2031 subtype = 35
2032
2033 def __init__(self, xid=None, port_no=None, slot_num=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002034 if xid != None:
2035 self.xid = xid
2036 else:
2037 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07002038 if port_no != None:
2039 self.port_no = port_no
2040 else:
2041 self.port_no = 0
2042 if slot_num != None:
2043 self.slot_num = slot_num
2044 else:
2045 self.slot_num = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002046 return
Rich Lane6f4978c2013-10-20 21:33:52 -07002047
2048 def pack(self):
2049 packed = []
2050 packed.append(struct.pack("!B", self.version))
2051 packed.append(struct.pack("!B", self.type))
2052 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2053 packed.append(struct.pack("!L", self.xid))
2054 packed.append(struct.pack("!L", self.experimenter))
2055 packed.append(struct.pack("!L", self.subtype))
2056 packed.append(util.pack_port_no(self.port_no))
2057 packed.append(struct.pack("!B", self.slot_num))
2058 length = sum([len(x) for x in packed])
2059 packed[2] = struct.pack("!H", length)
2060 return ''.join(packed)
2061
2062 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002063 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07002064 obj = bsn_pdu_rx_timeout()
Rich Lane6f4978c2013-10-20 21:33:52 -07002065 _version = reader.read("!B")[0]
2066 assert(_version == 3)
2067 _type = reader.read("!B")[0]
2068 assert(_type == 4)
2069 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002070 orig_reader = reader
2071 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07002072 obj.xid = reader.read("!L")[0]
2073 _experimenter = reader.read("!L")[0]
2074 assert(_experimenter == 6035143)
2075 _subtype = reader.read("!L")[0]
2076 assert(_subtype == 35)
2077 obj.port_no = util.unpack_port_no(reader)
2078 obj.slot_num = reader.read("!B")[0]
2079 return obj
2080
2081 def __eq__(self, other):
2082 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07002083 if self.xid != other.xid: return False
2084 if self.port_no != other.port_no: return False
2085 if self.slot_num != other.slot_num: return False
2086 return True
2087
Rich Lane6f4978c2013-10-20 21:33:52 -07002088 def pretty_print(self, q):
2089 q.text("bsn_pdu_rx_timeout {")
2090 with q.group():
2091 with q.indent(2):
2092 q.breakable()
2093 q.text("xid = ");
2094 if self.xid != None:
2095 q.text("%#x" % self.xid)
2096 else:
2097 q.text('None')
2098 q.text(","); q.breakable()
2099 q.text("port_no = ");
2100 q.text(util.pretty_port(self.port_no))
2101 q.text(","); q.breakable()
2102 q.text("slot_num = ");
2103 q.text("%#x" % self.slot_num)
2104 q.breakable()
2105 q.text('}')
2106
Rich Lane7dcdf022013-12-11 14:45:27 -08002107bsn_header.subtypes[35] = bsn_pdu_rx_timeout
2108
2109class bsn_pdu_tx_reply(bsn_header):
Rich Lane6f4978c2013-10-20 21:33:52 -07002110 version = 3
2111 type = 4
2112 experimenter = 6035143
2113 subtype = 32
2114
Rich Lane7b0f2012013-11-22 14:15:26 -08002115 def __init__(self, xid=None, status=None, port_no=None, slot_num=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002116 if xid != None:
2117 self.xid = xid
2118 else:
2119 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07002120 if status != None:
2121 self.status = status
2122 else:
2123 self.status = 0
Rich Lane7b0f2012013-11-22 14:15:26 -08002124 if port_no != None:
2125 self.port_no = port_no
2126 else:
2127 self.port_no = 0
2128 if slot_num != None:
2129 self.slot_num = slot_num
2130 else:
2131 self.slot_num = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002132 return
Rich Lane6f4978c2013-10-20 21:33:52 -07002133
2134 def pack(self):
2135 packed = []
2136 packed.append(struct.pack("!B", self.version))
2137 packed.append(struct.pack("!B", self.type))
2138 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2139 packed.append(struct.pack("!L", self.xid))
2140 packed.append(struct.pack("!L", self.experimenter))
2141 packed.append(struct.pack("!L", self.subtype))
2142 packed.append(struct.pack("!L", self.status))
Rich Lane7b0f2012013-11-22 14:15:26 -08002143 packed.append(util.pack_port_no(self.port_no))
2144 packed.append(struct.pack("!B", self.slot_num))
Rich Lane6f4978c2013-10-20 21:33:52 -07002145 length = sum([len(x) for x in packed])
2146 packed[2] = struct.pack("!H", length)
2147 return ''.join(packed)
2148
2149 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002150 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07002151 obj = bsn_pdu_tx_reply()
Rich Lane6f4978c2013-10-20 21:33:52 -07002152 _version = reader.read("!B")[0]
2153 assert(_version == 3)
2154 _type = reader.read("!B")[0]
2155 assert(_type == 4)
2156 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002157 orig_reader = reader
2158 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07002159 obj.xid = reader.read("!L")[0]
2160 _experimenter = reader.read("!L")[0]
2161 assert(_experimenter == 6035143)
2162 _subtype = reader.read("!L")[0]
2163 assert(_subtype == 32)
2164 obj.status = reader.read("!L")[0]
Rich Lane7b0f2012013-11-22 14:15:26 -08002165 obj.port_no = util.unpack_port_no(reader)
2166 obj.slot_num = reader.read("!B")[0]
Rich Lane6f4978c2013-10-20 21:33:52 -07002167 return obj
2168
2169 def __eq__(self, other):
2170 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07002171 if self.xid != other.xid: return False
2172 if self.status != other.status: return False
Rich Lane7b0f2012013-11-22 14:15:26 -08002173 if self.port_no != other.port_no: return False
2174 if self.slot_num != other.slot_num: return False
Rich Lane6f4978c2013-10-20 21:33:52 -07002175 return True
2176
Rich Lane6f4978c2013-10-20 21:33:52 -07002177 def pretty_print(self, q):
2178 q.text("bsn_pdu_tx_reply {")
2179 with q.group():
2180 with q.indent(2):
2181 q.breakable()
2182 q.text("xid = ");
2183 if self.xid != None:
2184 q.text("%#x" % self.xid)
2185 else:
2186 q.text('None')
2187 q.text(","); q.breakable()
2188 q.text("status = ");
2189 q.text("%#x" % self.status)
Rich Lane7b0f2012013-11-22 14:15:26 -08002190 q.text(","); q.breakable()
2191 q.text("port_no = ");
2192 q.text(util.pretty_port(self.port_no))
2193 q.text(","); q.breakable()
2194 q.text("slot_num = ");
2195 q.text("%#x" % self.slot_num)
Rich Lane6f4978c2013-10-20 21:33:52 -07002196 q.breakable()
2197 q.text('}')
2198
Rich Lane7dcdf022013-12-11 14:45:27 -08002199bsn_header.subtypes[32] = bsn_pdu_tx_reply
2200
2201class bsn_pdu_tx_request(bsn_header):
Rich Lane6f4978c2013-10-20 21:33:52 -07002202 version = 3
2203 type = 4
2204 experimenter = 6035143
2205 subtype = 31
2206
2207 def __init__(self, xid=None, tx_interval_ms=None, port_no=None, slot_num=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002208 if xid != None:
2209 self.xid = xid
2210 else:
2211 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07002212 if tx_interval_ms != None:
2213 self.tx_interval_ms = tx_interval_ms
2214 else:
2215 self.tx_interval_ms = 0
2216 if port_no != None:
2217 self.port_no = port_no
2218 else:
2219 self.port_no = 0
2220 if slot_num != None:
2221 self.slot_num = slot_num
2222 else:
2223 self.slot_num = 0
2224 if data != None:
2225 self.data = data
2226 else:
2227 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08002228 return
Rich Lane6f4978c2013-10-20 21:33:52 -07002229
2230 def pack(self):
2231 packed = []
2232 packed.append(struct.pack("!B", self.version))
2233 packed.append(struct.pack("!B", self.type))
2234 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2235 packed.append(struct.pack("!L", self.xid))
2236 packed.append(struct.pack("!L", self.experimenter))
2237 packed.append(struct.pack("!L", self.subtype))
2238 packed.append(struct.pack("!L", self.tx_interval_ms))
2239 packed.append(util.pack_port_no(self.port_no))
2240 packed.append(struct.pack("!B", self.slot_num))
2241 packed.append('\x00' * 3)
2242 packed.append(self.data)
2243 length = sum([len(x) for x in packed])
2244 packed[2] = struct.pack("!H", length)
2245 return ''.join(packed)
2246
2247 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002248 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07002249 obj = bsn_pdu_tx_request()
Rich Lane6f4978c2013-10-20 21:33:52 -07002250 _version = reader.read("!B")[0]
2251 assert(_version == 3)
2252 _type = reader.read("!B")[0]
2253 assert(_type == 4)
2254 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002255 orig_reader = reader
2256 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07002257 obj.xid = reader.read("!L")[0]
2258 _experimenter = reader.read("!L")[0]
2259 assert(_experimenter == 6035143)
2260 _subtype = reader.read("!L")[0]
2261 assert(_subtype == 31)
2262 obj.tx_interval_ms = reader.read("!L")[0]
2263 obj.port_no = util.unpack_port_no(reader)
2264 obj.slot_num = reader.read("!B")[0]
2265 reader.skip(3)
2266 obj.data = str(reader.read_all())
2267 return obj
2268
2269 def __eq__(self, other):
2270 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07002271 if self.xid != other.xid: return False
2272 if self.tx_interval_ms != other.tx_interval_ms: return False
2273 if self.port_no != other.port_no: return False
2274 if self.slot_num != other.slot_num: return False
2275 if self.data != other.data: return False
2276 return True
2277
Rich Lane6f4978c2013-10-20 21:33:52 -07002278 def pretty_print(self, q):
2279 q.text("bsn_pdu_tx_request {")
2280 with q.group():
2281 with q.indent(2):
2282 q.breakable()
2283 q.text("xid = ");
2284 if self.xid != None:
2285 q.text("%#x" % self.xid)
2286 else:
2287 q.text('None')
2288 q.text(","); q.breakable()
2289 q.text("tx_interval_ms = ");
2290 q.text("%#x" % self.tx_interval_ms)
2291 q.text(","); q.breakable()
2292 q.text("port_no = ");
2293 q.text(util.pretty_port(self.port_no))
2294 q.text(","); q.breakable()
2295 q.text("slot_num = ");
2296 q.text("%#x" % self.slot_num)
2297 q.text(","); q.breakable()
2298 q.text("data = ");
2299 q.pp(self.data)
2300 q.breakable()
2301 q.text('}')
2302
Rich Lane7dcdf022013-12-11 14:45:27 -08002303bsn_header.subtypes[31] = bsn_pdu_tx_request
2304
2305class bsn_set_mirroring(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07002306 version = 3
2307 type = 4
2308 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07002309 subtype = 3
2310
2311 def __init__(self, xid=None, report_mirror_ports=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002312 if xid != None:
2313 self.xid = xid
2314 else:
2315 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07002316 if report_mirror_ports != None:
2317 self.report_mirror_ports = report_mirror_ports
2318 else:
2319 self.report_mirror_ports = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002320 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07002321
2322 def pack(self):
2323 packed = []
2324 packed.append(struct.pack("!B", self.version))
2325 packed.append(struct.pack("!B", self.type))
2326 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2327 packed.append(struct.pack("!L", self.xid))
2328 packed.append(struct.pack("!L", self.experimenter))
2329 packed.append(struct.pack("!L", self.subtype))
2330 packed.append(struct.pack("!B", self.report_mirror_ports))
2331 packed.append('\x00' * 3)
2332 length = sum([len(x) for x in packed])
2333 packed[2] = struct.pack("!H", length)
2334 return ''.join(packed)
2335
2336 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002337 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002338 obj = bsn_set_mirroring()
Dan Talaycof6202252013-07-02 01:00:29 -07002339 _version = reader.read("!B")[0]
2340 assert(_version == 3)
2341 _type = reader.read("!B")[0]
2342 assert(_type == 4)
2343 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002344 orig_reader = reader
2345 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002346 obj.xid = reader.read("!L")[0]
2347 _experimenter = reader.read("!L")[0]
2348 assert(_experimenter == 6035143)
2349 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002350 assert(_subtype == 3)
Dan Talaycof6202252013-07-02 01:00:29 -07002351 obj.report_mirror_ports = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002352 reader.skip(3)
2353 return obj
2354
2355 def __eq__(self, other):
2356 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002357 if self.xid != other.xid: return False
2358 if self.report_mirror_ports != other.report_mirror_ports: return False
2359 return True
2360
Rich Lanec2ee4b82013-04-24 17:12:38 -07002361 def pretty_print(self, q):
2362 q.text("bsn_set_mirroring {")
2363 with q.group():
2364 with q.indent(2):
2365 q.breakable()
2366 q.text("xid = ");
2367 if self.xid != None:
2368 q.text("%#x" % self.xid)
2369 else:
2370 q.text('None')
2371 q.text(","); q.breakable()
2372 q.text("report_mirror_ports = ");
2373 q.text("%#x" % self.report_mirror_ports)
2374 q.breakable()
2375 q.text('}')
2376
Rich Lane7dcdf022013-12-11 14:45:27 -08002377bsn_header.subtypes[3] = bsn_set_mirroring
2378
2379class bsn_set_pktin_suppression_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07002380 version = 3
2381 type = 4
2382 experimenter = 6035143
2383 subtype = 25
2384
2385 def __init__(self, xid=None, status=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002386 if xid != None:
2387 self.xid = xid
2388 else:
2389 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07002390 if status != None:
2391 self.status = status
2392 else:
2393 self.status = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002394 return
Dan Talaycof6202252013-07-02 01:00:29 -07002395
2396 def pack(self):
2397 packed = []
2398 packed.append(struct.pack("!B", self.version))
2399 packed.append(struct.pack("!B", self.type))
2400 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2401 packed.append(struct.pack("!L", self.xid))
2402 packed.append(struct.pack("!L", self.experimenter))
2403 packed.append(struct.pack("!L", self.subtype))
2404 packed.append(struct.pack("!L", self.status))
2405 length = sum([len(x) for x in packed])
2406 packed[2] = struct.pack("!H", length)
2407 return ''.join(packed)
2408
2409 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002410 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07002411 obj = bsn_set_pktin_suppression_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07002412 _version = reader.read("!B")[0]
2413 assert(_version == 3)
2414 _type = reader.read("!B")[0]
2415 assert(_type == 4)
2416 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002417 orig_reader = reader
2418 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002419 obj.xid = reader.read("!L")[0]
2420 _experimenter = reader.read("!L")[0]
2421 assert(_experimenter == 6035143)
2422 _subtype = reader.read("!L")[0]
2423 assert(_subtype == 25)
2424 obj.status = reader.read("!L")[0]
2425 return obj
2426
2427 def __eq__(self, other):
2428 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07002429 if self.xid != other.xid: return False
2430 if self.status != other.status: return False
2431 return True
2432
Dan Talaycof6202252013-07-02 01:00:29 -07002433 def pretty_print(self, q):
2434 q.text("bsn_set_pktin_suppression_reply {")
2435 with q.group():
2436 with q.indent(2):
2437 q.breakable()
2438 q.text("xid = ");
2439 if self.xid != None:
2440 q.text("%#x" % self.xid)
2441 else:
2442 q.text('None')
2443 q.text(","); q.breakable()
2444 q.text("status = ");
2445 q.text("%#x" % self.status)
2446 q.breakable()
2447 q.text('}')
2448
Rich Lane7dcdf022013-12-11 14:45:27 -08002449bsn_header.subtypes[25] = bsn_set_pktin_suppression_reply
2450
2451class bsn_set_pktin_suppression_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07002452 version = 3
2453 type = 4
2454 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07002455 subtype = 11
2456
2457 def __init__(self, xid=None, enabled=None, idle_timeout=None, hard_timeout=None, priority=None, cookie=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002458 if xid != None:
2459 self.xid = xid
2460 else:
2461 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07002462 if enabled != None:
2463 self.enabled = enabled
2464 else:
2465 self.enabled = 0
2466 if idle_timeout != None:
2467 self.idle_timeout = idle_timeout
2468 else:
2469 self.idle_timeout = 0
2470 if hard_timeout != None:
2471 self.hard_timeout = hard_timeout
2472 else:
2473 self.hard_timeout = 0
2474 if priority != None:
2475 self.priority = priority
2476 else:
2477 self.priority = 0
2478 if cookie != None:
2479 self.cookie = cookie
2480 else:
2481 self.cookie = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002482 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07002483
2484 def pack(self):
2485 packed = []
2486 packed.append(struct.pack("!B", self.version))
2487 packed.append(struct.pack("!B", self.type))
2488 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2489 packed.append(struct.pack("!L", self.xid))
2490 packed.append(struct.pack("!L", self.experimenter))
2491 packed.append(struct.pack("!L", self.subtype))
2492 packed.append(struct.pack("!B", self.enabled))
2493 packed.append('\x00' * 1)
2494 packed.append(struct.pack("!H", self.idle_timeout))
2495 packed.append(struct.pack("!H", self.hard_timeout))
2496 packed.append(struct.pack("!H", self.priority))
2497 packed.append(struct.pack("!Q", self.cookie))
2498 length = sum([len(x) for x in packed])
2499 packed[2] = struct.pack("!H", length)
2500 return ''.join(packed)
2501
2502 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002503 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07002504 obj = bsn_set_pktin_suppression_request()
Dan Talaycof6202252013-07-02 01:00:29 -07002505 _version = reader.read("!B")[0]
2506 assert(_version == 3)
2507 _type = reader.read("!B")[0]
2508 assert(_type == 4)
2509 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002510 orig_reader = reader
2511 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002512 obj.xid = reader.read("!L")[0]
2513 _experimenter = reader.read("!L")[0]
2514 assert(_experimenter == 6035143)
2515 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002516 assert(_subtype == 11)
Dan Talaycof6202252013-07-02 01:00:29 -07002517 obj.enabled = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002518 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -07002519 obj.idle_timeout = reader.read("!H")[0]
2520 obj.hard_timeout = reader.read("!H")[0]
2521 obj.priority = reader.read("!H")[0]
2522 obj.cookie = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002523 return obj
2524
2525 def __eq__(self, other):
2526 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002527 if self.xid != other.xid: return False
2528 if self.enabled != other.enabled: return False
2529 if self.idle_timeout != other.idle_timeout: return False
2530 if self.hard_timeout != other.hard_timeout: return False
2531 if self.priority != other.priority: return False
2532 if self.cookie != other.cookie: return False
2533 return True
2534
Rich Lanec2ee4b82013-04-24 17:12:38 -07002535 def pretty_print(self, q):
Dan Talaycof6202252013-07-02 01:00:29 -07002536 q.text("bsn_set_pktin_suppression_request {")
Rich Lanec2ee4b82013-04-24 17:12:38 -07002537 with q.group():
2538 with q.indent(2):
2539 q.breakable()
2540 q.text("xid = ");
2541 if self.xid != None:
2542 q.text("%#x" % self.xid)
2543 else:
2544 q.text('None')
2545 q.text(","); q.breakable()
2546 q.text("enabled = ");
2547 q.text("%#x" % self.enabled)
2548 q.text(","); q.breakable()
2549 q.text("idle_timeout = ");
2550 q.text("%#x" % self.idle_timeout)
2551 q.text(","); q.breakable()
2552 q.text("hard_timeout = ");
2553 q.text("%#x" % self.hard_timeout)
2554 q.text(","); q.breakable()
2555 q.text("priority = ");
2556 q.text("%#x" % self.priority)
2557 q.text(","); q.breakable()
2558 q.text("cookie = ");
2559 q.text("%#x" % self.cookie)
2560 q.breakable()
2561 q.text('}')
2562
Rich Lane7dcdf022013-12-11 14:45:27 -08002563bsn_header.subtypes[11] = bsn_set_pktin_suppression_request
2564
2565class experimenter_stats_reply(stats_reply):
2566 subtypes = {}
2567
Rich Lane95f7fc92014-01-27 17:08:16 -08002568 version = 3
2569 type = 19
2570 stats_type = 65535
2571
2572 def __init__(self, xid=None, flags=None, experimenter=None, subtype=None, data=None):
2573 if xid != None:
2574 self.xid = xid
2575 else:
2576 self.xid = None
2577 if flags != None:
2578 self.flags = flags
2579 else:
2580 self.flags = 0
2581 if experimenter != None:
2582 self.experimenter = experimenter
2583 else:
2584 self.experimenter = 0
2585 if subtype != None:
2586 self.subtype = subtype
2587 else:
2588 self.subtype = 0
2589 if data != None:
2590 self.data = data
2591 else:
2592 self.data = ''
2593 return
2594
2595 def pack(self):
2596 packed = []
2597 packed.append(struct.pack("!B", self.version))
2598 packed.append(struct.pack("!B", self.type))
2599 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2600 packed.append(struct.pack("!L", self.xid))
2601 packed.append(struct.pack("!H", self.stats_type))
2602 packed.append(struct.pack("!H", self.flags))
2603 packed.append('\x00' * 4)
2604 packed.append(struct.pack("!L", self.experimenter))
2605 packed.append(struct.pack("!L", self.subtype))
2606 packed.append(self.data)
2607 length = sum([len(x) for x in packed])
2608 packed[2] = struct.pack("!H", length)
2609 return ''.join(packed)
2610
Rich Lane7dcdf022013-12-11 14:45:27 -08002611 @staticmethod
2612 def unpack(reader):
2613 subtype, = reader.peek('!L', 16)
Rich Lane95f7fc92014-01-27 17:08:16 -08002614 subclass = experimenter_stats_reply.subtypes.get(subtype)
2615 if subclass:
2616 return subclass.unpack(reader)
2617
2618 obj = experimenter_stats_reply()
2619 _version = reader.read("!B")[0]
2620 assert(_version == 3)
2621 _type = reader.read("!B")[0]
2622 assert(_type == 19)
2623 _length = reader.read("!H")[0]
2624 orig_reader = reader
2625 reader = orig_reader.slice(_length - (2 + 2))
2626 obj.xid = reader.read("!L")[0]
2627 _stats_type = reader.read("!H")[0]
2628 assert(_stats_type == 65535)
2629 obj.flags = reader.read("!H")[0]
2630 reader.skip(4)
2631 obj.experimenter = reader.read("!L")[0]
2632 obj.subtype = reader.read("!L")[0]
2633 obj.data = str(reader.read_all())
2634 return obj
2635
2636 def __eq__(self, other):
2637 if type(self) != type(other): return False
2638 if self.xid != other.xid: return False
2639 if self.flags != other.flags: return False
2640 if self.experimenter != other.experimenter: return False
2641 if self.subtype != other.subtype: return False
2642 if self.data != other.data: return False
2643 return True
2644
2645 def pretty_print(self, q):
2646 q.text("experimenter_stats_reply {")
2647 with q.group():
2648 with q.indent(2):
2649 q.breakable()
2650 q.text("xid = ");
2651 if self.xid != None:
2652 q.text("%#x" % self.xid)
2653 else:
2654 q.text('None')
2655 q.text(","); q.breakable()
2656 q.text("flags = ");
2657 q.text("%#x" % self.flags)
2658 q.text(","); q.breakable()
2659 q.text("subtype = ");
2660 q.text("%#x" % self.subtype)
2661 q.text(","); q.breakable()
2662 q.text("data = ");
2663 q.pp(self.data)
2664 q.breakable()
2665 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002666
2667stats_reply.subtypes[65535] = experimenter_stats_reply
2668
2669class bsn_stats_reply(experimenter_stats_reply):
2670 subtypes = {}
2671
Rich Lane95f7fc92014-01-27 17:08:16 -08002672 version = 3
2673 type = 19
2674 stats_type = 65535
2675 experimenter = 6035143
2676
2677 def __init__(self, xid=None, flags=None, subtype=None):
2678 if xid != None:
2679 self.xid = xid
2680 else:
2681 self.xid = None
2682 if flags != None:
2683 self.flags = flags
2684 else:
2685 self.flags = 0
2686 if subtype != None:
2687 self.subtype = subtype
2688 else:
2689 self.subtype = 0
2690 return
2691
2692 def pack(self):
2693 packed = []
2694 packed.append(struct.pack("!B", self.version))
2695 packed.append(struct.pack("!B", self.type))
2696 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2697 packed.append(struct.pack("!L", self.xid))
2698 packed.append(struct.pack("!H", self.stats_type))
2699 packed.append(struct.pack("!H", self.flags))
2700 packed.append('\x00' * 4)
2701 packed.append(struct.pack("!L", self.experimenter))
2702 packed.append(struct.pack("!L", self.subtype))
2703 length = sum([len(x) for x in packed])
2704 packed[2] = struct.pack("!H", length)
2705 return ''.join(packed)
2706
Rich Lane7dcdf022013-12-11 14:45:27 -08002707 @staticmethod
2708 def unpack(reader):
2709 subtype, = reader.peek('!L', 20)
Rich Lane95f7fc92014-01-27 17:08:16 -08002710 subclass = bsn_stats_reply.subtypes.get(subtype)
2711 if subclass:
2712 return subclass.unpack(reader)
2713
2714 obj = bsn_stats_reply()
2715 _version = reader.read("!B")[0]
2716 assert(_version == 3)
2717 _type = reader.read("!B")[0]
2718 assert(_type == 19)
2719 _length = reader.read("!H")[0]
2720 orig_reader = reader
2721 reader = orig_reader.slice(_length - (2 + 2))
2722 obj.xid = reader.read("!L")[0]
2723 _stats_type = reader.read("!H")[0]
2724 assert(_stats_type == 65535)
2725 obj.flags = reader.read("!H")[0]
2726 reader.skip(4)
2727 _experimenter = reader.read("!L")[0]
2728 assert(_experimenter == 6035143)
2729 obj.subtype = reader.read("!L")[0]
2730 return obj
2731
2732 def __eq__(self, other):
2733 if type(self) != type(other): return False
2734 if self.xid != other.xid: return False
2735 if self.flags != other.flags: return False
2736 if self.subtype != other.subtype: return False
2737 return True
2738
2739 def pretty_print(self, q):
2740 q.text("bsn_stats_reply {")
2741 with q.group():
2742 with q.indent(2):
2743 q.breakable()
2744 q.text("xid = ");
2745 if self.xid != None:
2746 q.text("%#x" % self.xid)
2747 else:
2748 q.text('None')
2749 q.text(","); q.breakable()
2750 q.text("flags = ");
2751 q.text("%#x" % self.flags)
2752 q.breakable()
2753 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002754
2755experimenter_stats_reply.subtypes[6035143] = bsn_stats_reply
2756
2757class experimenter_stats_request(stats_request):
2758 subtypes = {}
2759
Rich Lane95f7fc92014-01-27 17:08:16 -08002760 version = 3
2761 type = 18
2762 stats_type = 65535
2763
2764 def __init__(self, xid=None, flags=None, experimenter=None, subtype=None, data=None):
2765 if xid != None:
2766 self.xid = xid
2767 else:
2768 self.xid = None
2769 if flags != None:
2770 self.flags = flags
2771 else:
2772 self.flags = 0
2773 if experimenter != None:
2774 self.experimenter = experimenter
2775 else:
2776 self.experimenter = 0
2777 if subtype != None:
2778 self.subtype = subtype
2779 else:
2780 self.subtype = 0
2781 if data != None:
2782 self.data = data
2783 else:
2784 self.data = ''
2785 return
2786
2787 def pack(self):
2788 packed = []
2789 packed.append(struct.pack("!B", self.version))
2790 packed.append(struct.pack("!B", self.type))
2791 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2792 packed.append(struct.pack("!L", self.xid))
2793 packed.append(struct.pack("!H", self.stats_type))
2794 packed.append(struct.pack("!H", self.flags))
2795 packed.append('\x00' * 4)
2796 packed.append(struct.pack("!L", self.experimenter))
2797 packed.append(struct.pack("!L", self.subtype))
2798 packed.append(self.data)
2799 length = sum([len(x) for x in packed])
2800 packed[2] = struct.pack("!H", length)
2801 return ''.join(packed)
2802
Rich Lane7dcdf022013-12-11 14:45:27 -08002803 @staticmethod
2804 def unpack(reader):
2805 subtype, = reader.peek('!L', 16)
Rich Lane95f7fc92014-01-27 17:08:16 -08002806 subclass = experimenter_stats_request.subtypes.get(subtype)
2807 if subclass:
2808 return subclass.unpack(reader)
2809
2810 obj = experimenter_stats_request()
2811 _version = reader.read("!B")[0]
2812 assert(_version == 3)
2813 _type = reader.read("!B")[0]
2814 assert(_type == 18)
2815 _length = reader.read("!H")[0]
2816 orig_reader = reader
2817 reader = orig_reader.slice(_length - (2 + 2))
2818 obj.xid = reader.read("!L")[0]
2819 _stats_type = reader.read("!H")[0]
2820 assert(_stats_type == 65535)
2821 obj.flags = reader.read("!H")[0]
2822 reader.skip(4)
2823 obj.experimenter = reader.read("!L")[0]
2824 obj.subtype = reader.read("!L")[0]
2825 obj.data = str(reader.read_all())
2826 return obj
2827
2828 def __eq__(self, other):
2829 if type(self) != type(other): return False
2830 if self.xid != other.xid: return False
2831 if self.flags != other.flags: return False
2832 if self.experimenter != other.experimenter: return False
2833 if self.subtype != other.subtype: return False
2834 if self.data != other.data: return False
2835 return True
2836
2837 def pretty_print(self, q):
2838 q.text("experimenter_stats_request {")
2839 with q.group():
2840 with q.indent(2):
2841 q.breakable()
2842 q.text("xid = ");
2843 if self.xid != None:
2844 q.text("%#x" % self.xid)
2845 else:
2846 q.text('None')
2847 q.text(","); q.breakable()
2848 q.text("flags = ");
2849 q.text("%#x" % self.flags)
2850 q.text(","); q.breakable()
2851 q.text("subtype = ");
2852 q.text("%#x" % self.subtype)
2853 q.text(","); q.breakable()
2854 q.text("data = ");
2855 q.pp(self.data)
2856 q.breakable()
2857 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002858
2859stats_request.subtypes[65535] = experimenter_stats_request
2860
2861class bsn_stats_request(experimenter_stats_request):
2862 subtypes = {}
2863
Rich Lane95f7fc92014-01-27 17:08:16 -08002864 version = 3
2865 type = 18
2866 stats_type = 65535
2867 experimenter = 6035143
2868
2869 def __init__(self, xid=None, flags=None, subtype=None):
2870 if xid != None:
2871 self.xid = xid
2872 else:
2873 self.xid = None
2874 if flags != None:
2875 self.flags = flags
2876 else:
2877 self.flags = 0
2878 if subtype != None:
2879 self.subtype = subtype
2880 else:
2881 self.subtype = 0
2882 return
2883
2884 def pack(self):
2885 packed = []
2886 packed.append(struct.pack("!B", self.version))
2887 packed.append(struct.pack("!B", self.type))
2888 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2889 packed.append(struct.pack("!L", self.xid))
2890 packed.append(struct.pack("!H", self.stats_type))
2891 packed.append(struct.pack("!H", self.flags))
2892 packed.append('\x00' * 4)
2893 packed.append(struct.pack("!L", self.experimenter))
2894 packed.append(struct.pack("!L", self.subtype))
2895 length = sum([len(x) for x in packed])
2896 packed[2] = struct.pack("!H", length)
2897 return ''.join(packed)
2898
Rich Lane7dcdf022013-12-11 14:45:27 -08002899 @staticmethod
2900 def unpack(reader):
2901 subtype, = reader.peek('!L', 20)
Rich Lane95f7fc92014-01-27 17:08:16 -08002902 subclass = bsn_stats_request.subtypes.get(subtype)
2903 if subclass:
2904 return subclass.unpack(reader)
2905
2906 obj = bsn_stats_request()
2907 _version = reader.read("!B")[0]
2908 assert(_version == 3)
2909 _type = reader.read("!B")[0]
2910 assert(_type == 18)
2911 _length = reader.read("!H")[0]
2912 orig_reader = reader
2913 reader = orig_reader.slice(_length - (2 + 2))
2914 obj.xid = reader.read("!L")[0]
2915 _stats_type = reader.read("!H")[0]
2916 assert(_stats_type == 65535)
2917 obj.flags = reader.read("!H")[0]
2918 reader.skip(4)
2919 _experimenter = reader.read("!L")[0]
2920 assert(_experimenter == 6035143)
2921 obj.subtype = reader.read("!L")[0]
2922 return obj
2923
2924 def __eq__(self, other):
2925 if type(self) != type(other): return False
2926 if self.xid != other.xid: return False
2927 if self.flags != other.flags: return False
2928 if self.subtype != other.subtype: return False
2929 return True
2930
2931 def pretty_print(self, q):
2932 q.text("bsn_stats_request {")
2933 with q.group():
2934 with q.indent(2):
2935 q.breakable()
2936 q.text("xid = ");
2937 if self.xid != None:
2938 q.text("%#x" % self.xid)
2939 else:
2940 q.text('None')
2941 q.text(","); q.breakable()
2942 q.text("flags = ");
2943 q.text("%#x" % self.flags)
2944 q.breakable()
2945 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002946
2947experimenter_stats_request.subtypes[6035143] = bsn_stats_request
2948
2949class bsn_virtual_port_create_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07002950 version = 3
2951 type = 4
2952 experimenter = 6035143
2953 subtype = 16
2954
2955 def __init__(self, xid=None, status=None, vport_no=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002956 if xid != None:
2957 self.xid = xid
2958 else:
2959 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07002960 if status != None:
2961 self.status = status
2962 else:
2963 self.status = 0
2964 if vport_no != None:
2965 self.vport_no = vport_no
2966 else:
2967 self.vport_no = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002968 return
Dan Talaycof6202252013-07-02 01:00:29 -07002969
2970 def pack(self):
2971 packed = []
2972 packed.append(struct.pack("!B", self.version))
2973 packed.append(struct.pack("!B", self.type))
2974 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2975 packed.append(struct.pack("!L", self.xid))
2976 packed.append(struct.pack("!L", self.experimenter))
2977 packed.append(struct.pack("!L", self.subtype))
2978 packed.append(struct.pack("!L", self.status))
2979 packed.append(struct.pack("!L", self.vport_no))
2980 length = sum([len(x) for x in packed])
2981 packed[2] = struct.pack("!H", length)
2982 return ''.join(packed)
2983
2984 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002985 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07002986 obj = bsn_virtual_port_create_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07002987 _version = reader.read("!B")[0]
2988 assert(_version == 3)
2989 _type = reader.read("!B")[0]
2990 assert(_type == 4)
2991 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002992 orig_reader = reader
2993 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002994 obj.xid = reader.read("!L")[0]
2995 _experimenter = reader.read("!L")[0]
2996 assert(_experimenter == 6035143)
2997 _subtype = reader.read("!L")[0]
2998 assert(_subtype == 16)
2999 obj.status = reader.read("!L")[0]
3000 obj.vport_no = reader.read("!L")[0]
3001 return obj
3002
3003 def __eq__(self, other):
3004 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07003005 if self.xid != other.xid: return False
3006 if self.status != other.status: return False
3007 if self.vport_no != other.vport_no: return False
3008 return True
3009
Dan Talaycof6202252013-07-02 01:00:29 -07003010 def pretty_print(self, q):
3011 q.text("bsn_virtual_port_create_reply {")
3012 with q.group():
3013 with q.indent(2):
3014 q.breakable()
3015 q.text("xid = ");
3016 if self.xid != None:
3017 q.text("%#x" % self.xid)
3018 else:
3019 q.text('None')
3020 q.text(","); q.breakable()
3021 q.text("status = ");
3022 q.text("%#x" % self.status)
3023 q.text(","); q.breakable()
3024 q.text("vport_no = ");
3025 q.text("%#x" % self.vport_no)
3026 q.breakable()
3027 q.text('}')
3028
Rich Lane7dcdf022013-12-11 14:45:27 -08003029bsn_header.subtypes[16] = bsn_virtual_port_create_reply
3030
3031class bsn_virtual_port_create_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07003032 version = 3
3033 type = 4
3034 experimenter = 6035143
3035 subtype = 15
3036
3037 def __init__(self, xid=None, vport=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003038 if xid != None:
3039 self.xid = xid
3040 else:
3041 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07003042 if vport != None:
3043 self.vport = vport
3044 else:
Rich Lane93b33132014-04-21 12:20:58 -07003045 self.vport = common.bsn_vport()
Rich Lane7dcdf022013-12-11 14:45:27 -08003046 return
Dan Talaycof6202252013-07-02 01:00:29 -07003047
3048 def pack(self):
3049 packed = []
3050 packed.append(struct.pack("!B", self.version))
3051 packed.append(struct.pack("!B", self.type))
3052 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3053 packed.append(struct.pack("!L", self.xid))
3054 packed.append(struct.pack("!L", self.experimenter))
3055 packed.append(struct.pack("!L", self.subtype))
3056 packed.append(self.vport.pack())
3057 length = sum([len(x) for x in packed])
3058 packed[2] = struct.pack("!H", length)
3059 return ''.join(packed)
3060
3061 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003062 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07003063 obj = bsn_virtual_port_create_request()
Dan Talaycof6202252013-07-02 01:00:29 -07003064 _version = reader.read("!B")[0]
3065 assert(_version == 3)
3066 _type = reader.read("!B")[0]
3067 assert(_type == 4)
3068 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003069 orig_reader = reader
3070 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003071 obj.xid = reader.read("!L")[0]
3072 _experimenter = reader.read("!L")[0]
3073 assert(_experimenter == 6035143)
3074 _subtype = reader.read("!L")[0]
3075 assert(_subtype == 15)
Rich Lane93b33132014-04-21 12:20:58 -07003076 obj.vport = common.bsn_vport.unpack(reader)
Dan Talaycof6202252013-07-02 01:00:29 -07003077 return obj
3078
3079 def __eq__(self, other):
3080 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07003081 if self.xid != other.xid: return False
3082 if self.vport != other.vport: return False
3083 return True
3084
Dan Talaycof6202252013-07-02 01:00:29 -07003085 def pretty_print(self, q):
3086 q.text("bsn_virtual_port_create_request {")
3087 with q.group():
3088 with q.indent(2):
3089 q.breakable()
3090 q.text("xid = ");
3091 if self.xid != None:
3092 q.text("%#x" % self.xid)
3093 else:
3094 q.text('None')
3095 q.text(","); q.breakable()
3096 q.text("vport = ");
3097 q.pp(self.vport)
3098 q.breakable()
3099 q.text('}')
3100
Rich Lane7dcdf022013-12-11 14:45:27 -08003101bsn_header.subtypes[15] = bsn_virtual_port_create_request
3102
3103class bsn_virtual_port_remove_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07003104 version = 3
3105 type = 4
3106 experimenter = 6035143
3107 subtype = 26
3108
3109 def __init__(self, xid=None, status=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003110 if xid != None:
3111 self.xid = xid
3112 else:
3113 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07003114 if status != None:
3115 self.status = status
3116 else:
3117 self.status = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08003118 return
Dan Talaycof6202252013-07-02 01:00:29 -07003119
3120 def pack(self):
3121 packed = []
3122 packed.append(struct.pack("!B", self.version))
3123 packed.append(struct.pack("!B", self.type))
3124 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3125 packed.append(struct.pack("!L", self.xid))
3126 packed.append(struct.pack("!L", self.experimenter))
3127 packed.append(struct.pack("!L", self.subtype))
3128 packed.append(struct.pack("!L", self.status))
3129 length = sum([len(x) for x in packed])
3130 packed[2] = struct.pack("!H", length)
3131 return ''.join(packed)
3132
3133 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003134 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07003135 obj = bsn_virtual_port_remove_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07003136 _version = reader.read("!B")[0]
3137 assert(_version == 3)
3138 _type = reader.read("!B")[0]
3139 assert(_type == 4)
3140 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003141 orig_reader = reader
3142 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003143 obj.xid = reader.read("!L")[0]
3144 _experimenter = reader.read("!L")[0]
3145 assert(_experimenter == 6035143)
3146 _subtype = reader.read("!L")[0]
3147 assert(_subtype == 26)
3148 obj.status = reader.read("!L")[0]
3149 return obj
3150
3151 def __eq__(self, other):
3152 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07003153 if self.xid != other.xid: return False
3154 if self.status != other.status: return False
3155 return True
3156
Dan Talaycof6202252013-07-02 01:00:29 -07003157 def pretty_print(self, q):
3158 q.text("bsn_virtual_port_remove_reply {")
3159 with q.group():
3160 with q.indent(2):
3161 q.breakable()
3162 q.text("xid = ");
3163 if self.xid != None:
3164 q.text("%#x" % self.xid)
3165 else:
3166 q.text('None')
3167 q.text(","); q.breakable()
3168 q.text("status = ");
3169 q.text("%#x" % self.status)
3170 q.breakable()
3171 q.text('}')
3172
Rich Lane7dcdf022013-12-11 14:45:27 -08003173bsn_header.subtypes[26] = bsn_virtual_port_remove_reply
3174
3175class bsn_virtual_port_remove_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07003176 version = 3
3177 type = 4
3178 experimenter = 6035143
3179 subtype = 17
3180
3181 def __init__(self, xid=None, vport_no=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003182 if xid != None:
3183 self.xid = xid
3184 else:
3185 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07003186 if vport_no != None:
3187 self.vport_no = vport_no
3188 else:
3189 self.vport_no = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08003190 return
Dan Talaycof6202252013-07-02 01:00:29 -07003191
3192 def pack(self):
3193 packed = []
3194 packed.append(struct.pack("!B", self.version))
3195 packed.append(struct.pack("!B", self.type))
3196 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3197 packed.append(struct.pack("!L", self.xid))
3198 packed.append(struct.pack("!L", self.experimenter))
3199 packed.append(struct.pack("!L", self.subtype))
3200 packed.append(struct.pack("!L", self.vport_no))
3201 length = sum([len(x) for x in packed])
3202 packed[2] = struct.pack("!H", length)
3203 return ''.join(packed)
3204
3205 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003206 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07003207 obj = bsn_virtual_port_remove_request()
Dan Talaycof6202252013-07-02 01:00:29 -07003208 _version = reader.read("!B")[0]
3209 assert(_version == 3)
3210 _type = reader.read("!B")[0]
3211 assert(_type == 4)
3212 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003213 orig_reader = reader
3214 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003215 obj.xid = reader.read("!L")[0]
3216 _experimenter = reader.read("!L")[0]
3217 assert(_experimenter == 6035143)
3218 _subtype = reader.read("!L")[0]
3219 assert(_subtype == 17)
3220 obj.vport_no = reader.read("!L")[0]
3221 return obj
3222
3223 def __eq__(self, other):
3224 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07003225 if self.xid != other.xid: return False
3226 if self.vport_no != other.vport_no: return False
3227 return True
3228
Dan Talaycof6202252013-07-02 01:00:29 -07003229 def pretty_print(self, q):
3230 q.text("bsn_virtual_port_remove_request {")
3231 with q.group():
3232 with q.indent(2):
3233 q.breakable()
3234 q.text("xid = ");
3235 if self.xid != None:
3236 q.text("%#x" % self.xid)
3237 else:
3238 q.text('None')
3239 q.text(","); q.breakable()
3240 q.text("vport_no = ");
3241 q.text("%#x" % self.vport_no)
3242 q.breakable()
3243 q.text('}')
3244
Rich Lane7dcdf022013-12-11 14:45:27 -08003245bsn_header.subtypes[17] = bsn_virtual_port_remove_request
3246
3247class desc_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07003248 version = 3
3249 type = 19
3250 stats_type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07003251
3252 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 -08003253 if xid != None:
3254 self.xid = xid
3255 else:
3256 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003257 if flags != None:
3258 self.flags = flags
3259 else:
3260 self.flags = 0
3261 if mfr_desc != None:
3262 self.mfr_desc = mfr_desc
3263 else:
3264 self.mfr_desc = ""
3265 if hw_desc != None:
3266 self.hw_desc = hw_desc
3267 else:
3268 self.hw_desc = ""
3269 if sw_desc != None:
3270 self.sw_desc = sw_desc
3271 else:
3272 self.sw_desc = ""
3273 if serial_num != None:
3274 self.serial_num = serial_num
3275 else:
3276 self.serial_num = ""
3277 if dp_desc != None:
3278 self.dp_desc = dp_desc
3279 else:
3280 self.dp_desc = ""
Rich Lane7dcdf022013-12-11 14:45:27 -08003281 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003282
3283 def pack(self):
3284 packed = []
3285 packed.append(struct.pack("!B", self.version))
3286 packed.append(struct.pack("!B", self.type))
3287 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3288 packed.append(struct.pack("!L", self.xid))
3289 packed.append(struct.pack("!H", self.stats_type))
3290 packed.append(struct.pack("!H", self.flags))
3291 packed.append('\x00' * 4)
3292 packed.append(struct.pack("!256s", self.mfr_desc))
3293 packed.append(struct.pack("!256s", self.hw_desc))
3294 packed.append(struct.pack("!256s", self.sw_desc))
3295 packed.append(struct.pack("!32s", self.serial_num))
3296 packed.append(struct.pack("!256s", self.dp_desc))
3297 length = sum([len(x) for x in packed])
3298 packed[2] = struct.pack("!H", length)
3299 return ''.join(packed)
3300
3301 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003302 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003303 obj = desc_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07003304 _version = reader.read("!B")[0]
3305 assert(_version == 3)
3306 _type = reader.read("!B")[0]
3307 assert(_type == 19)
3308 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003309 orig_reader = reader
3310 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003311 obj.xid = reader.read("!L")[0]
3312 _stats_type = reader.read("!H")[0]
3313 assert(_stats_type == 0)
3314 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003315 reader.skip(4)
3316 obj.mfr_desc = reader.read("!256s")[0].rstrip("\x00")
3317 obj.hw_desc = reader.read("!256s")[0].rstrip("\x00")
3318 obj.sw_desc = reader.read("!256s")[0].rstrip("\x00")
3319 obj.serial_num = reader.read("!32s")[0].rstrip("\x00")
3320 obj.dp_desc = reader.read("!256s")[0].rstrip("\x00")
3321 return obj
3322
3323 def __eq__(self, other):
3324 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003325 if self.xid != other.xid: return False
3326 if self.flags != other.flags: return False
3327 if self.mfr_desc != other.mfr_desc: return False
3328 if self.hw_desc != other.hw_desc: return False
3329 if self.sw_desc != other.sw_desc: return False
3330 if self.serial_num != other.serial_num: return False
3331 if self.dp_desc != other.dp_desc: return False
3332 return True
3333
Rich Lanec2ee4b82013-04-24 17:12:38 -07003334 def pretty_print(self, q):
3335 q.text("desc_stats_reply {")
3336 with q.group():
3337 with q.indent(2):
3338 q.breakable()
3339 q.text("xid = ");
3340 if self.xid != None:
3341 q.text("%#x" % self.xid)
3342 else:
3343 q.text('None')
3344 q.text(","); q.breakable()
3345 q.text("flags = ");
3346 q.text("%#x" % self.flags)
3347 q.text(","); q.breakable()
3348 q.text("mfr_desc = ");
3349 q.pp(self.mfr_desc)
3350 q.text(","); q.breakable()
3351 q.text("hw_desc = ");
3352 q.pp(self.hw_desc)
3353 q.text(","); q.breakable()
3354 q.text("sw_desc = ");
3355 q.pp(self.sw_desc)
3356 q.text(","); q.breakable()
3357 q.text("serial_num = ");
3358 q.pp(self.serial_num)
3359 q.text(","); q.breakable()
3360 q.text("dp_desc = ");
3361 q.pp(self.dp_desc)
3362 q.breakable()
3363 q.text('}')
3364
Rich Lane7dcdf022013-12-11 14:45:27 -08003365stats_reply.subtypes[0] = desc_stats_reply
3366
3367class desc_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07003368 version = 3
3369 type = 18
3370 stats_type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07003371
3372 def __init__(self, xid=None, flags=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003373 if xid != None:
3374 self.xid = xid
3375 else:
3376 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003377 if flags != None:
3378 self.flags = flags
3379 else:
3380 self.flags = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08003381 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003382
3383 def pack(self):
3384 packed = []
3385 packed.append(struct.pack("!B", self.version))
3386 packed.append(struct.pack("!B", self.type))
3387 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3388 packed.append(struct.pack("!L", self.xid))
3389 packed.append(struct.pack("!H", self.stats_type))
3390 packed.append(struct.pack("!H", self.flags))
3391 packed.append('\x00' * 4)
3392 length = sum([len(x) for x in packed])
3393 packed[2] = struct.pack("!H", length)
3394 return ''.join(packed)
3395
3396 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003397 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003398 obj = desc_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07003399 _version = reader.read("!B")[0]
3400 assert(_version == 3)
3401 _type = reader.read("!B")[0]
3402 assert(_type == 18)
3403 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003404 orig_reader = reader
3405 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003406 obj.xid = reader.read("!L")[0]
3407 _stats_type = reader.read("!H")[0]
3408 assert(_stats_type == 0)
3409 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003410 reader.skip(4)
3411 return obj
3412
3413 def __eq__(self, other):
3414 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003415 if self.xid != other.xid: return False
3416 if self.flags != other.flags: return False
3417 return True
3418
Rich Lanec2ee4b82013-04-24 17:12:38 -07003419 def pretty_print(self, q):
3420 q.text("desc_stats_request {")
3421 with q.group():
3422 with q.indent(2):
3423 q.breakable()
3424 q.text("xid = ");
3425 if self.xid != None:
3426 q.text("%#x" % self.xid)
3427 else:
3428 q.text('None')
3429 q.text(","); q.breakable()
3430 q.text("flags = ");
3431 q.text("%#x" % self.flags)
3432 q.breakable()
3433 q.text('}')
3434
Rich Lane7dcdf022013-12-11 14:45:27 -08003435stats_request.subtypes[0] = desc_stats_request
3436
3437class echo_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -07003438 version = 3
3439 type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07003440
3441 def __init__(self, xid=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003442 if xid != None:
3443 self.xid = xid
3444 else:
3445 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003446 if data != None:
3447 self.data = data
3448 else:
Dan Talaycof6202252013-07-02 01:00:29 -07003449 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08003450 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003451
3452 def pack(self):
3453 packed = []
3454 packed.append(struct.pack("!B", self.version))
3455 packed.append(struct.pack("!B", self.type))
3456 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3457 packed.append(struct.pack("!L", self.xid))
3458 packed.append(self.data)
3459 length = sum([len(x) for x in packed])
3460 packed[2] = struct.pack("!H", length)
3461 return ''.join(packed)
3462
3463 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003464 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003465 obj = echo_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07003466 _version = reader.read("!B")[0]
3467 assert(_version == 3)
3468 _type = reader.read("!B")[0]
3469 assert(_type == 3)
3470 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003471 orig_reader = reader
3472 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003473 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003474 obj.data = str(reader.read_all())
3475 return obj
3476
3477 def __eq__(self, other):
3478 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003479 if self.xid != other.xid: return False
3480 if self.data != other.data: return False
3481 return True
3482
Rich Lanec2ee4b82013-04-24 17:12:38 -07003483 def pretty_print(self, q):
3484 q.text("echo_reply {")
3485 with q.group():
3486 with q.indent(2):
3487 q.breakable()
3488 q.text("xid = ");
3489 if self.xid != None:
3490 q.text("%#x" % self.xid)
3491 else:
3492 q.text('None')
3493 q.text(","); q.breakable()
3494 q.text("data = ");
3495 q.pp(self.data)
3496 q.breakable()
3497 q.text('}')
3498
Rich Lane7dcdf022013-12-11 14:45:27 -08003499message.subtypes[3] = echo_reply
3500
3501class echo_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -07003502 version = 3
3503 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07003504
3505 def __init__(self, xid=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003506 if xid != None:
3507 self.xid = xid
3508 else:
3509 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003510 if data != None:
3511 self.data = data
3512 else:
Dan Talaycof6202252013-07-02 01:00:29 -07003513 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08003514 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003515
3516 def pack(self):
3517 packed = []
3518 packed.append(struct.pack("!B", self.version))
3519 packed.append(struct.pack("!B", self.type))
3520 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3521 packed.append(struct.pack("!L", self.xid))
3522 packed.append(self.data)
3523 length = sum([len(x) for x in packed])
3524 packed[2] = struct.pack("!H", length)
3525 return ''.join(packed)
3526
3527 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003528 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003529 obj = echo_request()
Dan Talaycof6202252013-07-02 01:00:29 -07003530 _version = reader.read("!B")[0]
3531 assert(_version == 3)
3532 _type = reader.read("!B")[0]
3533 assert(_type == 2)
3534 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003535 orig_reader = reader
3536 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003537 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003538 obj.data = str(reader.read_all())
3539 return obj
3540
3541 def __eq__(self, other):
3542 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003543 if self.xid != other.xid: return False
3544 if self.data != other.data: return False
3545 return True
3546
Rich Lanec2ee4b82013-04-24 17:12:38 -07003547 def pretty_print(self, q):
3548 q.text("echo_request {")
3549 with q.group():
3550 with q.indent(2):
3551 q.breakable()
3552 q.text("xid = ");
3553 if self.xid != None:
3554 q.text("%#x" % self.xid)
3555 else:
3556 q.text('None')
3557 q.text(","); q.breakable()
3558 q.text("data = ");
3559 q.pp(self.data)
3560 q.breakable()
3561 q.text('}')
3562
Rich Lane7dcdf022013-12-11 14:45:27 -08003563message.subtypes[2] = echo_request
3564
3565class experimenter_error_msg(error_msg):
Dan Talaycof6202252013-07-02 01:00:29 -07003566 version = 3
3567 type = 1
Rich Lane6f4978c2013-10-20 21:33:52 -07003568 err_type = 65535
Rich Lanec2ee4b82013-04-24 17:12:38 -07003569
Rich Lane6f4978c2013-10-20 21:33:52 -07003570 def __init__(self, xid=None, subtype=None, experimenter=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003571 if xid != None:
3572 self.xid = xid
3573 else:
3574 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07003575 if subtype != None:
3576 self.subtype = subtype
Rich Lanec2ee4b82013-04-24 17:12:38 -07003577 else:
Rich Lane6f4978c2013-10-20 21:33:52 -07003578 self.subtype = 0
3579 if experimenter != None:
3580 self.experimenter = experimenter
Rich Lanec2ee4b82013-04-24 17:12:38 -07003581 else:
Rich Lane6f4978c2013-10-20 21:33:52 -07003582 self.experimenter = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07003583 if data != None:
3584 self.data = data
3585 else:
Dan Talaycof6202252013-07-02 01:00:29 -07003586 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08003587 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003588
3589 def pack(self):
3590 packed = []
3591 packed.append(struct.pack("!B", self.version))
3592 packed.append(struct.pack("!B", self.type))
3593 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3594 packed.append(struct.pack("!L", self.xid))
3595 packed.append(struct.pack("!H", self.err_type))
Rich Lane6f4978c2013-10-20 21:33:52 -07003596 packed.append(struct.pack("!H", self.subtype))
3597 packed.append(struct.pack("!L", self.experimenter))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003598 packed.append(self.data)
3599 length = sum([len(x) for x in packed])
3600 packed[2] = struct.pack("!H", length)
3601 return ''.join(packed)
3602
3603 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003604 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07003605 obj = experimenter_error_msg()
Dan Talaycof6202252013-07-02 01:00:29 -07003606 _version = reader.read("!B")[0]
3607 assert(_version == 3)
3608 _type = reader.read("!B")[0]
3609 assert(_type == 1)
3610 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003611 orig_reader = reader
3612 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003613 obj.xid = reader.read("!L")[0]
Rich Lane6f4978c2013-10-20 21:33:52 -07003614 _err_type = reader.read("!H")[0]
3615 assert(_err_type == 65535)
3616 obj.subtype = reader.read("!H")[0]
3617 obj.experimenter = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003618 obj.data = str(reader.read_all())
3619 return obj
3620
3621 def __eq__(self, other):
3622 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003623 if self.xid != other.xid: return False
Rich Lane6f4978c2013-10-20 21:33:52 -07003624 if self.subtype != other.subtype: return False
3625 if self.experimenter != other.experimenter: return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003626 if self.data != other.data: return False
3627 return True
3628
Rich Lanec2ee4b82013-04-24 17:12:38 -07003629 def pretty_print(self, q):
Rich Lane6f4978c2013-10-20 21:33:52 -07003630 q.text("experimenter_error_msg {")
Rich Lanec2ee4b82013-04-24 17:12:38 -07003631 with q.group():
3632 with q.indent(2):
3633 q.breakable()
3634 q.text("xid = ");
3635 if self.xid != None:
3636 q.text("%#x" % self.xid)
3637 else:
3638 q.text('None')
3639 q.text(","); q.breakable()
Rich Lane6f4978c2013-10-20 21:33:52 -07003640 q.text("subtype = ");
3641 q.text("%#x" % self.subtype)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003642 q.text(","); q.breakable()
Rich Lane6f4978c2013-10-20 21:33:52 -07003643 q.text("experimenter = ");
3644 q.text("%#x" % self.experimenter)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003645 q.text(","); q.breakable()
3646 q.text("data = ");
3647 q.pp(self.data)
3648 q.breakable()
3649 q.text('}')
3650
Rich Lane7dcdf022013-12-11 14:45:27 -08003651error_msg.subtypes[65535] = experimenter_error_msg
3652
3653class features_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -07003654 version = 3
3655 type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07003656
3657 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 -08003658 if xid != None:
3659 self.xid = xid
3660 else:
3661 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003662 if datapath_id != None:
3663 self.datapath_id = datapath_id
3664 else:
3665 self.datapath_id = 0
3666 if n_buffers != None:
3667 self.n_buffers = n_buffers
3668 else:
3669 self.n_buffers = 0
3670 if n_tables != None:
3671 self.n_tables = n_tables
3672 else:
3673 self.n_tables = 0
3674 if capabilities != None:
3675 self.capabilities = capabilities
3676 else:
3677 self.capabilities = 0
3678 if reserved != None:
3679 self.reserved = reserved
3680 else:
3681 self.reserved = 0
3682 if ports != None:
3683 self.ports = ports
3684 else:
3685 self.ports = []
Rich Lane7dcdf022013-12-11 14:45:27 -08003686 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003687
3688 def pack(self):
3689 packed = []
3690 packed.append(struct.pack("!B", self.version))
3691 packed.append(struct.pack("!B", self.type))
3692 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3693 packed.append(struct.pack("!L", self.xid))
3694 packed.append(struct.pack("!Q", self.datapath_id))
3695 packed.append(struct.pack("!L", self.n_buffers))
3696 packed.append(struct.pack("!B", self.n_tables))
3697 packed.append('\x00' * 3)
3698 packed.append(struct.pack("!L", self.capabilities))
3699 packed.append(struct.pack("!L", self.reserved))
Rich Lane7dcdf022013-12-11 14:45:27 -08003700 packed.append(loxi.generic_util.pack_list(self.ports))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003701 length = sum([len(x) for x in packed])
3702 packed[2] = struct.pack("!H", length)
3703 return ''.join(packed)
3704
3705 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003706 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003707 obj = features_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07003708 _version = reader.read("!B")[0]
3709 assert(_version == 3)
3710 _type = reader.read("!B")[0]
3711 assert(_type == 6)
3712 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003713 orig_reader = reader
3714 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003715 obj.xid = reader.read("!L")[0]
3716 obj.datapath_id = reader.read("!Q")[0]
3717 obj.n_buffers = reader.read("!L")[0]
3718 obj.n_tables = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003719 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07003720 obj.capabilities = reader.read("!L")[0]
3721 obj.reserved = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003722 obj.ports = loxi.generic_util.unpack_list(reader, common.port_desc.unpack)
3723 return obj
3724
3725 def __eq__(self, other):
3726 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003727 if self.xid != other.xid: return False
3728 if self.datapath_id != other.datapath_id: return False
3729 if self.n_buffers != other.n_buffers: return False
3730 if self.n_tables != other.n_tables: return False
3731 if self.capabilities != other.capabilities: return False
3732 if self.reserved != other.reserved: return False
3733 if self.ports != other.ports: return False
3734 return True
3735
Rich Lanec2ee4b82013-04-24 17:12:38 -07003736 def pretty_print(self, q):
3737 q.text("features_reply {")
3738 with q.group():
3739 with q.indent(2):
3740 q.breakable()
3741 q.text("xid = ");
3742 if self.xid != None:
3743 q.text("%#x" % self.xid)
3744 else:
3745 q.text('None')
3746 q.text(","); q.breakable()
3747 q.text("datapath_id = ");
3748 q.text("%#x" % self.datapath_id)
3749 q.text(","); q.breakable()
3750 q.text("n_buffers = ");
3751 q.text("%#x" % self.n_buffers)
3752 q.text(","); q.breakable()
3753 q.text("n_tables = ");
3754 q.text("%#x" % self.n_tables)
3755 q.text(","); q.breakable()
3756 q.text("capabilities = ");
3757 q.text("%#x" % self.capabilities)
3758 q.text(","); q.breakable()
3759 q.text("reserved = ");
3760 q.text("%#x" % self.reserved)
3761 q.text(","); q.breakable()
3762 q.text("ports = ");
3763 q.pp(self.ports)
3764 q.breakable()
3765 q.text('}')
3766
Rich Lane7dcdf022013-12-11 14:45:27 -08003767message.subtypes[6] = features_reply
3768
3769class features_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -07003770 version = 3
3771 type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07003772
3773 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003774 if xid != None:
3775 self.xid = xid
3776 else:
3777 self.xid = None
3778 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003779
3780 def pack(self):
3781 packed = []
3782 packed.append(struct.pack("!B", self.version))
3783 packed.append(struct.pack("!B", self.type))
3784 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3785 packed.append(struct.pack("!L", self.xid))
3786 length = sum([len(x) for x in packed])
3787 packed[2] = struct.pack("!H", length)
3788 return ''.join(packed)
3789
3790 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003791 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003792 obj = features_request()
Dan Talaycof6202252013-07-02 01:00:29 -07003793 _version = reader.read("!B")[0]
3794 assert(_version == 3)
3795 _type = reader.read("!B")[0]
3796 assert(_type == 5)
3797 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003798 orig_reader = reader
3799 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003800 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003801 return obj
3802
3803 def __eq__(self, other):
3804 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003805 if self.xid != other.xid: return False
3806 return True
3807
Rich Lanec2ee4b82013-04-24 17:12:38 -07003808 def pretty_print(self, q):
3809 q.text("features_request {")
3810 with q.group():
3811 with q.indent(2):
3812 q.breakable()
3813 q.text("xid = ");
3814 if self.xid != None:
3815 q.text("%#x" % self.xid)
3816 else:
3817 q.text('None')
3818 q.breakable()
3819 q.text('}')
3820
Rich Lane7dcdf022013-12-11 14:45:27 -08003821message.subtypes[5] = features_request
3822
3823class flow_mod(message):
3824 subtypes = {}
3825
Rich Lane95f7fc92014-01-27 17:08:16 -08003826 version = 3
3827 type = 14
3828
3829 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):
3830 if xid != None:
3831 self.xid = xid
3832 else:
3833 self.xid = None
3834 if cookie != None:
3835 self.cookie = cookie
3836 else:
3837 self.cookie = 0
3838 if cookie_mask != None:
3839 self.cookie_mask = cookie_mask
3840 else:
3841 self.cookie_mask = 0
3842 if table_id != None:
3843 self.table_id = table_id
3844 else:
3845 self.table_id = 0
3846 if _command != None:
3847 self._command = _command
3848 else:
3849 self._command = 0
3850 if idle_timeout != None:
3851 self.idle_timeout = idle_timeout
3852 else:
3853 self.idle_timeout = 0
3854 if hard_timeout != None:
3855 self.hard_timeout = hard_timeout
3856 else:
3857 self.hard_timeout = 0
3858 if priority != None:
3859 self.priority = priority
3860 else:
3861 self.priority = 0
3862 if buffer_id != None:
3863 self.buffer_id = buffer_id
3864 else:
3865 self.buffer_id = 0
3866 if out_port != None:
3867 self.out_port = out_port
3868 else:
3869 self.out_port = 0
3870 if out_group != None:
3871 self.out_group = out_group
3872 else:
3873 self.out_group = 0
3874 if flags != None:
3875 self.flags = flags
3876 else:
3877 self.flags = 0
3878 if match != None:
3879 self.match = match
3880 else:
3881 self.match = common.match()
3882 if instructions != None:
3883 self.instructions = instructions
3884 else:
3885 self.instructions = []
3886 return
3887
3888 def pack(self):
3889 packed = []
3890 packed.append(struct.pack("!B", self.version))
3891 packed.append(struct.pack("!B", self.type))
3892 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3893 packed.append(struct.pack("!L", self.xid))
3894 packed.append(struct.pack("!Q", self.cookie))
3895 packed.append(struct.pack("!Q", self.cookie_mask))
3896 packed.append(struct.pack("!B", self.table_id))
3897 packed.append(util.pack_fm_cmd(self._command))
3898 packed.append(struct.pack("!H", self.idle_timeout))
3899 packed.append(struct.pack("!H", self.hard_timeout))
3900 packed.append(struct.pack("!H", self.priority))
3901 packed.append(struct.pack("!L", self.buffer_id))
3902 packed.append(util.pack_port_no(self.out_port))
3903 packed.append(struct.pack("!L", self.out_group))
3904 packed.append(struct.pack("!H", self.flags))
3905 packed.append('\x00' * 2)
3906 packed.append(self.match.pack())
3907 packed.append(loxi.generic_util.pack_list(self.instructions))
3908 length = sum([len(x) for x in packed])
3909 packed[2] = struct.pack("!H", length)
3910 return ''.join(packed)
3911
Rich Lane7dcdf022013-12-11 14:45:27 -08003912 @staticmethod
3913 def unpack(reader):
3914 subtype, = reader.peek('B', 25)
Rich Lane95f7fc92014-01-27 17:08:16 -08003915 subclass = flow_mod.subtypes.get(subtype)
3916 if subclass:
3917 return subclass.unpack(reader)
3918
3919 obj = flow_mod()
3920 _version = reader.read("!B")[0]
3921 assert(_version == 3)
3922 _type = reader.read("!B")[0]
3923 assert(_type == 14)
3924 _length = reader.read("!H")[0]
3925 orig_reader = reader
3926 reader = orig_reader.slice(_length - (2 + 2))
3927 obj.xid = reader.read("!L")[0]
3928 obj.cookie = reader.read("!Q")[0]
3929 obj.cookie_mask = reader.read("!Q")[0]
3930 obj.table_id = reader.read("!B")[0]
3931 obj._command = util.unpack_fm_cmd(reader)
3932 obj.idle_timeout = reader.read("!H")[0]
3933 obj.hard_timeout = reader.read("!H")[0]
3934 obj.priority = reader.read("!H")[0]
3935 obj.buffer_id = reader.read("!L")[0]
3936 obj.out_port = util.unpack_port_no(reader)
3937 obj.out_group = reader.read("!L")[0]
3938 obj.flags = reader.read("!H")[0]
3939 reader.skip(2)
3940 obj.match = common.match.unpack(reader)
3941 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
3942 return obj
3943
3944 def __eq__(self, other):
3945 if type(self) != type(other): return False
3946 if self.xid != other.xid: return False
3947 if self.cookie != other.cookie: return False
3948 if self.cookie_mask != other.cookie_mask: return False
3949 if self.table_id != other.table_id: return False
3950 if self._command != other._command: return False
3951 if self.idle_timeout != other.idle_timeout: return False
3952 if self.hard_timeout != other.hard_timeout: return False
3953 if self.priority != other.priority: return False
3954 if self.buffer_id != other.buffer_id: return False
3955 if self.out_port != other.out_port: return False
3956 if self.out_group != other.out_group: return False
3957 if self.flags != other.flags: return False
3958 if self.match != other.match: return False
3959 if self.instructions != other.instructions: return False
3960 return True
3961
3962 def pretty_print(self, q):
3963 q.text("flow_mod {")
3964 with q.group():
3965 with q.indent(2):
3966 q.breakable()
3967 q.text("xid = ");
3968 if self.xid != None:
3969 q.text("%#x" % self.xid)
3970 else:
3971 q.text('None')
3972 q.text(","); q.breakable()
3973 q.text("cookie = ");
3974 q.text("%#x" % self.cookie)
3975 q.text(","); q.breakable()
3976 q.text("cookie_mask = ");
3977 q.text("%#x" % self.cookie_mask)
3978 q.text(","); q.breakable()
3979 q.text("table_id = ");
3980 q.text("%#x" % self.table_id)
3981 q.text(","); q.breakable()
3982 q.text("idle_timeout = ");
3983 q.text("%#x" % self.idle_timeout)
3984 q.text(","); q.breakable()
3985 q.text("hard_timeout = ");
3986 q.text("%#x" % self.hard_timeout)
3987 q.text(","); q.breakable()
3988 q.text("priority = ");
3989 q.text("%#x" % self.priority)
3990 q.text(","); q.breakable()
3991 q.text("buffer_id = ");
3992 q.text("%#x" % self.buffer_id)
3993 q.text(","); q.breakable()
3994 q.text("out_port = ");
3995 q.text(util.pretty_port(self.out_port))
3996 q.text(","); q.breakable()
3997 q.text("out_group = ");
3998 q.text("%#x" % self.out_group)
3999 q.text(","); q.breakable()
4000 q.text("flags = ");
4001 q.text("%#x" % self.flags)
4002 q.text(","); q.breakable()
4003 q.text("match = ");
4004 q.pp(self.match)
4005 q.text(","); q.breakable()
4006 q.text("instructions = ");
4007 q.pp(self.instructions)
4008 q.breakable()
4009 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08004010
4011message.subtypes[14] = flow_mod
4012
4013class flow_add(flow_mod):
Dan Talaycof6202252013-07-02 01:00:29 -07004014 version = 3
4015 type = 14
4016 _command = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07004017
4018 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 -08004019 if xid != None:
4020 self.xid = xid
4021 else:
4022 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004023 if cookie != None:
4024 self.cookie = cookie
4025 else:
4026 self.cookie = 0
4027 if cookie_mask != None:
4028 self.cookie_mask = cookie_mask
4029 else:
4030 self.cookie_mask = 0
4031 if table_id != None:
4032 self.table_id = table_id
4033 else:
4034 self.table_id = 0
4035 if idle_timeout != None:
4036 self.idle_timeout = idle_timeout
4037 else:
4038 self.idle_timeout = 0
4039 if hard_timeout != None:
4040 self.hard_timeout = hard_timeout
4041 else:
4042 self.hard_timeout = 0
4043 if priority != None:
4044 self.priority = priority
4045 else:
4046 self.priority = 0
4047 if buffer_id != None:
4048 self.buffer_id = buffer_id
4049 else:
4050 self.buffer_id = 0
4051 if out_port != None:
4052 self.out_port = out_port
4053 else:
4054 self.out_port = 0
4055 if out_group != None:
4056 self.out_group = out_group
4057 else:
4058 self.out_group = 0
4059 if flags != None:
4060 self.flags = flags
4061 else:
4062 self.flags = 0
4063 if match != None:
4064 self.match = match
4065 else:
4066 self.match = common.match()
4067 if instructions != None:
4068 self.instructions = instructions
4069 else:
4070 self.instructions = []
Rich Lane7dcdf022013-12-11 14:45:27 -08004071 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004072
4073 def pack(self):
4074 packed = []
4075 packed.append(struct.pack("!B", self.version))
4076 packed.append(struct.pack("!B", self.type))
4077 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4078 packed.append(struct.pack("!L", self.xid))
4079 packed.append(struct.pack("!Q", self.cookie))
4080 packed.append(struct.pack("!Q", self.cookie_mask))
4081 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004082 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004083 packed.append(struct.pack("!H", self.idle_timeout))
4084 packed.append(struct.pack("!H", self.hard_timeout))
4085 packed.append(struct.pack("!H", self.priority))
4086 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004087 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004088 packed.append(struct.pack("!L", self.out_group))
4089 packed.append(struct.pack("!H", self.flags))
4090 packed.append('\x00' * 2)
4091 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08004092 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004093 length = sum([len(x) for x in packed])
4094 packed[2] = struct.pack("!H", length)
4095 return ''.join(packed)
4096
4097 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004098 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004099 obj = flow_add()
Dan Talaycof6202252013-07-02 01:00:29 -07004100 _version = reader.read("!B")[0]
4101 assert(_version == 3)
4102 _type = reader.read("!B")[0]
4103 assert(_type == 14)
4104 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004105 orig_reader = reader
4106 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07004107 obj.xid = reader.read("!L")[0]
4108 obj.cookie = reader.read("!Q")[0]
4109 obj.cookie_mask = reader.read("!Q")[0]
4110 obj.table_id = reader.read("!B")[0]
4111 __command = util.unpack_fm_cmd(reader)
4112 assert(__command == 0)
4113 obj.idle_timeout = reader.read("!H")[0]
4114 obj.hard_timeout = reader.read("!H")[0]
4115 obj.priority = reader.read("!H")[0]
4116 obj.buffer_id = reader.read("!L")[0]
4117 obj.out_port = util.unpack_port_no(reader)
4118 obj.out_group = reader.read("!L")[0]
4119 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004120 reader.skip(2)
4121 obj.match = common.match.unpack(reader)
Rich Lane7dcdf022013-12-11 14:45:27 -08004122 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07004123 return obj
4124
4125 def __eq__(self, other):
4126 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004127 if self.xid != other.xid: return False
4128 if self.cookie != other.cookie: return False
4129 if self.cookie_mask != other.cookie_mask: return False
4130 if self.table_id != other.table_id: return False
4131 if self.idle_timeout != other.idle_timeout: return False
4132 if self.hard_timeout != other.hard_timeout: return False
4133 if self.priority != other.priority: return False
4134 if self.buffer_id != other.buffer_id: return False
4135 if self.out_port != other.out_port: return False
4136 if self.out_group != other.out_group: return False
4137 if self.flags != other.flags: return False
4138 if self.match != other.match: return False
4139 if self.instructions != other.instructions: return False
4140 return True
4141
Rich Lanec2ee4b82013-04-24 17:12:38 -07004142 def pretty_print(self, q):
4143 q.text("flow_add {")
4144 with q.group():
4145 with q.indent(2):
4146 q.breakable()
4147 q.text("xid = ");
4148 if self.xid != None:
4149 q.text("%#x" % self.xid)
4150 else:
4151 q.text('None')
4152 q.text(","); q.breakable()
4153 q.text("cookie = ");
4154 q.text("%#x" % self.cookie)
4155 q.text(","); q.breakable()
4156 q.text("cookie_mask = ");
4157 q.text("%#x" % self.cookie_mask)
4158 q.text(","); q.breakable()
4159 q.text("table_id = ");
4160 q.text("%#x" % self.table_id)
4161 q.text(","); q.breakable()
4162 q.text("idle_timeout = ");
4163 q.text("%#x" % self.idle_timeout)
4164 q.text(","); q.breakable()
4165 q.text("hard_timeout = ");
4166 q.text("%#x" % self.hard_timeout)
4167 q.text(","); q.breakable()
4168 q.text("priority = ");
4169 q.text("%#x" % self.priority)
4170 q.text(","); q.breakable()
4171 q.text("buffer_id = ");
4172 q.text("%#x" % self.buffer_id)
4173 q.text(","); q.breakable()
4174 q.text("out_port = ");
4175 q.text(util.pretty_port(self.out_port))
4176 q.text(","); q.breakable()
4177 q.text("out_group = ");
4178 q.text("%#x" % self.out_group)
4179 q.text(","); q.breakable()
4180 q.text("flags = ");
4181 q.text("%#x" % self.flags)
4182 q.text(","); q.breakable()
4183 q.text("match = ");
4184 q.pp(self.match)
4185 q.text(","); q.breakable()
4186 q.text("instructions = ");
4187 q.pp(self.instructions)
4188 q.breakable()
4189 q.text('}')
4190
Rich Lane7dcdf022013-12-11 14:45:27 -08004191flow_mod.subtypes[0] = flow_add
4192
4193class flow_delete(flow_mod):
Dan Talaycof6202252013-07-02 01:00:29 -07004194 version = 3
4195 type = 14
4196 _command = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07004197
4198 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 -08004199 if xid != None:
4200 self.xid = xid
4201 else:
4202 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004203 if cookie != None:
4204 self.cookie = cookie
4205 else:
4206 self.cookie = 0
4207 if cookie_mask != None:
4208 self.cookie_mask = cookie_mask
4209 else:
4210 self.cookie_mask = 0
4211 if table_id != None:
4212 self.table_id = table_id
4213 else:
4214 self.table_id = 0
4215 if idle_timeout != None:
4216 self.idle_timeout = idle_timeout
4217 else:
4218 self.idle_timeout = 0
4219 if hard_timeout != None:
4220 self.hard_timeout = hard_timeout
4221 else:
4222 self.hard_timeout = 0
4223 if priority != None:
4224 self.priority = priority
4225 else:
4226 self.priority = 0
4227 if buffer_id != None:
4228 self.buffer_id = buffer_id
4229 else:
4230 self.buffer_id = 0
4231 if out_port != None:
4232 self.out_port = out_port
4233 else:
4234 self.out_port = 0
4235 if out_group != None:
4236 self.out_group = out_group
4237 else:
4238 self.out_group = 0
4239 if flags != None:
4240 self.flags = flags
4241 else:
4242 self.flags = 0
4243 if match != None:
4244 self.match = match
4245 else:
4246 self.match = common.match()
4247 if instructions != None:
4248 self.instructions = instructions
4249 else:
4250 self.instructions = []
Rich Lane7dcdf022013-12-11 14:45:27 -08004251 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004252
4253 def pack(self):
4254 packed = []
4255 packed.append(struct.pack("!B", self.version))
4256 packed.append(struct.pack("!B", self.type))
4257 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4258 packed.append(struct.pack("!L", self.xid))
4259 packed.append(struct.pack("!Q", self.cookie))
4260 packed.append(struct.pack("!Q", self.cookie_mask))
4261 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004262 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004263 packed.append(struct.pack("!H", self.idle_timeout))
4264 packed.append(struct.pack("!H", self.hard_timeout))
4265 packed.append(struct.pack("!H", self.priority))
4266 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004267 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004268 packed.append(struct.pack("!L", self.out_group))
4269 packed.append(struct.pack("!H", self.flags))
4270 packed.append('\x00' * 2)
4271 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08004272 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004273 length = sum([len(x) for x in packed])
4274 packed[2] = struct.pack("!H", length)
4275 return ''.join(packed)
4276
4277 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004278 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004279 obj = flow_delete()
Dan Talaycof6202252013-07-02 01:00:29 -07004280 _version = reader.read("!B")[0]
4281 assert(_version == 3)
4282 _type = reader.read("!B")[0]
4283 assert(_type == 14)
4284 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004285 orig_reader = reader
4286 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07004287 obj.xid = reader.read("!L")[0]
4288 obj.cookie = reader.read("!Q")[0]
4289 obj.cookie_mask = reader.read("!Q")[0]
4290 obj.table_id = reader.read("!B")[0]
4291 __command = util.unpack_fm_cmd(reader)
4292 assert(__command == 3)
4293 obj.idle_timeout = reader.read("!H")[0]
4294 obj.hard_timeout = reader.read("!H")[0]
4295 obj.priority = reader.read("!H")[0]
4296 obj.buffer_id = reader.read("!L")[0]
4297 obj.out_port = util.unpack_port_no(reader)
4298 obj.out_group = reader.read("!L")[0]
4299 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004300 reader.skip(2)
4301 obj.match = common.match.unpack(reader)
Rich Lane7dcdf022013-12-11 14:45:27 -08004302 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07004303 return obj
4304
4305 def __eq__(self, other):
4306 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004307 if self.xid != other.xid: return False
4308 if self.cookie != other.cookie: return False
4309 if self.cookie_mask != other.cookie_mask: return False
4310 if self.table_id != other.table_id: return False
4311 if self.idle_timeout != other.idle_timeout: return False
4312 if self.hard_timeout != other.hard_timeout: return False
4313 if self.priority != other.priority: return False
4314 if self.buffer_id != other.buffer_id: return False
4315 if self.out_port != other.out_port: return False
4316 if self.out_group != other.out_group: return False
4317 if self.flags != other.flags: return False
4318 if self.match != other.match: return False
4319 if self.instructions != other.instructions: return False
4320 return True
4321
Rich Lanec2ee4b82013-04-24 17:12:38 -07004322 def pretty_print(self, q):
4323 q.text("flow_delete {")
4324 with q.group():
4325 with q.indent(2):
4326 q.breakable()
4327 q.text("xid = ");
4328 if self.xid != None:
4329 q.text("%#x" % self.xid)
4330 else:
4331 q.text('None')
4332 q.text(","); q.breakable()
4333 q.text("cookie = ");
4334 q.text("%#x" % self.cookie)
4335 q.text(","); q.breakable()
4336 q.text("cookie_mask = ");
4337 q.text("%#x" % self.cookie_mask)
4338 q.text(","); q.breakable()
4339 q.text("table_id = ");
4340 q.text("%#x" % self.table_id)
4341 q.text(","); q.breakable()
4342 q.text("idle_timeout = ");
4343 q.text("%#x" % self.idle_timeout)
4344 q.text(","); q.breakable()
4345 q.text("hard_timeout = ");
4346 q.text("%#x" % self.hard_timeout)
4347 q.text(","); q.breakable()
4348 q.text("priority = ");
4349 q.text("%#x" % self.priority)
4350 q.text(","); q.breakable()
4351 q.text("buffer_id = ");
4352 q.text("%#x" % self.buffer_id)
4353 q.text(","); q.breakable()
4354 q.text("out_port = ");
4355 q.text(util.pretty_port(self.out_port))
4356 q.text(","); q.breakable()
4357 q.text("out_group = ");
4358 q.text("%#x" % self.out_group)
4359 q.text(","); q.breakable()
4360 q.text("flags = ");
4361 q.text("%#x" % self.flags)
4362 q.text(","); q.breakable()
4363 q.text("match = ");
4364 q.pp(self.match)
4365 q.text(","); q.breakable()
4366 q.text("instructions = ");
4367 q.pp(self.instructions)
4368 q.breakable()
4369 q.text('}')
4370
Rich Lane7dcdf022013-12-11 14:45:27 -08004371flow_mod.subtypes[3] = flow_delete
4372
4373class flow_delete_strict(flow_mod):
Dan Talaycof6202252013-07-02 01:00:29 -07004374 version = 3
4375 type = 14
4376 _command = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07004377
4378 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 -08004379 if xid != None:
4380 self.xid = xid
4381 else:
4382 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004383 if cookie != None:
4384 self.cookie = cookie
4385 else:
4386 self.cookie = 0
4387 if cookie_mask != None:
4388 self.cookie_mask = cookie_mask
4389 else:
4390 self.cookie_mask = 0
4391 if table_id != None:
4392 self.table_id = table_id
4393 else:
4394 self.table_id = 0
4395 if idle_timeout != None:
4396 self.idle_timeout = idle_timeout
4397 else:
4398 self.idle_timeout = 0
4399 if hard_timeout != None:
4400 self.hard_timeout = hard_timeout
4401 else:
4402 self.hard_timeout = 0
4403 if priority != None:
4404 self.priority = priority
4405 else:
4406 self.priority = 0
4407 if buffer_id != None:
4408 self.buffer_id = buffer_id
4409 else:
4410 self.buffer_id = 0
4411 if out_port != None:
4412 self.out_port = out_port
4413 else:
4414 self.out_port = 0
4415 if out_group != None:
4416 self.out_group = out_group
4417 else:
4418 self.out_group = 0
4419 if flags != None:
4420 self.flags = flags
4421 else:
4422 self.flags = 0
4423 if match != None:
4424 self.match = match
4425 else:
4426 self.match = common.match()
4427 if instructions != None:
4428 self.instructions = instructions
4429 else:
4430 self.instructions = []
Rich Lane7dcdf022013-12-11 14:45:27 -08004431 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004432
4433 def pack(self):
4434 packed = []
4435 packed.append(struct.pack("!B", self.version))
4436 packed.append(struct.pack("!B", self.type))
4437 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4438 packed.append(struct.pack("!L", self.xid))
4439 packed.append(struct.pack("!Q", self.cookie))
4440 packed.append(struct.pack("!Q", self.cookie_mask))
4441 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004442 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004443 packed.append(struct.pack("!H", self.idle_timeout))
4444 packed.append(struct.pack("!H", self.hard_timeout))
4445 packed.append(struct.pack("!H", self.priority))
4446 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004447 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004448 packed.append(struct.pack("!L", self.out_group))
4449 packed.append(struct.pack("!H", self.flags))
4450 packed.append('\x00' * 2)
4451 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08004452 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004453 length = sum([len(x) for x in packed])
4454 packed[2] = struct.pack("!H", length)
4455 return ''.join(packed)
4456
4457 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004458 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004459 obj = flow_delete_strict()
Dan Talaycof6202252013-07-02 01:00:29 -07004460 _version = reader.read("!B")[0]
4461 assert(_version == 3)
4462 _type = reader.read("!B")[0]
4463 assert(_type == 14)
4464 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004465 orig_reader = reader
4466 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07004467 obj.xid = reader.read("!L")[0]
4468 obj.cookie = reader.read("!Q")[0]
4469 obj.cookie_mask = reader.read("!Q")[0]
4470 obj.table_id = reader.read("!B")[0]
4471 __command = util.unpack_fm_cmd(reader)
4472 assert(__command == 4)
4473 obj.idle_timeout = reader.read("!H")[0]
4474 obj.hard_timeout = reader.read("!H")[0]
4475 obj.priority = reader.read("!H")[0]
4476 obj.buffer_id = reader.read("!L")[0]
4477 obj.out_port = util.unpack_port_no(reader)
4478 obj.out_group = reader.read("!L")[0]
4479 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004480 reader.skip(2)
4481 obj.match = common.match.unpack(reader)
Rich Lane7dcdf022013-12-11 14:45:27 -08004482 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07004483 return obj
4484
4485 def __eq__(self, other):
4486 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004487 if self.xid != other.xid: return False
4488 if self.cookie != other.cookie: return False
4489 if self.cookie_mask != other.cookie_mask: return False
4490 if self.table_id != other.table_id: return False
4491 if self.idle_timeout != other.idle_timeout: return False
4492 if self.hard_timeout != other.hard_timeout: return False
4493 if self.priority != other.priority: return False
4494 if self.buffer_id != other.buffer_id: return False
4495 if self.out_port != other.out_port: return False
4496 if self.out_group != other.out_group: return False
4497 if self.flags != other.flags: return False
4498 if self.match != other.match: return False
4499 if self.instructions != other.instructions: return False
4500 return True
4501
Rich Lanec2ee4b82013-04-24 17:12:38 -07004502 def pretty_print(self, q):
4503 q.text("flow_delete_strict {")
4504 with q.group():
4505 with q.indent(2):
4506 q.breakable()
4507 q.text("xid = ");
4508 if self.xid != None:
4509 q.text("%#x" % self.xid)
4510 else:
4511 q.text('None')
4512 q.text(","); q.breakable()
4513 q.text("cookie = ");
4514 q.text("%#x" % self.cookie)
4515 q.text(","); q.breakable()
4516 q.text("cookie_mask = ");
4517 q.text("%#x" % self.cookie_mask)
4518 q.text(","); q.breakable()
4519 q.text("table_id = ");
4520 q.text("%#x" % self.table_id)
4521 q.text(","); q.breakable()
4522 q.text("idle_timeout = ");
4523 q.text("%#x" % self.idle_timeout)
4524 q.text(","); q.breakable()
4525 q.text("hard_timeout = ");
4526 q.text("%#x" % self.hard_timeout)
4527 q.text(","); q.breakable()
4528 q.text("priority = ");
4529 q.text("%#x" % self.priority)
4530 q.text(","); q.breakable()
4531 q.text("buffer_id = ");
4532 q.text("%#x" % self.buffer_id)
4533 q.text(","); q.breakable()
4534 q.text("out_port = ");
4535 q.text(util.pretty_port(self.out_port))
4536 q.text(","); q.breakable()
4537 q.text("out_group = ");
4538 q.text("%#x" % self.out_group)
4539 q.text(","); q.breakable()
4540 q.text("flags = ");
4541 q.text("%#x" % self.flags)
4542 q.text(","); q.breakable()
4543 q.text("match = ");
4544 q.pp(self.match)
4545 q.text(","); q.breakable()
4546 q.text("instructions = ");
4547 q.pp(self.instructions)
4548 q.breakable()
4549 q.text('}')
4550
Rich Lane7dcdf022013-12-11 14:45:27 -08004551flow_mod.subtypes[4] = flow_delete_strict
4552
4553class flow_mod_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07004554 version = 3
4555 type = 1
4556 err_type = 5
4557
4558 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08004559 if xid != None:
4560 self.xid = xid
4561 else:
4562 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07004563 if code != None:
4564 self.code = code
4565 else:
4566 self.code = 0
4567 if data != None:
4568 self.data = data
4569 else:
4570 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08004571 return
Rich Lane6f4978c2013-10-20 21:33:52 -07004572
4573 def pack(self):
4574 packed = []
4575 packed.append(struct.pack("!B", self.version))
4576 packed.append(struct.pack("!B", self.type))
4577 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4578 packed.append(struct.pack("!L", self.xid))
4579 packed.append(struct.pack("!H", self.err_type))
4580 packed.append(struct.pack("!H", self.code))
4581 packed.append(self.data)
4582 length = sum([len(x) for x in packed])
4583 packed[2] = struct.pack("!H", length)
4584 return ''.join(packed)
4585
4586 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004587 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07004588 obj = flow_mod_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07004589 _version = reader.read("!B")[0]
4590 assert(_version == 3)
4591 _type = reader.read("!B")[0]
4592 assert(_type == 1)
4593 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004594 orig_reader = reader
4595 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07004596 obj.xid = reader.read("!L")[0]
4597 _err_type = reader.read("!H")[0]
4598 assert(_err_type == 5)
4599 obj.code = reader.read("!H")[0]
4600 obj.data = str(reader.read_all())
4601 return obj
4602
4603 def __eq__(self, other):
4604 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07004605 if self.xid != other.xid: return False
4606 if self.code != other.code: return False
4607 if self.data != other.data: return False
4608 return True
4609
Rich Lane6f4978c2013-10-20 21:33:52 -07004610 def pretty_print(self, q):
4611 q.text("flow_mod_failed_error_msg {")
4612 with q.group():
4613 with q.indent(2):
4614 q.breakable()
4615 q.text("xid = ");
4616 if self.xid != None:
4617 q.text("%#x" % self.xid)
4618 else:
4619 q.text('None')
4620 q.text(","); q.breakable()
4621 q.text("code = ");
4622 q.text("%#x" % self.code)
4623 q.text(","); q.breakable()
4624 q.text("data = ");
4625 q.pp(self.data)
4626 q.breakable()
4627 q.text('}')
4628
Rich Lane7dcdf022013-12-11 14:45:27 -08004629error_msg.subtypes[5] = flow_mod_failed_error_msg
4630
4631class flow_modify(flow_mod):
Dan Talaycof6202252013-07-02 01:00:29 -07004632 version = 3
4633 type = 14
4634 _command = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07004635
4636 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 -08004637 if xid != None:
4638 self.xid = xid
4639 else:
4640 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004641 if cookie != None:
4642 self.cookie = cookie
4643 else:
4644 self.cookie = 0
4645 if cookie_mask != None:
4646 self.cookie_mask = cookie_mask
4647 else:
4648 self.cookie_mask = 0
4649 if table_id != None:
4650 self.table_id = table_id
4651 else:
4652 self.table_id = 0
4653 if idle_timeout != None:
4654 self.idle_timeout = idle_timeout
4655 else:
4656 self.idle_timeout = 0
4657 if hard_timeout != None:
4658 self.hard_timeout = hard_timeout
4659 else:
4660 self.hard_timeout = 0
4661 if priority != None:
4662 self.priority = priority
4663 else:
4664 self.priority = 0
4665 if buffer_id != None:
4666 self.buffer_id = buffer_id
4667 else:
4668 self.buffer_id = 0
4669 if out_port != None:
4670 self.out_port = out_port
4671 else:
4672 self.out_port = 0
4673 if out_group != None:
4674 self.out_group = out_group
4675 else:
4676 self.out_group = 0
4677 if flags != None:
4678 self.flags = flags
4679 else:
4680 self.flags = 0
4681 if match != None:
4682 self.match = match
4683 else:
4684 self.match = common.match()
4685 if instructions != None:
4686 self.instructions = instructions
4687 else:
4688 self.instructions = []
Rich Lane7dcdf022013-12-11 14:45:27 -08004689 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004690
4691 def pack(self):
4692 packed = []
4693 packed.append(struct.pack("!B", self.version))
4694 packed.append(struct.pack("!B", self.type))
4695 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4696 packed.append(struct.pack("!L", self.xid))
4697 packed.append(struct.pack("!Q", self.cookie))
4698 packed.append(struct.pack("!Q", self.cookie_mask))
4699 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004700 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004701 packed.append(struct.pack("!H", self.idle_timeout))
4702 packed.append(struct.pack("!H", self.hard_timeout))
4703 packed.append(struct.pack("!H", self.priority))
4704 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004705 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004706 packed.append(struct.pack("!L", self.out_group))
4707 packed.append(struct.pack("!H", self.flags))
4708 packed.append('\x00' * 2)
4709 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08004710 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004711 length = sum([len(x) for x in packed])
4712 packed[2] = struct.pack("!H", length)
4713 return ''.join(packed)
4714
4715 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004716 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004717 obj = flow_modify()
Dan Talaycof6202252013-07-02 01:00:29 -07004718 _version = reader.read("!B")[0]
4719 assert(_version == 3)
4720 _type = reader.read("!B")[0]
4721 assert(_type == 14)
4722 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004723 orig_reader = reader
4724 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07004725 obj.xid = reader.read("!L")[0]
4726 obj.cookie = reader.read("!Q")[0]
4727 obj.cookie_mask = reader.read("!Q")[0]
4728 obj.table_id = reader.read("!B")[0]
4729 __command = util.unpack_fm_cmd(reader)
4730 assert(__command == 1)
4731 obj.idle_timeout = reader.read("!H")[0]
4732 obj.hard_timeout = reader.read("!H")[0]
4733 obj.priority = reader.read("!H")[0]
4734 obj.buffer_id = reader.read("!L")[0]
4735 obj.out_port = util.unpack_port_no(reader)
4736 obj.out_group = reader.read("!L")[0]
4737 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004738 reader.skip(2)
4739 obj.match = common.match.unpack(reader)
Rich Lane7dcdf022013-12-11 14:45:27 -08004740 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07004741 return obj
4742
4743 def __eq__(self, other):
4744 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004745 if self.xid != other.xid: return False
4746 if self.cookie != other.cookie: return False
4747 if self.cookie_mask != other.cookie_mask: return False
4748 if self.table_id != other.table_id: return False
4749 if self.idle_timeout != other.idle_timeout: return False
4750 if self.hard_timeout != other.hard_timeout: return False
4751 if self.priority != other.priority: return False
4752 if self.buffer_id != other.buffer_id: return False
4753 if self.out_port != other.out_port: return False
4754 if self.out_group != other.out_group: return False
4755 if self.flags != other.flags: return False
4756 if self.match != other.match: return False
4757 if self.instructions != other.instructions: return False
4758 return True
4759
Rich Lanec2ee4b82013-04-24 17:12:38 -07004760 def pretty_print(self, q):
4761 q.text("flow_modify {")
4762 with q.group():
4763 with q.indent(2):
4764 q.breakable()
4765 q.text("xid = ");
4766 if self.xid != None:
4767 q.text("%#x" % self.xid)
4768 else:
4769 q.text('None')
4770 q.text(","); q.breakable()
4771 q.text("cookie = ");
4772 q.text("%#x" % self.cookie)
4773 q.text(","); q.breakable()
4774 q.text("cookie_mask = ");
4775 q.text("%#x" % self.cookie_mask)
4776 q.text(","); q.breakable()
4777 q.text("table_id = ");
4778 q.text("%#x" % self.table_id)
4779 q.text(","); q.breakable()
4780 q.text("idle_timeout = ");
4781 q.text("%#x" % self.idle_timeout)
4782 q.text(","); q.breakable()
4783 q.text("hard_timeout = ");
4784 q.text("%#x" % self.hard_timeout)
4785 q.text(","); q.breakable()
4786 q.text("priority = ");
4787 q.text("%#x" % self.priority)
4788 q.text(","); q.breakable()
4789 q.text("buffer_id = ");
4790 q.text("%#x" % self.buffer_id)
4791 q.text(","); q.breakable()
4792 q.text("out_port = ");
4793 q.text(util.pretty_port(self.out_port))
4794 q.text(","); q.breakable()
4795 q.text("out_group = ");
4796 q.text("%#x" % self.out_group)
4797 q.text(","); q.breakable()
4798 q.text("flags = ");
4799 q.text("%#x" % self.flags)
4800 q.text(","); q.breakable()
4801 q.text("match = ");
4802 q.pp(self.match)
4803 q.text(","); q.breakable()
4804 q.text("instructions = ");
4805 q.pp(self.instructions)
4806 q.breakable()
4807 q.text('}')
4808
Rich Lane7dcdf022013-12-11 14:45:27 -08004809flow_mod.subtypes[1] = flow_modify
4810
4811class flow_modify_strict(flow_mod):
Dan Talaycof6202252013-07-02 01:00:29 -07004812 version = 3
4813 type = 14
4814 _command = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07004815
4816 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 -08004817 if xid != None:
4818 self.xid = xid
4819 else:
4820 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004821 if cookie != None:
4822 self.cookie = cookie
4823 else:
4824 self.cookie = 0
4825 if cookie_mask != None:
4826 self.cookie_mask = cookie_mask
4827 else:
4828 self.cookie_mask = 0
4829 if table_id != None:
4830 self.table_id = table_id
4831 else:
4832 self.table_id = 0
4833 if idle_timeout != None:
4834 self.idle_timeout = idle_timeout
4835 else:
4836 self.idle_timeout = 0
4837 if hard_timeout != None:
4838 self.hard_timeout = hard_timeout
4839 else:
4840 self.hard_timeout = 0
4841 if priority != None:
4842 self.priority = priority
4843 else:
4844 self.priority = 0
4845 if buffer_id != None:
4846 self.buffer_id = buffer_id
4847 else:
4848 self.buffer_id = 0
4849 if out_port != None:
4850 self.out_port = out_port
4851 else:
4852 self.out_port = 0
4853 if out_group != None:
4854 self.out_group = out_group
4855 else:
4856 self.out_group = 0
4857 if flags != None:
4858 self.flags = flags
4859 else:
4860 self.flags = 0
4861 if match != None:
4862 self.match = match
4863 else:
4864 self.match = common.match()
4865 if instructions != None:
4866 self.instructions = instructions
4867 else:
4868 self.instructions = []
Rich Lane7dcdf022013-12-11 14:45:27 -08004869 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004870
4871 def pack(self):
4872 packed = []
4873 packed.append(struct.pack("!B", self.version))
4874 packed.append(struct.pack("!B", self.type))
4875 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4876 packed.append(struct.pack("!L", self.xid))
4877 packed.append(struct.pack("!Q", self.cookie))
4878 packed.append(struct.pack("!Q", self.cookie_mask))
4879 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004880 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004881 packed.append(struct.pack("!H", self.idle_timeout))
4882 packed.append(struct.pack("!H", self.hard_timeout))
4883 packed.append(struct.pack("!H", self.priority))
4884 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004885 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004886 packed.append(struct.pack("!L", self.out_group))
4887 packed.append(struct.pack("!H", self.flags))
4888 packed.append('\x00' * 2)
4889 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08004890 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004891 length = sum([len(x) for x in packed])
4892 packed[2] = struct.pack("!H", length)
4893 return ''.join(packed)
4894
4895 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004896 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004897 obj = flow_modify_strict()
Dan Talaycof6202252013-07-02 01:00:29 -07004898 _version = reader.read("!B")[0]
4899 assert(_version == 3)
4900 _type = reader.read("!B")[0]
4901 assert(_type == 14)
4902 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004903 orig_reader = reader
4904 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07004905 obj.xid = reader.read("!L")[0]
4906 obj.cookie = reader.read("!Q")[0]
4907 obj.cookie_mask = reader.read("!Q")[0]
4908 obj.table_id = reader.read("!B")[0]
4909 __command = util.unpack_fm_cmd(reader)
4910 assert(__command == 2)
4911 obj.idle_timeout = reader.read("!H")[0]
4912 obj.hard_timeout = reader.read("!H")[0]
4913 obj.priority = reader.read("!H")[0]
4914 obj.buffer_id = reader.read("!L")[0]
4915 obj.out_port = util.unpack_port_no(reader)
4916 obj.out_group = reader.read("!L")[0]
4917 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004918 reader.skip(2)
4919 obj.match = common.match.unpack(reader)
Rich Lane7dcdf022013-12-11 14:45:27 -08004920 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07004921 return obj
4922
4923 def __eq__(self, other):
4924 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004925 if self.xid != other.xid: return False
4926 if self.cookie != other.cookie: return False
4927 if self.cookie_mask != other.cookie_mask: return False
4928 if self.table_id != other.table_id: return False
4929 if self.idle_timeout != other.idle_timeout: return False
4930 if self.hard_timeout != other.hard_timeout: return False
4931 if self.priority != other.priority: return False
4932 if self.buffer_id != other.buffer_id: return False
4933 if self.out_port != other.out_port: return False
4934 if self.out_group != other.out_group: return False
4935 if self.flags != other.flags: return False
4936 if self.match != other.match: return False
4937 if self.instructions != other.instructions: return False
4938 return True
4939
Rich Lanec2ee4b82013-04-24 17:12:38 -07004940 def pretty_print(self, q):
4941 q.text("flow_modify_strict {")
4942 with q.group():
4943 with q.indent(2):
4944 q.breakable()
4945 q.text("xid = ");
4946 if self.xid != None:
4947 q.text("%#x" % self.xid)
4948 else:
4949 q.text('None')
4950 q.text(","); q.breakable()
4951 q.text("cookie = ");
4952 q.text("%#x" % self.cookie)
4953 q.text(","); q.breakable()
4954 q.text("cookie_mask = ");
4955 q.text("%#x" % self.cookie_mask)
4956 q.text(","); q.breakable()
4957 q.text("table_id = ");
4958 q.text("%#x" % self.table_id)
4959 q.text(","); q.breakable()
4960 q.text("idle_timeout = ");
4961 q.text("%#x" % self.idle_timeout)
4962 q.text(","); q.breakable()
4963 q.text("hard_timeout = ");
4964 q.text("%#x" % self.hard_timeout)
4965 q.text(","); q.breakable()
4966 q.text("priority = ");
4967 q.text("%#x" % self.priority)
4968 q.text(","); q.breakable()
4969 q.text("buffer_id = ");
4970 q.text("%#x" % self.buffer_id)
4971 q.text(","); q.breakable()
4972 q.text("out_port = ");
4973 q.text(util.pretty_port(self.out_port))
4974 q.text(","); q.breakable()
4975 q.text("out_group = ");
4976 q.text("%#x" % self.out_group)
4977 q.text(","); q.breakable()
4978 q.text("flags = ");
4979 q.text("%#x" % self.flags)
4980 q.text(","); q.breakable()
4981 q.text("match = ");
4982 q.pp(self.match)
4983 q.text(","); q.breakable()
4984 q.text("instructions = ");
4985 q.pp(self.instructions)
4986 q.breakable()
4987 q.text('}')
4988
Rich Lane7dcdf022013-12-11 14:45:27 -08004989flow_mod.subtypes[2] = flow_modify_strict
4990
4991class flow_removed(message):
Dan Talaycof6202252013-07-02 01:00:29 -07004992 version = 3
4993 type = 11
Rich Lanec2ee4b82013-04-24 17:12:38 -07004994
4995 def __init__(self, xid=None, cookie=None, priority=None, reason=None, table_id=None, duration_sec=None, duration_nsec=None, idle_timeout=None, hard_timeout=None, packet_count=None, byte_count=None, match=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08004996 if xid != None:
4997 self.xid = xid
4998 else:
4999 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005000 if cookie != None:
5001 self.cookie = cookie
5002 else:
5003 self.cookie = 0
5004 if priority != None:
5005 self.priority = priority
5006 else:
5007 self.priority = 0
5008 if reason != None:
5009 self.reason = reason
5010 else:
5011 self.reason = 0
5012 if table_id != None:
5013 self.table_id = table_id
5014 else:
5015 self.table_id = 0
5016 if duration_sec != None:
5017 self.duration_sec = duration_sec
5018 else:
5019 self.duration_sec = 0
5020 if duration_nsec != None:
5021 self.duration_nsec = duration_nsec
5022 else:
5023 self.duration_nsec = 0
5024 if idle_timeout != None:
5025 self.idle_timeout = idle_timeout
5026 else:
5027 self.idle_timeout = 0
5028 if hard_timeout != None:
5029 self.hard_timeout = hard_timeout
5030 else:
5031 self.hard_timeout = 0
5032 if packet_count != None:
5033 self.packet_count = packet_count
5034 else:
5035 self.packet_count = 0
5036 if byte_count != None:
5037 self.byte_count = byte_count
5038 else:
5039 self.byte_count = 0
5040 if match != None:
5041 self.match = match
5042 else:
5043 self.match = common.match()
Rich Lane7dcdf022013-12-11 14:45:27 -08005044 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005045
5046 def pack(self):
5047 packed = []
5048 packed.append(struct.pack("!B", self.version))
5049 packed.append(struct.pack("!B", self.type))
5050 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5051 packed.append(struct.pack("!L", self.xid))
5052 packed.append(struct.pack("!Q", self.cookie))
5053 packed.append(struct.pack("!H", self.priority))
5054 packed.append(struct.pack("!B", self.reason))
5055 packed.append(struct.pack("!B", self.table_id))
5056 packed.append(struct.pack("!L", self.duration_sec))
5057 packed.append(struct.pack("!L", self.duration_nsec))
5058 packed.append(struct.pack("!H", self.idle_timeout))
5059 packed.append(struct.pack("!H", self.hard_timeout))
5060 packed.append(struct.pack("!Q", self.packet_count))
5061 packed.append(struct.pack("!Q", self.byte_count))
5062 packed.append(self.match.pack())
5063 length = sum([len(x) for x in packed])
5064 packed[2] = struct.pack("!H", length)
5065 return ''.join(packed)
5066
5067 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005068 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005069 obj = flow_removed()
Dan Talaycof6202252013-07-02 01:00:29 -07005070 _version = reader.read("!B")[0]
5071 assert(_version == 3)
5072 _type = reader.read("!B")[0]
5073 assert(_type == 11)
5074 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005075 orig_reader = reader
5076 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005077 obj.xid = reader.read("!L")[0]
5078 obj.cookie = reader.read("!Q")[0]
5079 obj.priority = reader.read("!H")[0]
5080 obj.reason = reader.read("!B")[0]
5081 obj.table_id = reader.read("!B")[0]
5082 obj.duration_sec = reader.read("!L")[0]
5083 obj.duration_nsec = reader.read("!L")[0]
5084 obj.idle_timeout = reader.read("!H")[0]
5085 obj.hard_timeout = reader.read("!H")[0]
5086 obj.packet_count = reader.read("!Q")[0]
5087 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005088 obj.match = common.match.unpack(reader)
5089 return obj
5090
5091 def __eq__(self, other):
5092 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005093 if self.xid != other.xid: return False
5094 if self.cookie != other.cookie: return False
5095 if self.priority != other.priority: return False
5096 if self.reason != other.reason: return False
5097 if self.table_id != other.table_id: return False
5098 if self.duration_sec != other.duration_sec: return False
5099 if self.duration_nsec != other.duration_nsec: return False
5100 if self.idle_timeout != other.idle_timeout: return False
5101 if self.hard_timeout != other.hard_timeout: return False
5102 if self.packet_count != other.packet_count: return False
5103 if self.byte_count != other.byte_count: return False
5104 if self.match != other.match: return False
5105 return True
5106
Rich Lanec2ee4b82013-04-24 17:12:38 -07005107 def pretty_print(self, q):
5108 q.text("flow_removed {")
5109 with q.group():
5110 with q.indent(2):
5111 q.breakable()
5112 q.text("xid = ");
5113 if self.xid != None:
5114 q.text("%#x" % self.xid)
5115 else:
5116 q.text('None')
5117 q.text(","); q.breakable()
5118 q.text("cookie = ");
5119 q.text("%#x" % self.cookie)
5120 q.text(","); q.breakable()
5121 q.text("priority = ");
5122 q.text("%#x" % self.priority)
5123 q.text(","); q.breakable()
5124 q.text("reason = ");
5125 q.text("%#x" % self.reason)
5126 q.text(","); q.breakable()
5127 q.text("table_id = ");
5128 q.text("%#x" % self.table_id)
5129 q.text(","); q.breakable()
5130 q.text("duration_sec = ");
5131 q.text("%#x" % self.duration_sec)
5132 q.text(","); q.breakable()
5133 q.text("duration_nsec = ");
5134 q.text("%#x" % self.duration_nsec)
5135 q.text(","); q.breakable()
5136 q.text("idle_timeout = ");
5137 q.text("%#x" % self.idle_timeout)
5138 q.text(","); q.breakable()
5139 q.text("hard_timeout = ");
5140 q.text("%#x" % self.hard_timeout)
5141 q.text(","); q.breakable()
5142 q.text("packet_count = ");
5143 q.text("%#x" % self.packet_count)
5144 q.text(","); q.breakable()
5145 q.text("byte_count = ");
5146 q.text("%#x" % self.byte_count)
5147 q.text(","); q.breakable()
5148 q.text("match = ");
5149 q.pp(self.match)
5150 q.breakable()
5151 q.text('}')
5152
Rich Lane7dcdf022013-12-11 14:45:27 -08005153message.subtypes[11] = flow_removed
5154
5155class flow_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07005156 version = 3
5157 type = 19
5158 stats_type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07005159
5160 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005161 if xid != None:
5162 self.xid = xid
5163 else:
5164 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005165 if flags != None:
5166 self.flags = flags
5167 else:
5168 self.flags = 0
5169 if entries != None:
5170 self.entries = entries
5171 else:
5172 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08005173 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005174
5175 def pack(self):
5176 packed = []
5177 packed.append(struct.pack("!B", self.version))
5178 packed.append(struct.pack("!B", self.type))
5179 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5180 packed.append(struct.pack("!L", self.xid))
5181 packed.append(struct.pack("!H", self.stats_type))
5182 packed.append(struct.pack("!H", self.flags))
5183 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08005184 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005185 length = sum([len(x) for x in packed])
5186 packed[2] = struct.pack("!H", length)
5187 return ''.join(packed)
5188
5189 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005190 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005191 obj = flow_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07005192 _version = reader.read("!B")[0]
5193 assert(_version == 3)
5194 _type = reader.read("!B")[0]
5195 assert(_type == 19)
5196 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005197 orig_reader = reader
5198 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005199 obj.xid = reader.read("!L")[0]
5200 _stats_type = reader.read("!H")[0]
5201 assert(_stats_type == 1)
5202 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005203 reader.skip(4)
Rich Lane7dcdf022013-12-11 14:45:27 -08005204 obj.entries = loxi.generic_util.unpack_list(reader, common.flow_stats_entry.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07005205 return obj
5206
5207 def __eq__(self, other):
5208 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005209 if self.xid != other.xid: return False
5210 if self.flags != other.flags: return False
5211 if self.entries != other.entries: return False
5212 return True
5213
Rich Lanec2ee4b82013-04-24 17:12:38 -07005214 def pretty_print(self, q):
5215 q.text("flow_stats_reply {")
5216 with q.group():
5217 with q.indent(2):
5218 q.breakable()
5219 q.text("xid = ");
5220 if self.xid != None:
5221 q.text("%#x" % self.xid)
5222 else:
5223 q.text('None')
5224 q.text(","); q.breakable()
5225 q.text("flags = ");
5226 q.text("%#x" % self.flags)
5227 q.text(","); q.breakable()
5228 q.text("entries = ");
5229 q.pp(self.entries)
5230 q.breakable()
5231 q.text('}')
5232
Rich Lane7dcdf022013-12-11 14:45:27 -08005233stats_reply.subtypes[1] = flow_stats_reply
5234
5235class flow_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07005236 version = 3
5237 type = 18
5238 stats_type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07005239
5240 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 -08005241 if xid != None:
5242 self.xid = xid
5243 else:
5244 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005245 if flags != None:
5246 self.flags = flags
5247 else:
5248 self.flags = 0
5249 if table_id != None:
5250 self.table_id = table_id
5251 else:
5252 self.table_id = 0
5253 if out_port != None:
5254 self.out_port = out_port
5255 else:
5256 self.out_port = 0
5257 if out_group != None:
5258 self.out_group = out_group
5259 else:
5260 self.out_group = 0
5261 if cookie != None:
5262 self.cookie = cookie
5263 else:
5264 self.cookie = 0
5265 if cookie_mask != None:
5266 self.cookie_mask = cookie_mask
5267 else:
5268 self.cookie_mask = 0
5269 if match != None:
5270 self.match = match
5271 else:
5272 self.match = common.match()
Rich Lane7dcdf022013-12-11 14:45:27 -08005273 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005274
5275 def pack(self):
5276 packed = []
5277 packed.append(struct.pack("!B", self.version))
5278 packed.append(struct.pack("!B", self.type))
5279 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5280 packed.append(struct.pack("!L", self.xid))
5281 packed.append(struct.pack("!H", self.stats_type))
5282 packed.append(struct.pack("!H", self.flags))
5283 packed.append('\x00' * 4)
5284 packed.append(struct.pack("!B", self.table_id))
5285 packed.append('\x00' * 3)
Dan Talaycof6202252013-07-02 01:00:29 -07005286 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005287 packed.append(struct.pack("!L", self.out_group))
5288 packed.append('\x00' * 4)
5289 packed.append(struct.pack("!Q", self.cookie))
5290 packed.append(struct.pack("!Q", self.cookie_mask))
5291 packed.append(self.match.pack())
5292 length = sum([len(x) for x in packed])
5293 packed[2] = struct.pack("!H", length)
5294 return ''.join(packed)
5295
5296 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005297 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005298 obj = flow_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07005299 _version = reader.read("!B")[0]
5300 assert(_version == 3)
5301 _type = reader.read("!B")[0]
5302 assert(_type == 18)
5303 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005304 orig_reader = reader
5305 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005306 obj.xid = reader.read("!L")[0]
5307 _stats_type = reader.read("!H")[0]
5308 assert(_stats_type == 1)
5309 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005310 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07005311 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005312 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07005313 obj.out_port = util.unpack_port_no(reader)
5314 obj.out_group = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005315 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07005316 obj.cookie = reader.read("!Q")[0]
5317 obj.cookie_mask = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005318 obj.match = common.match.unpack(reader)
5319 return obj
5320
5321 def __eq__(self, other):
5322 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005323 if self.xid != other.xid: return False
5324 if self.flags != other.flags: return False
5325 if self.table_id != other.table_id: return False
5326 if self.out_port != other.out_port: return False
5327 if self.out_group != other.out_group: return False
5328 if self.cookie != other.cookie: return False
5329 if self.cookie_mask != other.cookie_mask: return False
5330 if self.match != other.match: return False
5331 return True
5332
Rich Lanec2ee4b82013-04-24 17:12:38 -07005333 def pretty_print(self, q):
5334 q.text("flow_stats_request {")
5335 with q.group():
5336 with q.indent(2):
5337 q.breakable()
5338 q.text("xid = ");
5339 if self.xid != None:
5340 q.text("%#x" % self.xid)
5341 else:
5342 q.text('None')
5343 q.text(","); q.breakable()
5344 q.text("flags = ");
5345 q.text("%#x" % self.flags)
5346 q.text(","); q.breakable()
5347 q.text("table_id = ");
5348 q.text("%#x" % self.table_id)
5349 q.text(","); q.breakable()
5350 q.text("out_port = ");
5351 q.text(util.pretty_port(self.out_port))
5352 q.text(","); q.breakable()
5353 q.text("out_group = ");
5354 q.text("%#x" % self.out_group)
5355 q.text(","); q.breakable()
5356 q.text("cookie = ");
5357 q.text("%#x" % self.cookie)
5358 q.text(","); q.breakable()
5359 q.text("cookie_mask = ");
5360 q.text("%#x" % self.cookie_mask)
5361 q.text(","); q.breakable()
5362 q.text("match = ");
5363 q.pp(self.match)
5364 q.breakable()
5365 q.text('}')
5366
Rich Lane7dcdf022013-12-11 14:45:27 -08005367stats_request.subtypes[1] = flow_stats_request
5368
5369class get_config_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -07005370 version = 3
5371 type = 8
Rich Lanec2ee4b82013-04-24 17:12:38 -07005372
5373 def __init__(self, xid=None, flags=None, miss_send_len=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005374 if xid != None:
5375 self.xid = xid
5376 else:
5377 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005378 if flags != None:
5379 self.flags = flags
5380 else:
5381 self.flags = 0
5382 if miss_send_len != None:
5383 self.miss_send_len = miss_send_len
5384 else:
5385 self.miss_send_len = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08005386 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005387
5388 def pack(self):
5389 packed = []
5390 packed.append(struct.pack("!B", self.version))
5391 packed.append(struct.pack("!B", self.type))
5392 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5393 packed.append(struct.pack("!L", self.xid))
5394 packed.append(struct.pack("!H", self.flags))
5395 packed.append(struct.pack("!H", self.miss_send_len))
5396 length = sum([len(x) for x in packed])
5397 packed[2] = struct.pack("!H", length)
5398 return ''.join(packed)
5399
5400 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005401 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005402 obj = get_config_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07005403 _version = reader.read("!B")[0]
5404 assert(_version == 3)
5405 _type = reader.read("!B")[0]
5406 assert(_type == 8)
5407 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005408 orig_reader = reader
5409 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005410 obj.xid = reader.read("!L")[0]
5411 obj.flags = reader.read("!H")[0]
5412 obj.miss_send_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005413 return obj
5414
5415 def __eq__(self, other):
5416 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005417 if self.xid != other.xid: return False
5418 if self.flags != other.flags: return False
5419 if self.miss_send_len != other.miss_send_len: return False
5420 return True
5421
Rich Lanec2ee4b82013-04-24 17:12:38 -07005422 def pretty_print(self, q):
5423 q.text("get_config_reply {")
5424 with q.group():
5425 with q.indent(2):
5426 q.breakable()
5427 q.text("xid = ");
5428 if self.xid != None:
5429 q.text("%#x" % self.xid)
5430 else:
5431 q.text('None')
5432 q.text(","); q.breakable()
5433 q.text("flags = ");
5434 q.text("%#x" % self.flags)
5435 q.text(","); q.breakable()
5436 q.text("miss_send_len = ");
5437 q.text("%#x" % self.miss_send_len)
5438 q.breakable()
5439 q.text('}')
5440
Rich Lane7dcdf022013-12-11 14:45:27 -08005441message.subtypes[8] = get_config_reply
5442
5443class get_config_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -07005444 version = 3
5445 type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07005446
5447 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005448 if xid != None:
5449 self.xid = xid
5450 else:
5451 self.xid = None
5452 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005453
5454 def pack(self):
5455 packed = []
5456 packed.append(struct.pack("!B", self.version))
5457 packed.append(struct.pack("!B", self.type))
5458 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5459 packed.append(struct.pack("!L", self.xid))
5460 length = sum([len(x) for x in packed])
5461 packed[2] = struct.pack("!H", length)
5462 return ''.join(packed)
5463
5464 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005465 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005466 obj = get_config_request()
Dan Talaycof6202252013-07-02 01:00:29 -07005467 _version = reader.read("!B")[0]
5468 assert(_version == 3)
5469 _type = reader.read("!B")[0]
5470 assert(_type == 7)
5471 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005472 orig_reader = reader
5473 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005474 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005475 return obj
5476
5477 def __eq__(self, other):
5478 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005479 if self.xid != other.xid: return False
5480 return True
5481
Rich Lanec2ee4b82013-04-24 17:12:38 -07005482 def pretty_print(self, q):
5483 q.text("get_config_request {")
5484 with q.group():
5485 with q.indent(2):
5486 q.breakable()
5487 q.text("xid = ");
5488 if self.xid != None:
5489 q.text("%#x" % self.xid)
5490 else:
5491 q.text('None')
5492 q.breakable()
5493 q.text('}')
5494
Rich Lane7dcdf022013-12-11 14:45:27 -08005495message.subtypes[7] = get_config_request
5496
5497class group_mod(message):
5498 subtypes = {}
5499
Rich Lane95f7fc92014-01-27 17:08:16 -08005500 version = 3
5501 type = 15
5502
5503 def __init__(self, xid=None, command=None, group_type=None, group_id=None, buckets=None):
5504 if xid != None:
5505 self.xid = xid
5506 else:
5507 self.xid = None
5508 if command != None:
5509 self.command = command
5510 else:
5511 self.command = 0
5512 if group_type != None:
5513 self.group_type = group_type
5514 else:
5515 self.group_type = 0
5516 if group_id != None:
5517 self.group_id = group_id
5518 else:
5519 self.group_id = 0
5520 if buckets != None:
5521 self.buckets = buckets
5522 else:
5523 self.buckets = []
5524 return
5525
5526 def pack(self):
5527 packed = []
5528 packed.append(struct.pack("!B", self.version))
5529 packed.append(struct.pack("!B", self.type))
5530 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5531 packed.append(struct.pack("!L", self.xid))
5532 packed.append(struct.pack("!H", self.command))
5533 packed.append(struct.pack("!B", self.group_type))
5534 packed.append('\x00' * 1)
5535 packed.append(struct.pack("!L", self.group_id))
5536 packed.append(loxi.generic_util.pack_list(self.buckets))
5537 length = sum([len(x) for x in packed])
5538 packed[2] = struct.pack("!H", length)
5539 return ''.join(packed)
5540
Rich Lane7dcdf022013-12-11 14:45:27 -08005541 @staticmethod
5542 def unpack(reader):
5543 subtype, = reader.peek('!H', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -08005544 subclass = group_mod.subtypes.get(subtype)
5545 if subclass:
5546 return subclass.unpack(reader)
5547
5548 obj = group_mod()
5549 _version = reader.read("!B")[0]
5550 assert(_version == 3)
5551 _type = reader.read("!B")[0]
5552 assert(_type == 15)
5553 _length = reader.read("!H")[0]
5554 orig_reader = reader
5555 reader = orig_reader.slice(_length - (2 + 2))
5556 obj.xid = reader.read("!L")[0]
5557 obj.command = reader.read("!H")[0]
5558 obj.group_type = reader.read("!B")[0]
5559 reader.skip(1)
5560 obj.group_id = reader.read("!L")[0]
5561 obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack)
5562 return obj
5563
5564 def __eq__(self, other):
5565 if type(self) != type(other): return False
5566 if self.xid != other.xid: return False
5567 if self.command != other.command: return False
5568 if self.group_type != other.group_type: return False
5569 if self.group_id != other.group_id: return False
5570 if self.buckets != other.buckets: return False
5571 return True
5572
5573 def pretty_print(self, q):
5574 q.text("group_mod {")
5575 with q.group():
5576 with q.indent(2):
5577 q.breakable()
5578 q.text("xid = ");
5579 if self.xid != None:
5580 q.text("%#x" % self.xid)
5581 else:
5582 q.text('None')
5583 q.text(","); q.breakable()
5584 q.text("group_type = ");
5585 q.text("%#x" % self.group_type)
5586 q.text(","); q.breakable()
5587 q.text("group_id = ");
5588 q.text("%#x" % self.group_id)
5589 q.text(","); q.breakable()
5590 q.text("buckets = ");
5591 q.pp(self.buckets)
5592 q.breakable()
5593 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08005594
5595message.subtypes[15] = group_mod
5596
5597class group_add(group_mod):
Rich Lane7b0f2012013-11-22 14:15:26 -08005598 version = 3
5599 type = 15
5600 command = 0
5601
5602 def __init__(self, xid=None, group_type=None, group_id=None, buckets=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005603 if xid != None:
5604 self.xid = xid
5605 else:
5606 self.xid = None
Rich Lane7b0f2012013-11-22 14:15:26 -08005607 if group_type != None:
5608 self.group_type = group_type
5609 else:
5610 self.group_type = 0
5611 if group_id != None:
5612 self.group_id = group_id
5613 else:
5614 self.group_id = 0
5615 if buckets != None:
5616 self.buckets = buckets
5617 else:
5618 self.buckets = []
Rich Lane7dcdf022013-12-11 14:45:27 -08005619 return
Rich Lane7b0f2012013-11-22 14:15:26 -08005620
5621 def pack(self):
5622 packed = []
5623 packed.append(struct.pack("!B", self.version))
5624 packed.append(struct.pack("!B", self.type))
5625 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5626 packed.append(struct.pack("!L", self.xid))
5627 packed.append(struct.pack("!H", self.command))
5628 packed.append(struct.pack("!B", self.group_type))
5629 packed.append('\x00' * 1)
5630 packed.append(struct.pack("!L", self.group_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08005631 packed.append(loxi.generic_util.pack_list(self.buckets))
Rich Lane7b0f2012013-11-22 14:15:26 -08005632 length = sum([len(x) for x in packed])
5633 packed[2] = struct.pack("!H", length)
5634 return ''.join(packed)
5635
5636 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005637 def unpack(reader):
Rich Lane7b0f2012013-11-22 14:15:26 -08005638 obj = group_add()
Rich Lane7b0f2012013-11-22 14:15:26 -08005639 _version = reader.read("!B")[0]
5640 assert(_version == 3)
5641 _type = reader.read("!B")[0]
5642 assert(_type == 15)
5643 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005644 orig_reader = reader
5645 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane7b0f2012013-11-22 14:15:26 -08005646 obj.xid = reader.read("!L")[0]
5647 _command = reader.read("!H")[0]
5648 assert(_command == 0)
5649 obj.group_type = reader.read("!B")[0]
5650 reader.skip(1)
5651 obj.group_id = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005652 obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack)
Rich Lane7b0f2012013-11-22 14:15:26 -08005653 return obj
5654
5655 def __eq__(self, other):
5656 if type(self) != type(other): return False
Rich Lane7b0f2012013-11-22 14:15:26 -08005657 if self.xid != other.xid: return False
5658 if self.group_type != other.group_type: return False
5659 if self.group_id != other.group_id: return False
5660 if self.buckets != other.buckets: return False
5661 return True
5662
Rich Lane7b0f2012013-11-22 14:15:26 -08005663 def pretty_print(self, q):
5664 q.text("group_add {")
5665 with q.group():
5666 with q.indent(2):
5667 q.breakable()
5668 q.text("xid = ");
5669 if self.xid != None:
5670 q.text("%#x" % self.xid)
5671 else:
5672 q.text('None')
5673 q.text(","); q.breakable()
5674 q.text("group_type = ");
5675 q.text("%#x" % self.group_type)
5676 q.text(","); q.breakable()
5677 q.text("group_id = ");
5678 q.text("%#x" % self.group_id)
5679 q.text(","); q.breakable()
5680 q.text("buckets = ");
5681 q.pp(self.buckets)
5682 q.breakable()
5683 q.text('}')
5684
Rich Lane7dcdf022013-12-11 14:45:27 -08005685group_mod.subtypes[0] = group_add
5686
5687class group_delete(group_mod):
Rich Lane7b0f2012013-11-22 14:15:26 -08005688 version = 3
5689 type = 15
5690 command = 2
5691
5692 def __init__(self, xid=None, group_type=None, group_id=None, buckets=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005693 if xid != None:
5694 self.xid = xid
5695 else:
5696 self.xid = None
Rich Lane7b0f2012013-11-22 14:15:26 -08005697 if group_type != None:
5698 self.group_type = group_type
5699 else:
5700 self.group_type = 0
5701 if group_id != None:
5702 self.group_id = group_id
5703 else:
5704 self.group_id = 0
5705 if buckets != None:
5706 self.buckets = buckets
5707 else:
5708 self.buckets = []
Rich Lane7dcdf022013-12-11 14:45:27 -08005709 return
Rich Lane7b0f2012013-11-22 14:15:26 -08005710
5711 def pack(self):
5712 packed = []
5713 packed.append(struct.pack("!B", self.version))
5714 packed.append(struct.pack("!B", self.type))
5715 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5716 packed.append(struct.pack("!L", self.xid))
5717 packed.append(struct.pack("!H", self.command))
5718 packed.append(struct.pack("!B", self.group_type))
5719 packed.append('\x00' * 1)
5720 packed.append(struct.pack("!L", self.group_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08005721 packed.append(loxi.generic_util.pack_list(self.buckets))
Rich Lane7b0f2012013-11-22 14:15:26 -08005722 length = sum([len(x) for x in packed])
5723 packed[2] = struct.pack("!H", length)
5724 return ''.join(packed)
5725
5726 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005727 def unpack(reader):
Rich Lane7b0f2012013-11-22 14:15:26 -08005728 obj = group_delete()
Rich Lane7b0f2012013-11-22 14:15:26 -08005729 _version = reader.read("!B")[0]
5730 assert(_version == 3)
5731 _type = reader.read("!B")[0]
5732 assert(_type == 15)
5733 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005734 orig_reader = reader
5735 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane7b0f2012013-11-22 14:15:26 -08005736 obj.xid = reader.read("!L")[0]
5737 _command = reader.read("!H")[0]
5738 assert(_command == 2)
5739 obj.group_type = reader.read("!B")[0]
5740 reader.skip(1)
5741 obj.group_id = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005742 obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack)
Rich Lane7b0f2012013-11-22 14:15:26 -08005743 return obj
5744
5745 def __eq__(self, other):
5746 if type(self) != type(other): return False
Rich Lane7b0f2012013-11-22 14:15:26 -08005747 if self.xid != other.xid: return False
5748 if self.group_type != other.group_type: return False
5749 if self.group_id != other.group_id: return False
5750 if self.buckets != other.buckets: return False
5751 return True
5752
Rich Lane7b0f2012013-11-22 14:15:26 -08005753 def pretty_print(self, q):
5754 q.text("group_delete {")
5755 with q.group():
5756 with q.indent(2):
5757 q.breakable()
5758 q.text("xid = ");
5759 if self.xid != None:
5760 q.text("%#x" % self.xid)
5761 else:
5762 q.text('None')
5763 q.text(","); q.breakable()
5764 q.text("group_type = ");
5765 q.text("%#x" % self.group_type)
5766 q.text(","); q.breakable()
5767 q.text("group_id = ");
5768 q.text("%#x" % self.group_id)
5769 q.text(","); q.breakable()
5770 q.text("buckets = ");
5771 q.pp(self.buckets)
5772 q.breakable()
5773 q.text('}')
5774
Rich Lane7dcdf022013-12-11 14:45:27 -08005775group_mod.subtypes[2] = group_delete
5776
5777class group_desc_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07005778 version = 3
5779 type = 19
5780 stats_type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07005781
5782 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005783 if xid != None:
5784 self.xid = xid
5785 else:
5786 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005787 if flags != None:
5788 self.flags = flags
5789 else:
5790 self.flags = 0
5791 if entries != None:
5792 self.entries = entries
5793 else:
5794 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08005795 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005796
5797 def pack(self):
5798 packed = []
5799 packed.append(struct.pack("!B", self.version))
5800 packed.append(struct.pack("!B", self.type))
5801 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5802 packed.append(struct.pack("!L", self.xid))
5803 packed.append(struct.pack("!H", self.stats_type))
5804 packed.append(struct.pack("!H", self.flags))
5805 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08005806 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005807 length = sum([len(x) for x in packed])
5808 packed[2] = struct.pack("!H", length)
5809 return ''.join(packed)
5810
5811 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005812 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005813 obj = group_desc_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07005814 _version = reader.read("!B")[0]
5815 assert(_version == 3)
5816 _type = reader.read("!B")[0]
5817 assert(_type == 19)
5818 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005819 orig_reader = reader
5820 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005821 obj.xid = reader.read("!L")[0]
5822 _stats_type = reader.read("!H")[0]
5823 assert(_stats_type == 7)
5824 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005825 reader.skip(4)
Rich Lane7dcdf022013-12-11 14:45:27 -08005826 obj.entries = loxi.generic_util.unpack_list(reader, common.group_desc_stats_entry.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07005827 return obj
5828
5829 def __eq__(self, other):
5830 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005831 if self.xid != other.xid: return False
5832 if self.flags != other.flags: return False
5833 if self.entries != other.entries: return False
5834 return True
5835
Rich Lanec2ee4b82013-04-24 17:12:38 -07005836 def pretty_print(self, q):
5837 q.text("group_desc_stats_reply {")
5838 with q.group():
5839 with q.indent(2):
5840 q.breakable()
5841 q.text("xid = ");
5842 if self.xid != None:
5843 q.text("%#x" % self.xid)
5844 else:
5845 q.text('None')
5846 q.text(","); q.breakable()
5847 q.text("flags = ");
5848 q.text("%#x" % self.flags)
5849 q.text(","); q.breakable()
5850 q.text("entries = ");
5851 q.pp(self.entries)
5852 q.breakable()
5853 q.text('}')
5854
Rich Lane7dcdf022013-12-11 14:45:27 -08005855stats_reply.subtypes[7] = group_desc_stats_reply
5856
5857class group_desc_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07005858 version = 3
5859 type = 18
5860 stats_type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07005861
5862 def __init__(self, xid=None, flags=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005863 if xid != None:
5864 self.xid = xid
5865 else:
5866 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005867 if flags != None:
5868 self.flags = flags
5869 else:
5870 self.flags = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08005871 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005872
5873 def pack(self):
5874 packed = []
5875 packed.append(struct.pack("!B", self.version))
5876 packed.append(struct.pack("!B", self.type))
5877 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5878 packed.append(struct.pack("!L", self.xid))
5879 packed.append(struct.pack("!H", self.stats_type))
5880 packed.append(struct.pack("!H", self.flags))
5881 packed.append('\x00' * 4)
5882 length = sum([len(x) for x in packed])
5883 packed[2] = struct.pack("!H", length)
5884 return ''.join(packed)
5885
5886 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005887 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005888 obj = group_desc_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07005889 _version = reader.read("!B")[0]
5890 assert(_version == 3)
5891 _type = reader.read("!B")[0]
5892 assert(_type == 18)
5893 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005894 orig_reader = reader
5895 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005896 obj.xid = reader.read("!L")[0]
5897 _stats_type = reader.read("!H")[0]
5898 assert(_stats_type == 7)
5899 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005900 reader.skip(4)
5901 return obj
5902
5903 def __eq__(self, other):
5904 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005905 if self.xid != other.xid: return False
5906 if self.flags != other.flags: return False
5907 return True
5908
Rich Lanec2ee4b82013-04-24 17:12:38 -07005909 def pretty_print(self, q):
5910 q.text("group_desc_stats_request {")
5911 with q.group():
5912 with q.indent(2):
5913 q.breakable()
5914 q.text("xid = ");
5915 if self.xid != None:
5916 q.text("%#x" % self.xid)
5917 else:
5918 q.text('None')
5919 q.text(","); q.breakable()
5920 q.text("flags = ");
5921 q.text("%#x" % self.flags)
5922 q.breakable()
5923 q.text('}')
5924
Rich Lane7dcdf022013-12-11 14:45:27 -08005925stats_request.subtypes[7] = group_desc_stats_request
5926
5927class group_features_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07005928 version = 3
5929 type = 19
5930 stats_type = 8
Rich Lanec2ee4b82013-04-24 17:12:38 -07005931
5932 def __init__(self, xid=None, flags=None, types=None, capabilities=None, max_groups_all=None, max_groups_select=None, max_groups_indirect=None, max_groups_ff=None, actions_all=None, actions_select=None, actions_indirect=None, actions_ff=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005933 if xid != None:
5934 self.xid = xid
5935 else:
5936 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005937 if flags != None:
5938 self.flags = flags
5939 else:
5940 self.flags = 0
5941 if types != None:
5942 self.types = types
5943 else:
5944 self.types = 0
5945 if capabilities != None:
5946 self.capabilities = capabilities
5947 else:
5948 self.capabilities = 0
5949 if max_groups_all != None:
5950 self.max_groups_all = max_groups_all
5951 else:
5952 self.max_groups_all = 0
5953 if max_groups_select != None:
5954 self.max_groups_select = max_groups_select
5955 else:
5956 self.max_groups_select = 0
5957 if max_groups_indirect != None:
5958 self.max_groups_indirect = max_groups_indirect
5959 else:
5960 self.max_groups_indirect = 0
5961 if max_groups_ff != None:
5962 self.max_groups_ff = max_groups_ff
5963 else:
5964 self.max_groups_ff = 0
5965 if actions_all != None:
5966 self.actions_all = actions_all
5967 else:
5968 self.actions_all = 0
5969 if actions_select != None:
5970 self.actions_select = actions_select
5971 else:
5972 self.actions_select = 0
5973 if actions_indirect != None:
5974 self.actions_indirect = actions_indirect
5975 else:
5976 self.actions_indirect = 0
5977 if actions_ff != None:
5978 self.actions_ff = actions_ff
5979 else:
5980 self.actions_ff = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08005981 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005982
5983 def pack(self):
5984 packed = []
5985 packed.append(struct.pack("!B", self.version))
5986 packed.append(struct.pack("!B", self.type))
5987 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5988 packed.append(struct.pack("!L", self.xid))
5989 packed.append(struct.pack("!H", self.stats_type))
5990 packed.append(struct.pack("!H", self.flags))
5991 packed.append('\x00' * 4)
5992 packed.append(struct.pack("!L", self.types))
5993 packed.append(struct.pack("!L", self.capabilities))
5994 packed.append(struct.pack("!L", self.max_groups_all))
5995 packed.append(struct.pack("!L", self.max_groups_select))
5996 packed.append(struct.pack("!L", self.max_groups_indirect))
5997 packed.append(struct.pack("!L", self.max_groups_ff))
5998 packed.append(struct.pack("!L", self.actions_all))
5999 packed.append(struct.pack("!L", self.actions_select))
6000 packed.append(struct.pack("!L", self.actions_indirect))
6001 packed.append(struct.pack("!L", self.actions_ff))
6002 length = sum([len(x) for x in packed])
6003 packed[2] = struct.pack("!H", length)
6004 return ''.join(packed)
6005
6006 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006007 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006008 obj = group_features_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07006009 _version = reader.read("!B")[0]
6010 assert(_version == 3)
6011 _type = reader.read("!B")[0]
6012 assert(_type == 19)
6013 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006014 orig_reader = reader
6015 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006016 obj.xid = reader.read("!L")[0]
6017 _stats_type = reader.read("!H")[0]
6018 assert(_stats_type == 8)
6019 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006020 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07006021 obj.types = reader.read("!L")[0]
6022 obj.capabilities = reader.read("!L")[0]
6023 obj.max_groups_all = reader.read("!L")[0]
6024 obj.max_groups_select = reader.read("!L")[0]
6025 obj.max_groups_indirect = reader.read("!L")[0]
6026 obj.max_groups_ff = reader.read("!L")[0]
6027 obj.actions_all = reader.read("!L")[0]
6028 obj.actions_select = reader.read("!L")[0]
6029 obj.actions_indirect = reader.read("!L")[0]
6030 obj.actions_ff = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006031 return obj
6032
6033 def __eq__(self, other):
6034 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006035 if self.xid != other.xid: return False
6036 if self.flags != other.flags: return False
6037 if self.types != other.types: return False
6038 if self.capabilities != other.capabilities: return False
6039 if self.max_groups_all != other.max_groups_all: return False
6040 if self.max_groups_select != other.max_groups_select: return False
6041 if self.max_groups_indirect != other.max_groups_indirect: return False
6042 if self.max_groups_ff != other.max_groups_ff: return False
6043 if self.actions_all != other.actions_all: return False
6044 if self.actions_select != other.actions_select: return False
6045 if self.actions_indirect != other.actions_indirect: return False
6046 if self.actions_ff != other.actions_ff: return False
6047 return True
6048
Rich Lanec2ee4b82013-04-24 17:12:38 -07006049 def pretty_print(self, q):
6050 q.text("group_features_stats_reply {")
6051 with q.group():
6052 with q.indent(2):
6053 q.breakable()
6054 q.text("xid = ");
6055 if self.xid != None:
6056 q.text("%#x" % self.xid)
6057 else:
6058 q.text('None')
6059 q.text(","); q.breakable()
6060 q.text("flags = ");
6061 q.text("%#x" % self.flags)
6062 q.text(","); q.breakable()
6063 q.text("types = ");
6064 q.text("%#x" % self.types)
6065 q.text(","); q.breakable()
6066 q.text("capabilities = ");
6067 q.text("%#x" % self.capabilities)
6068 q.text(","); q.breakable()
6069 q.text("max_groups_all = ");
6070 q.text("%#x" % self.max_groups_all)
6071 q.text(","); q.breakable()
6072 q.text("max_groups_select = ");
6073 q.text("%#x" % self.max_groups_select)
6074 q.text(","); q.breakable()
6075 q.text("max_groups_indirect = ");
6076 q.text("%#x" % self.max_groups_indirect)
6077 q.text(","); q.breakable()
6078 q.text("max_groups_ff = ");
6079 q.text("%#x" % self.max_groups_ff)
6080 q.text(","); q.breakable()
6081 q.text("actions_all = ");
6082 q.text("%#x" % self.actions_all)
6083 q.text(","); q.breakable()
6084 q.text("actions_select = ");
6085 q.text("%#x" % self.actions_select)
6086 q.text(","); q.breakable()
6087 q.text("actions_indirect = ");
6088 q.text("%#x" % self.actions_indirect)
6089 q.text(","); q.breakable()
6090 q.text("actions_ff = ");
6091 q.text("%#x" % self.actions_ff)
6092 q.breakable()
6093 q.text('}')
6094
Rich Lane7dcdf022013-12-11 14:45:27 -08006095stats_reply.subtypes[8] = group_features_stats_reply
6096
6097class group_features_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07006098 version = 3
6099 type = 18
6100 stats_type = 8
Rich Lanec2ee4b82013-04-24 17:12:38 -07006101
6102 def __init__(self, xid=None, flags=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006103 if xid != None:
6104 self.xid = xid
6105 else:
6106 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006107 if flags != None:
6108 self.flags = flags
6109 else:
6110 self.flags = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08006111 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006112
6113 def pack(self):
6114 packed = []
6115 packed.append(struct.pack("!B", self.version))
6116 packed.append(struct.pack("!B", self.type))
6117 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6118 packed.append(struct.pack("!L", self.xid))
6119 packed.append(struct.pack("!H", self.stats_type))
6120 packed.append(struct.pack("!H", self.flags))
6121 packed.append('\x00' * 4)
6122 length = sum([len(x) for x in packed])
6123 packed[2] = struct.pack("!H", length)
6124 return ''.join(packed)
6125
6126 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006127 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006128 obj = group_features_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07006129 _version = reader.read("!B")[0]
6130 assert(_version == 3)
6131 _type = reader.read("!B")[0]
6132 assert(_type == 18)
6133 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006134 orig_reader = reader
6135 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006136 obj.xid = reader.read("!L")[0]
6137 _stats_type = reader.read("!H")[0]
6138 assert(_stats_type == 8)
6139 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006140 reader.skip(4)
6141 return obj
6142
6143 def __eq__(self, other):
6144 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006145 if self.xid != other.xid: return False
6146 if self.flags != other.flags: return False
6147 return True
6148
Rich Lanec2ee4b82013-04-24 17:12:38 -07006149 def pretty_print(self, q):
6150 q.text("group_features_stats_request {")
6151 with q.group():
6152 with q.indent(2):
6153 q.breakable()
6154 q.text("xid = ");
6155 if self.xid != None:
6156 q.text("%#x" % self.xid)
6157 else:
6158 q.text('None')
6159 q.text(","); q.breakable()
6160 q.text("flags = ");
6161 q.text("%#x" % self.flags)
6162 q.breakable()
6163 q.text('}')
6164
Rich Lane7dcdf022013-12-11 14:45:27 -08006165stats_request.subtypes[8] = group_features_stats_request
6166
6167class group_mod_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07006168 version = 3
6169 type = 1
6170 err_type = 6
6171
6172 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006173 if xid != None:
6174 self.xid = xid
6175 else:
6176 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07006177 if code != None:
6178 self.code = code
6179 else:
6180 self.code = 0
6181 if data != None:
6182 self.data = data
6183 else:
6184 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08006185 return
Rich Lane6f4978c2013-10-20 21:33:52 -07006186
6187 def pack(self):
6188 packed = []
6189 packed.append(struct.pack("!B", self.version))
6190 packed.append(struct.pack("!B", self.type))
6191 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6192 packed.append(struct.pack("!L", self.xid))
6193 packed.append(struct.pack("!H", self.err_type))
6194 packed.append(struct.pack("!H", self.code))
6195 packed.append(self.data)
6196 length = sum([len(x) for x in packed])
6197 packed[2] = struct.pack("!H", length)
6198 return ''.join(packed)
6199
6200 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006201 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07006202 obj = group_mod_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07006203 _version = reader.read("!B")[0]
6204 assert(_version == 3)
6205 _type = reader.read("!B")[0]
6206 assert(_type == 1)
6207 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006208 orig_reader = reader
6209 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07006210 obj.xid = reader.read("!L")[0]
6211 _err_type = reader.read("!H")[0]
6212 assert(_err_type == 6)
6213 obj.code = reader.read("!H")[0]
6214 obj.data = str(reader.read_all())
6215 return obj
6216
6217 def __eq__(self, other):
6218 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07006219 if self.xid != other.xid: return False
6220 if self.code != other.code: return False
6221 if self.data != other.data: return False
6222 return True
6223
Rich Lane6f4978c2013-10-20 21:33:52 -07006224 def pretty_print(self, q):
6225 q.text("group_mod_failed_error_msg {")
6226 with q.group():
6227 with q.indent(2):
6228 q.breakable()
6229 q.text("xid = ");
6230 if self.xid != None:
6231 q.text("%#x" % self.xid)
6232 else:
6233 q.text('None')
6234 q.text(","); q.breakable()
6235 q.text("code = ");
6236 q.text("%#x" % self.code)
6237 q.text(","); q.breakable()
6238 q.text("data = ");
6239 q.pp(self.data)
6240 q.breakable()
6241 q.text('}')
6242
Rich Lane7dcdf022013-12-11 14:45:27 -08006243error_msg.subtypes[6] = group_mod_failed_error_msg
6244
6245class group_modify(group_mod):
Rich Lane7b0f2012013-11-22 14:15:26 -08006246 version = 3
6247 type = 15
6248 command = 1
6249
6250 def __init__(self, xid=None, group_type=None, group_id=None, buckets=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006251 if xid != None:
6252 self.xid = xid
6253 else:
6254 self.xid = None
Rich Lane7b0f2012013-11-22 14:15:26 -08006255 if group_type != None:
6256 self.group_type = group_type
6257 else:
6258 self.group_type = 0
6259 if group_id != None:
6260 self.group_id = group_id
6261 else:
6262 self.group_id = 0
6263 if buckets != None:
6264 self.buckets = buckets
6265 else:
6266 self.buckets = []
Rich Lane7dcdf022013-12-11 14:45:27 -08006267 return
Rich Lane7b0f2012013-11-22 14:15:26 -08006268
6269 def pack(self):
6270 packed = []
6271 packed.append(struct.pack("!B", self.version))
6272 packed.append(struct.pack("!B", self.type))
6273 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6274 packed.append(struct.pack("!L", self.xid))
6275 packed.append(struct.pack("!H", self.command))
6276 packed.append(struct.pack("!B", self.group_type))
6277 packed.append('\x00' * 1)
6278 packed.append(struct.pack("!L", self.group_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08006279 packed.append(loxi.generic_util.pack_list(self.buckets))
Rich Lane7b0f2012013-11-22 14:15:26 -08006280 length = sum([len(x) for x in packed])
6281 packed[2] = struct.pack("!H", length)
6282 return ''.join(packed)
6283
6284 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006285 def unpack(reader):
Rich Lane7b0f2012013-11-22 14:15:26 -08006286 obj = group_modify()
Rich Lane7b0f2012013-11-22 14:15:26 -08006287 _version = reader.read("!B")[0]
6288 assert(_version == 3)
6289 _type = reader.read("!B")[0]
6290 assert(_type == 15)
6291 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006292 orig_reader = reader
6293 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane7b0f2012013-11-22 14:15:26 -08006294 obj.xid = reader.read("!L")[0]
6295 _command = reader.read("!H")[0]
6296 assert(_command == 1)
6297 obj.group_type = reader.read("!B")[0]
6298 reader.skip(1)
6299 obj.group_id = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006300 obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack)
Rich Lane7b0f2012013-11-22 14:15:26 -08006301 return obj
6302
6303 def __eq__(self, other):
6304 if type(self) != type(other): return False
Rich Lane7b0f2012013-11-22 14:15:26 -08006305 if self.xid != other.xid: return False
6306 if self.group_type != other.group_type: return False
6307 if self.group_id != other.group_id: return False
6308 if self.buckets != other.buckets: return False
6309 return True
6310
Rich Lane7b0f2012013-11-22 14:15:26 -08006311 def pretty_print(self, q):
6312 q.text("group_modify {")
6313 with q.group():
6314 with q.indent(2):
6315 q.breakable()
6316 q.text("xid = ");
6317 if self.xid != None:
6318 q.text("%#x" % self.xid)
6319 else:
6320 q.text('None')
6321 q.text(","); q.breakable()
6322 q.text("group_type = ");
6323 q.text("%#x" % self.group_type)
6324 q.text(","); q.breakable()
6325 q.text("group_id = ");
6326 q.text("%#x" % self.group_id)
6327 q.text(","); q.breakable()
6328 q.text("buckets = ");
6329 q.pp(self.buckets)
6330 q.breakable()
6331 q.text('}')
6332
Rich Lane7dcdf022013-12-11 14:45:27 -08006333group_mod.subtypes[1] = group_modify
6334
6335class group_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07006336 version = 3
6337 type = 19
6338 stats_type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07006339
6340 def __init__(self, xid=None, flags=None, entries=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 flags != None:
6346 self.flags = flags
6347 else:
6348 self.flags = 0
6349 if entries != None:
6350 self.entries = entries
6351 else:
6352 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08006353 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006354
6355 def pack(self):
6356 packed = []
6357 packed.append(struct.pack("!B", self.version))
6358 packed.append(struct.pack("!B", self.type))
6359 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6360 packed.append(struct.pack("!L", self.xid))
6361 packed.append(struct.pack("!H", self.stats_type))
6362 packed.append(struct.pack("!H", self.flags))
6363 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08006364 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006365 length = sum([len(x) for x in packed])
6366 packed[2] = struct.pack("!H", length)
6367 return ''.join(packed)
6368
6369 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006370 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006371 obj = group_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07006372 _version = reader.read("!B")[0]
6373 assert(_version == 3)
6374 _type = reader.read("!B")[0]
6375 assert(_type == 19)
6376 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006377 orig_reader = reader
6378 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006379 obj.xid = reader.read("!L")[0]
6380 _stats_type = reader.read("!H")[0]
6381 assert(_stats_type == 6)
6382 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006383 reader.skip(4)
Rich Lane7dcdf022013-12-11 14:45:27 -08006384 obj.entries = loxi.generic_util.unpack_list(reader, common.group_stats_entry.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006385 return obj
6386
6387 def __eq__(self, other):
6388 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006389 if self.xid != other.xid: return False
6390 if self.flags != other.flags: return False
6391 if self.entries != other.entries: return False
6392 return True
6393
Rich Lanec2ee4b82013-04-24 17:12:38 -07006394 def pretty_print(self, q):
6395 q.text("group_stats_reply {")
6396 with q.group():
6397 with q.indent(2):
6398 q.breakable()
6399 q.text("xid = ");
6400 if self.xid != None:
6401 q.text("%#x" % self.xid)
6402 else:
6403 q.text('None')
6404 q.text(","); q.breakable()
6405 q.text("flags = ");
6406 q.text("%#x" % self.flags)
6407 q.text(","); q.breakable()
6408 q.text("entries = ");
6409 q.pp(self.entries)
6410 q.breakable()
6411 q.text('}')
6412
Rich Lane7dcdf022013-12-11 14:45:27 -08006413stats_reply.subtypes[6] = group_stats_reply
6414
6415class group_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07006416 version = 3
6417 type = 18
6418 stats_type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07006419
6420 def __init__(self, xid=None, flags=None, group_id=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006421 if xid != None:
6422 self.xid = xid
6423 else:
6424 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006425 if flags != None:
6426 self.flags = flags
6427 else:
6428 self.flags = 0
6429 if group_id != None:
6430 self.group_id = group_id
6431 else:
6432 self.group_id = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08006433 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006434
6435 def pack(self):
6436 packed = []
6437 packed.append(struct.pack("!B", self.version))
6438 packed.append(struct.pack("!B", self.type))
6439 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6440 packed.append(struct.pack("!L", self.xid))
6441 packed.append(struct.pack("!H", self.stats_type))
6442 packed.append(struct.pack("!H", self.flags))
6443 packed.append('\x00' * 4)
6444 packed.append(struct.pack("!L", self.group_id))
6445 packed.append('\x00' * 4)
6446 length = sum([len(x) for x in packed])
6447 packed[2] = struct.pack("!H", length)
6448 return ''.join(packed)
6449
6450 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006451 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006452 obj = group_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07006453 _version = reader.read("!B")[0]
6454 assert(_version == 3)
6455 _type = reader.read("!B")[0]
6456 assert(_type == 18)
6457 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006458 orig_reader = reader
6459 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006460 obj.xid = reader.read("!L")[0]
6461 _stats_type = reader.read("!H")[0]
6462 assert(_stats_type == 6)
6463 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006464 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07006465 obj.group_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006466 reader.skip(4)
6467 return obj
6468
6469 def __eq__(self, other):
6470 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006471 if self.xid != other.xid: return False
6472 if self.flags != other.flags: return False
6473 if self.group_id != other.group_id: return False
6474 return True
6475
Rich Lanec2ee4b82013-04-24 17:12:38 -07006476 def pretty_print(self, q):
6477 q.text("group_stats_request {")
6478 with q.group():
6479 with q.indent(2):
6480 q.breakable()
6481 q.text("xid = ");
6482 if self.xid != None:
6483 q.text("%#x" % self.xid)
6484 else:
6485 q.text('None')
6486 q.text(","); q.breakable()
6487 q.text("flags = ");
6488 q.text("%#x" % self.flags)
6489 q.text(","); q.breakable()
6490 q.text("group_id = ");
6491 q.text("%#x" % self.group_id)
6492 q.breakable()
6493 q.text('}')
6494
Rich Lane7dcdf022013-12-11 14:45:27 -08006495stats_request.subtypes[6] = group_stats_request
6496
6497class hello(message):
Dan Talaycof6202252013-07-02 01:00:29 -07006498 version = 3
6499 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07006500
6501 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006502 if xid != None:
6503 self.xid = xid
6504 else:
6505 self.xid = None
6506 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006507
6508 def pack(self):
6509 packed = []
6510 packed.append(struct.pack("!B", self.version))
6511 packed.append(struct.pack("!B", self.type))
6512 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6513 packed.append(struct.pack("!L", self.xid))
6514 length = sum([len(x) for x in packed])
6515 packed[2] = struct.pack("!H", length)
6516 return ''.join(packed)
6517
6518 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006519 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006520 obj = hello()
Dan Talaycof6202252013-07-02 01:00:29 -07006521 _version = reader.read("!B")[0]
6522 assert(_version == 3)
6523 _type = reader.read("!B")[0]
6524 assert(_type == 0)
6525 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006526 orig_reader = reader
6527 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006528 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006529 return obj
6530
6531 def __eq__(self, other):
6532 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006533 if self.xid != other.xid: return False
6534 return True
6535
Rich Lanec2ee4b82013-04-24 17:12:38 -07006536 def pretty_print(self, q):
6537 q.text("hello {")
6538 with q.group():
6539 with q.indent(2):
6540 q.breakable()
6541 q.text("xid = ");
6542 if self.xid != None:
6543 q.text("%#x" % self.xid)
6544 else:
6545 q.text('None')
6546 q.breakable()
6547 q.text('}')
6548
Rich Lane7dcdf022013-12-11 14:45:27 -08006549message.subtypes[0] = hello
6550
6551class hello_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07006552 version = 3
6553 type = 1
6554 err_type = 0
6555
6556 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006557 if xid != None:
6558 self.xid = xid
6559 else:
6560 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07006561 if code != None:
6562 self.code = code
6563 else:
6564 self.code = 0
6565 if data != None:
6566 self.data = data
6567 else:
6568 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08006569 return
Rich Lane6f4978c2013-10-20 21:33:52 -07006570
6571 def pack(self):
6572 packed = []
6573 packed.append(struct.pack("!B", self.version))
6574 packed.append(struct.pack("!B", self.type))
6575 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6576 packed.append(struct.pack("!L", self.xid))
6577 packed.append(struct.pack("!H", self.err_type))
6578 packed.append(struct.pack("!H", self.code))
6579 packed.append(self.data)
6580 length = sum([len(x) for x in packed])
6581 packed[2] = struct.pack("!H", length)
6582 return ''.join(packed)
6583
6584 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006585 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07006586 obj = hello_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07006587 _version = reader.read("!B")[0]
6588 assert(_version == 3)
6589 _type = reader.read("!B")[0]
6590 assert(_type == 1)
6591 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006592 orig_reader = reader
6593 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07006594 obj.xid = reader.read("!L")[0]
6595 _err_type = reader.read("!H")[0]
6596 assert(_err_type == 0)
6597 obj.code = reader.read("!H")[0]
6598 obj.data = str(reader.read_all())
6599 return obj
6600
6601 def __eq__(self, other):
6602 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07006603 if self.xid != other.xid: return False
6604 if self.code != other.code: return False
6605 if self.data != other.data: return False
6606 return True
6607
Rich Lane6f4978c2013-10-20 21:33:52 -07006608 def pretty_print(self, q):
6609 q.text("hello_failed_error_msg {")
6610 with q.group():
6611 with q.indent(2):
6612 q.breakable()
6613 q.text("xid = ");
6614 if self.xid != None:
6615 q.text("%#x" % self.xid)
6616 else:
6617 q.text('None')
6618 q.text(","); q.breakable()
6619 q.text("code = ");
6620 q.text("%#x" % self.code)
6621 q.text(","); q.breakable()
6622 q.text("data = ");
6623 q.pp(self.data)
6624 q.breakable()
6625 q.text('}')
6626
Rich Lane7dcdf022013-12-11 14:45:27 -08006627error_msg.subtypes[0] = hello_failed_error_msg
6628
6629class nicira_header(experimenter):
6630 subtypes = {}
6631
Rich Lane95f7fc92014-01-27 17:08:16 -08006632 version = 3
6633 type = 4
6634 experimenter = 8992
6635
6636 def __init__(self, xid=None, subtype=None):
6637 if xid != None:
6638 self.xid = xid
6639 else:
6640 self.xid = None
6641 if subtype != None:
6642 self.subtype = subtype
6643 else:
6644 self.subtype = 0
6645 return
6646
6647 def pack(self):
6648 packed = []
6649 packed.append(struct.pack("!B", self.version))
6650 packed.append(struct.pack("!B", self.type))
6651 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6652 packed.append(struct.pack("!L", self.xid))
6653 packed.append(struct.pack("!L", self.experimenter))
6654 packed.append(struct.pack("!L", self.subtype))
6655 length = sum([len(x) for x in packed])
6656 packed[2] = struct.pack("!H", length)
6657 return ''.join(packed)
6658
Rich Lane7dcdf022013-12-11 14:45:27 -08006659 @staticmethod
6660 def unpack(reader):
6661 subtype, = reader.peek('!L', 12)
Rich Lane95f7fc92014-01-27 17:08:16 -08006662 subclass = nicira_header.subtypes.get(subtype)
6663 if subclass:
6664 return subclass.unpack(reader)
6665
6666 obj = nicira_header()
6667 _version = reader.read("!B")[0]
6668 assert(_version == 3)
6669 _type = reader.read("!B")[0]
6670 assert(_type == 4)
6671 _length = reader.read("!H")[0]
6672 orig_reader = reader
6673 reader = orig_reader.slice(_length - (2 + 2))
6674 obj.xid = reader.read("!L")[0]
6675 _experimenter = reader.read("!L")[0]
6676 assert(_experimenter == 8992)
6677 obj.subtype = reader.read("!L")[0]
6678 return obj
6679
6680 def __eq__(self, other):
6681 if type(self) != type(other): return False
6682 if self.xid != other.xid: return False
6683 if self.subtype != other.subtype: return False
6684 return True
6685
6686 def pretty_print(self, q):
6687 q.text("nicira_header {")
6688 with q.group():
6689 with q.indent(2):
6690 q.breakable()
6691 q.text("xid = ");
6692 if self.xid != None:
6693 q.text("%#x" % self.xid)
6694 else:
6695 q.text('None')
6696 q.breakable()
6697 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08006698
6699experimenter.subtypes[8992] = nicira_header
6700
6701class packet_in(message):
Dan Talaycof6202252013-07-02 01:00:29 -07006702 version = 3
6703 type = 10
Rich Lanec2ee4b82013-04-24 17:12:38 -07006704
6705 def __init__(self, xid=None, buffer_id=None, total_len=None, reason=None, table_id=None, match=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006706 if xid != None:
6707 self.xid = xid
6708 else:
6709 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006710 if buffer_id != None:
6711 self.buffer_id = buffer_id
6712 else:
6713 self.buffer_id = 0
6714 if total_len != None:
6715 self.total_len = total_len
6716 else:
6717 self.total_len = 0
6718 if reason != None:
6719 self.reason = reason
6720 else:
6721 self.reason = 0
6722 if table_id != None:
6723 self.table_id = table_id
6724 else:
6725 self.table_id = 0
6726 if match != None:
6727 self.match = match
6728 else:
6729 self.match = common.match()
6730 if data != None:
6731 self.data = data
6732 else:
Dan Talaycof6202252013-07-02 01:00:29 -07006733 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08006734 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006735
6736 def pack(self):
6737 packed = []
6738 packed.append(struct.pack("!B", self.version))
6739 packed.append(struct.pack("!B", self.type))
6740 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6741 packed.append(struct.pack("!L", self.xid))
6742 packed.append(struct.pack("!L", self.buffer_id))
6743 packed.append(struct.pack("!H", self.total_len))
6744 packed.append(struct.pack("!B", self.reason))
6745 packed.append(struct.pack("!B", self.table_id))
6746 packed.append(self.match.pack())
6747 packed.append('\x00' * 2)
6748 packed.append(self.data)
6749 length = sum([len(x) for x in packed])
6750 packed[2] = struct.pack("!H", length)
6751 return ''.join(packed)
6752
6753 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006754 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006755 obj = packet_in()
Dan Talaycof6202252013-07-02 01:00:29 -07006756 _version = reader.read("!B")[0]
6757 assert(_version == 3)
6758 _type = reader.read("!B")[0]
6759 assert(_type == 10)
6760 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006761 orig_reader = reader
6762 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006763 obj.xid = reader.read("!L")[0]
6764 obj.buffer_id = reader.read("!L")[0]
6765 obj.total_len = reader.read("!H")[0]
6766 obj.reason = reader.read("!B")[0]
6767 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006768 obj.match = common.match.unpack(reader)
6769 reader.skip(2)
6770 obj.data = str(reader.read_all())
6771 return obj
6772
6773 def __eq__(self, other):
6774 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006775 if self.xid != other.xid: return False
6776 if self.buffer_id != other.buffer_id: return False
6777 if self.total_len != other.total_len: return False
6778 if self.reason != other.reason: return False
6779 if self.table_id != other.table_id: return False
6780 if self.match != other.match: return False
6781 if self.data != other.data: return False
6782 return True
6783
Rich Lanec2ee4b82013-04-24 17:12:38 -07006784 def pretty_print(self, q):
6785 q.text("packet_in {")
6786 with q.group():
6787 with q.indent(2):
6788 q.breakable()
6789 q.text("xid = ");
6790 if self.xid != None:
6791 q.text("%#x" % self.xid)
6792 else:
6793 q.text('None')
6794 q.text(","); q.breakable()
6795 q.text("buffer_id = ");
6796 q.text("%#x" % self.buffer_id)
6797 q.text(","); q.breakable()
6798 q.text("total_len = ");
6799 q.text("%#x" % self.total_len)
6800 q.text(","); q.breakable()
6801 q.text("reason = ");
6802 q.text("%#x" % self.reason)
6803 q.text(","); q.breakable()
6804 q.text("table_id = ");
6805 q.text("%#x" % self.table_id)
6806 q.text(","); q.breakable()
6807 q.text("match = ");
6808 q.pp(self.match)
6809 q.text(","); q.breakable()
6810 q.text("data = ");
6811 q.pp(self.data)
6812 q.breakable()
6813 q.text('}')
6814
Rich Lane7dcdf022013-12-11 14:45:27 -08006815message.subtypes[10] = packet_in
6816
6817class packet_out(message):
Dan Talaycof6202252013-07-02 01:00:29 -07006818 version = 3
6819 type = 13
Rich Lanec2ee4b82013-04-24 17:12:38 -07006820
6821 def __init__(self, xid=None, buffer_id=None, in_port=None, actions=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006822 if xid != None:
6823 self.xid = xid
6824 else:
6825 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006826 if buffer_id != None:
6827 self.buffer_id = buffer_id
6828 else:
6829 self.buffer_id = 0
6830 if in_port != None:
6831 self.in_port = in_port
6832 else:
6833 self.in_port = 0
6834 if actions != None:
6835 self.actions = actions
6836 else:
6837 self.actions = []
6838 if data != None:
6839 self.data = data
6840 else:
Dan Talaycof6202252013-07-02 01:00:29 -07006841 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08006842 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006843
6844 def pack(self):
6845 packed = []
6846 packed.append(struct.pack("!B", self.version))
6847 packed.append(struct.pack("!B", self.type))
6848 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6849 packed.append(struct.pack("!L", self.xid))
6850 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07006851 packed.append(util.pack_port_no(self.in_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006852 packed.append(struct.pack("!H", 0)) # placeholder for actions_len at index 6
6853 packed.append('\x00' * 6)
Rich Lane7dcdf022013-12-11 14:45:27 -08006854 packed.append(loxi.generic_util.pack_list(self.actions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006855 packed[6] = struct.pack("!H", len(packed[-1]))
6856 packed.append(self.data)
6857 length = sum([len(x) for x in packed])
6858 packed[2] = struct.pack("!H", length)
6859 return ''.join(packed)
6860
6861 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006862 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006863 obj = packet_out()
Dan Talaycof6202252013-07-02 01:00:29 -07006864 _version = reader.read("!B")[0]
6865 assert(_version == 3)
6866 _type = reader.read("!B")[0]
6867 assert(_type == 13)
6868 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006869 orig_reader = reader
6870 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006871 obj.xid = reader.read("!L")[0]
6872 obj.buffer_id = reader.read("!L")[0]
6873 obj.in_port = util.unpack_port_no(reader)
6874 _actions_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006875 reader.skip(6)
Rich Lane7dcdf022013-12-11 14:45:27 -08006876 obj.actions = loxi.generic_util.unpack_list(reader.slice(_actions_len), action.action.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006877 obj.data = str(reader.read_all())
6878 return obj
6879
6880 def __eq__(self, other):
6881 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006882 if self.xid != other.xid: return False
6883 if self.buffer_id != other.buffer_id: return False
6884 if self.in_port != other.in_port: return False
6885 if self.actions != other.actions: return False
6886 if self.data != other.data: return False
6887 return True
6888
Rich Lanec2ee4b82013-04-24 17:12:38 -07006889 def pretty_print(self, q):
6890 q.text("packet_out {")
6891 with q.group():
6892 with q.indent(2):
6893 q.breakable()
6894 q.text("xid = ");
6895 if self.xid != None:
6896 q.text("%#x" % self.xid)
6897 else:
6898 q.text('None')
6899 q.text(","); q.breakable()
6900 q.text("buffer_id = ");
6901 q.text("%#x" % self.buffer_id)
6902 q.text(","); q.breakable()
6903 q.text("in_port = ");
6904 q.text(util.pretty_port(self.in_port))
6905 q.text(","); q.breakable()
6906 q.text("actions = ");
6907 q.pp(self.actions)
6908 q.text(","); q.breakable()
6909 q.text("data = ");
6910 q.pp(self.data)
6911 q.breakable()
6912 q.text('}')
6913
Rich Lane7dcdf022013-12-11 14:45:27 -08006914message.subtypes[13] = packet_out
6915
6916class port_mod(message):
Dan Talaycof6202252013-07-02 01:00:29 -07006917 version = 3
6918 type = 16
Rich Lanec2ee4b82013-04-24 17:12:38 -07006919
6920 def __init__(self, xid=None, port_no=None, hw_addr=None, config=None, mask=None, advertise=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006921 if xid != None:
6922 self.xid = xid
6923 else:
6924 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006925 if port_no != None:
6926 self.port_no = port_no
6927 else:
6928 self.port_no = 0
6929 if hw_addr != None:
6930 self.hw_addr = hw_addr
6931 else:
6932 self.hw_addr = [0,0,0,0,0,0]
6933 if config != None:
6934 self.config = config
6935 else:
6936 self.config = 0
6937 if mask != None:
6938 self.mask = mask
6939 else:
6940 self.mask = 0
6941 if advertise != None:
6942 self.advertise = advertise
6943 else:
6944 self.advertise = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08006945 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006946
6947 def pack(self):
6948 packed = []
6949 packed.append(struct.pack("!B", self.version))
6950 packed.append(struct.pack("!B", self.type))
6951 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6952 packed.append(struct.pack("!L", self.xid))
Dan Talaycof6202252013-07-02 01:00:29 -07006953 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006954 packed.append('\x00' * 4)
6955 packed.append(struct.pack("!6B", *self.hw_addr))
6956 packed.append('\x00' * 2)
6957 packed.append(struct.pack("!L", self.config))
6958 packed.append(struct.pack("!L", self.mask))
6959 packed.append(struct.pack("!L", self.advertise))
6960 packed.append('\x00' * 4)
6961 length = sum([len(x) for x in packed])
6962 packed[2] = struct.pack("!H", length)
6963 return ''.join(packed)
6964
6965 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006966 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006967 obj = port_mod()
Dan Talaycof6202252013-07-02 01:00:29 -07006968 _version = reader.read("!B")[0]
6969 assert(_version == 3)
6970 _type = reader.read("!B")[0]
6971 assert(_type == 16)
6972 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006973 orig_reader = reader
6974 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006975 obj.xid = reader.read("!L")[0]
6976 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006977 reader.skip(4)
6978 obj.hw_addr = list(reader.read('!6B'))
6979 reader.skip(2)
Dan Talaycof6202252013-07-02 01:00:29 -07006980 obj.config = reader.read("!L")[0]
6981 obj.mask = reader.read("!L")[0]
6982 obj.advertise = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006983 reader.skip(4)
6984 return obj
6985
6986 def __eq__(self, other):
6987 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006988 if self.xid != other.xid: return False
6989 if self.port_no != other.port_no: return False
6990 if self.hw_addr != other.hw_addr: return False
6991 if self.config != other.config: return False
6992 if self.mask != other.mask: return False
6993 if self.advertise != other.advertise: return False
6994 return True
6995
Rich Lanec2ee4b82013-04-24 17:12:38 -07006996 def pretty_print(self, q):
6997 q.text("port_mod {")
6998 with q.group():
6999 with q.indent(2):
7000 q.breakable()
7001 q.text("xid = ");
7002 if self.xid != None:
7003 q.text("%#x" % self.xid)
7004 else:
7005 q.text('None')
7006 q.text(","); q.breakable()
7007 q.text("port_no = ");
7008 q.text(util.pretty_port(self.port_no))
7009 q.text(","); q.breakable()
7010 q.text("hw_addr = ");
7011 q.text(util.pretty_mac(self.hw_addr))
7012 q.text(","); q.breakable()
7013 q.text("config = ");
7014 q.text("%#x" % self.config)
7015 q.text(","); q.breakable()
7016 q.text("mask = ");
7017 q.text("%#x" % self.mask)
7018 q.text(","); q.breakable()
7019 q.text("advertise = ");
7020 q.text("%#x" % self.advertise)
7021 q.breakable()
7022 q.text('}')
7023
Rich Lane7dcdf022013-12-11 14:45:27 -08007024message.subtypes[16] = port_mod
7025
7026class port_mod_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07007027 version = 3
7028 type = 1
7029 err_type = 7
7030
7031 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007032 if xid != None:
7033 self.xid = xid
7034 else:
7035 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07007036 if code != None:
7037 self.code = code
7038 else:
7039 self.code = 0
7040 if data != None:
7041 self.data = data
7042 else:
7043 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08007044 return
Rich Lane6f4978c2013-10-20 21:33:52 -07007045
7046 def pack(self):
7047 packed = []
7048 packed.append(struct.pack("!B", self.version))
7049 packed.append(struct.pack("!B", self.type))
7050 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7051 packed.append(struct.pack("!L", self.xid))
7052 packed.append(struct.pack("!H", self.err_type))
7053 packed.append(struct.pack("!H", self.code))
7054 packed.append(self.data)
7055 length = sum([len(x) for x in packed])
7056 packed[2] = struct.pack("!H", length)
7057 return ''.join(packed)
7058
7059 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007060 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07007061 obj = port_mod_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07007062 _version = reader.read("!B")[0]
7063 assert(_version == 3)
7064 _type = reader.read("!B")[0]
7065 assert(_type == 1)
7066 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007067 orig_reader = reader
7068 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07007069 obj.xid = reader.read("!L")[0]
7070 _err_type = reader.read("!H")[0]
7071 assert(_err_type == 7)
7072 obj.code = reader.read("!H")[0]
7073 obj.data = str(reader.read_all())
7074 return obj
7075
7076 def __eq__(self, other):
7077 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07007078 if self.xid != other.xid: return False
7079 if self.code != other.code: return False
7080 if self.data != other.data: return False
7081 return True
7082
Rich Lane6f4978c2013-10-20 21:33:52 -07007083 def pretty_print(self, q):
7084 q.text("port_mod_failed_error_msg {")
7085 with q.group():
7086 with q.indent(2):
7087 q.breakable()
7088 q.text("xid = ");
7089 if self.xid != None:
7090 q.text("%#x" % self.xid)
7091 else:
7092 q.text('None')
7093 q.text(","); q.breakable()
7094 q.text("code = ");
7095 q.text("%#x" % self.code)
7096 q.text(","); q.breakable()
7097 q.text("data = ");
7098 q.pp(self.data)
7099 q.breakable()
7100 q.text('}')
7101
Rich Lane7dcdf022013-12-11 14:45:27 -08007102error_msg.subtypes[7] = port_mod_failed_error_msg
7103
7104class port_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07007105 version = 3
7106 type = 19
7107 stats_type = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07007108
7109 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007110 if xid != None:
7111 self.xid = xid
7112 else:
7113 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007114 if flags != None:
7115 self.flags = flags
7116 else:
7117 self.flags = 0
7118 if entries != None:
7119 self.entries = entries
7120 else:
7121 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08007122 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007123
7124 def pack(self):
7125 packed = []
7126 packed.append(struct.pack("!B", self.version))
7127 packed.append(struct.pack("!B", self.type))
7128 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7129 packed.append(struct.pack("!L", self.xid))
7130 packed.append(struct.pack("!H", self.stats_type))
7131 packed.append(struct.pack("!H", self.flags))
7132 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08007133 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007134 length = sum([len(x) for x in packed])
7135 packed[2] = struct.pack("!H", length)
7136 return ''.join(packed)
7137
7138 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007139 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007140 obj = port_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07007141 _version = reader.read("!B")[0]
7142 assert(_version == 3)
7143 _type = reader.read("!B")[0]
7144 assert(_type == 19)
7145 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007146 orig_reader = reader
7147 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07007148 obj.xid = reader.read("!L")[0]
7149 _stats_type = reader.read("!H")[0]
7150 assert(_stats_type == 4)
7151 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007152 reader.skip(4)
7153 obj.entries = loxi.generic_util.unpack_list(reader, common.port_stats_entry.unpack)
7154 return obj
7155
7156 def __eq__(self, other):
7157 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007158 if self.xid != other.xid: return False
7159 if self.flags != other.flags: return False
7160 if self.entries != other.entries: return False
7161 return True
7162
Rich Lanec2ee4b82013-04-24 17:12:38 -07007163 def pretty_print(self, q):
7164 q.text("port_stats_reply {")
7165 with q.group():
7166 with q.indent(2):
7167 q.breakable()
7168 q.text("xid = ");
7169 if self.xid != None:
7170 q.text("%#x" % self.xid)
7171 else:
7172 q.text('None')
7173 q.text(","); q.breakable()
7174 q.text("flags = ");
7175 q.text("%#x" % self.flags)
7176 q.text(","); q.breakable()
7177 q.text("entries = ");
7178 q.pp(self.entries)
7179 q.breakable()
7180 q.text('}')
7181
Rich Lane7dcdf022013-12-11 14:45:27 -08007182stats_reply.subtypes[4] = port_stats_reply
7183
7184class port_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07007185 version = 3
7186 type = 18
7187 stats_type = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07007188
7189 def __init__(self, xid=None, flags=None, port_no=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007190 if xid != None:
7191 self.xid = xid
7192 else:
7193 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007194 if flags != None:
7195 self.flags = flags
7196 else:
7197 self.flags = 0
7198 if port_no != None:
7199 self.port_no = port_no
7200 else:
7201 self.port_no = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08007202 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007203
7204 def pack(self):
7205 packed = []
7206 packed.append(struct.pack("!B", self.version))
7207 packed.append(struct.pack("!B", self.type))
7208 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7209 packed.append(struct.pack("!L", self.xid))
7210 packed.append(struct.pack("!H", self.stats_type))
7211 packed.append(struct.pack("!H", self.flags))
7212 packed.append('\x00' * 4)
Dan Talaycof6202252013-07-02 01:00:29 -07007213 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007214 packed.append('\x00' * 4)
7215 length = sum([len(x) for x in packed])
7216 packed[2] = struct.pack("!H", length)
7217 return ''.join(packed)
7218
7219 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007220 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007221 obj = port_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07007222 _version = reader.read("!B")[0]
7223 assert(_version == 3)
7224 _type = reader.read("!B")[0]
7225 assert(_type == 18)
7226 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007227 orig_reader = reader
7228 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07007229 obj.xid = reader.read("!L")[0]
7230 _stats_type = reader.read("!H")[0]
7231 assert(_stats_type == 4)
7232 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007233 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07007234 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07007235 reader.skip(4)
7236 return obj
7237
7238 def __eq__(self, other):
7239 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007240 if self.xid != other.xid: return False
7241 if self.flags != other.flags: return False
7242 if self.port_no != other.port_no: return False
7243 return True
7244
Rich Lanec2ee4b82013-04-24 17:12:38 -07007245 def pretty_print(self, q):
7246 q.text("port_stats_request {")
7247 with q.group():
7248 with q.indent(2):
7249 q.breakable()
7250 q.text("xid = ");
7251 if self.xid != None:
7252 q.text("%#x" % self.xid)
7253 else:
7254 q.text('None')
7255 q.text(","); q.breakable()
7256 q.text("flags = ");
7257 q.text("%#x" % self.flags)
7258 q.text(","); q.breakable()
7259 q.text("port_no = ");
7260 q.text(util.pretty_port(self.port_no))
7261 q.breakable()
7262 q.text('}')
7263
Rich Lane7dcdf022013-12-11 14:45:27 -08007264stats_request.subtypes[4] = port_stats_request
7265
7266class port_status(message):
Dan Talaycof6202252013-07-02 01:00:29 -07007267 version = 3
7268 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -07007269
7270 def __init__(self, xid=None, reason=None, desc=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007271 if xid != None:
7272 self.xid = xid
7273 else:
7274 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007275 if reason != None:
7276 self.reason = reason
7277 else:
7278 self.reason = 0
7279 if desc != None:
7280 self.desc = desc
7281 else:
7282 self.desc = common.port_desc()
Rich Lane7dcdf022013-12-11 14:45:27 -08007283 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007284
7285 def pack(self):
7286 packed = []
7287 packed.append(struct.pack("!B", self.version))
7288 packed.append(struct.pack("!B", self.type))
7289 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7290 packed.append(struct.pack("!L", self.xid))
7291 packed.append(struct.pack("!B", self.reason))
7292 packed.append('\x00' * 7)
7293 packed.append(self.desc.pack())
7294 length = sum([len(x) for x in packed])
7295 packed[2] = struct.pack("!H", length)
7296 return ''.join(packed)
7297
7298 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007299 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007300 obj = port_status()
Dan Talaycof6202252013-07-02 01:00:29 -07007301 _version = reader.read("!B")[0]
7302 assert(_version == 3)
7303 _type = reader.read("!B")[0]
7304 assert(_type == 12)
7305 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007306 orig_reader = reader
7307 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07007308 obj.xid = reader.read("!L")[0]
7309 obj.reason = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007310 reader.skip(7)
7311 obj.desc = common.port_desc.unpack(reader)
7312 return obj
7313
7314 def __eq__(self, other):
7315 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007316 if self.xid != other.xid: return False
7317 if self.reason != other.reason: return False
7318 if self.desc != other.desc: return False
7319 return True
7320
Rich Lanec2ee4b82013-04-24 17:12:38 -07007321 def pretty_print(self, q):
7322 q.text("port_status {")
7323 with q.group():
7324 with q.indent(2):
7325 q.breakable()
7326 q.text("xid = ");
7327 if self.xid != None:
7328 q.text("%#x" % self.xid)
7329 else:
7330 q.text('None')
7331 q.text(","); q.breakable()
7332 q.text("reason = ");
7333 q.text("%#x" % self.reason)
7334 q.text(","); q.breakable()
7335 q.text("desc = ");
7336 q.pp(self.desc)
7337 q.breakable()
7338 q.text('}')
7339
Rich Lane7dcdf022013-12-11 14:45:27 -08007340message.subtypes[12] = port_status
7341
7342class queue_get_config_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -07007343 version = 3
7344 type = 23
Rich Lanec2ee4b82013-04-24 17:12:38 -07007345
7346 def __init__(self, xid=None, port=None, queues=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007347 if xid != None:
7348 self.xid = xid
7349 else:
7350 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007351 if port != None:
7352 self.port = port
7353 else:
7354 self.port = 0
7355 if queues != None:
7356 self.queues = queues
7357 else:
7358 self.queues = []
Rich Lane7dcdf022013-12-11 14:45:27 -08007359 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007360
7361 def pack(self):
7362 packed = []
7363 packed.append(struct.pack("!B", self.version))
7364 packed.append(struct.pack("!B", self.type))
7365 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7366 packed.append(struct.pack("!L", self.xid))
Dan Talaycof6202252013-07-02 01:00:29 -07007367 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007368 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08007369 packed.append(loxi.generic_util.pack_list(self.queues))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007370 length = sum([len(x) for x in packed])
7371 packed[2] = struct.pack("!H", length)
7372 return ''.join(packed)
7373
7374 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007375 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007376 obj = queue_get_config_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07007377 _version = reader.read("!B")[0]
7378 assert(_version == 3)
7379 _type = reader.read("!B")[0]
7380 assert(_type == 23)
7381 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007382 orig_reader = reader
7383 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07007384 obj.xid = reader.read("!L")[0]
7385 obj.port = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07007386 reader.skip(4)
Rich Lane7dcdf022013-12-11 14:45:27 -08007387 obj.queues = loxi.generic_util.unpack_list(reader, common.packet_queue.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07007388 return obj
7389
7390 def __eq__(self, other):
7391 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007392 if self.xid != other.xid: return False
7393 if self.port != other.port: return False
7394 if self.queues != other.queues: return False
7395 return True
7396
Rich Lanec2ee4b82013-04-24 17:12:38 -07007397 def pretty_print(self, q):
7398 q.text("queue_get_config_reply {")
7399 with q.group():
7400 with q.indent(2):
7401 q.breakable()
7402 q.text("xid = ");
7403 if self.xid != None:
7404 q.text("%#x" % self.xid)
7405 else:
7406 q.text('None')
7407 q.text(","); q.breakable()
7408 q.text("port = ");
7409 q.text(util.pretty_port(self.port))
7410 q.text(","); q.breakable()
7411 q.text("queues = ");
7412 q.pp(self.queues)
7413 q.breakable()
7414 q.text('}')
7415
Rich Lane7dcdf022013-12-11 14:45:27 -08007416message.subtypes[23] = queue_get_config_reply
7417
7418class queue_get_config_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -07007419 version = 3
7420 type = 22
Rich Lanec2ee4b82013-04-24 17:12:38 -07007421
7422 def __init__(self, xid=None, port=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007423 if xid != None:
7424 self.xid = xid
7425 else:
7426 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007427 if port != None:
7428 self.port = port
7429 else:
7430 self.port = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08007431 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007432
7433 def pack(self):
7434 packed = []
7435 packed.append(struct.pack("!B", self.version))
7436 packed.append(struct.pack("!B", self.type))
7437 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7438 packed.append(struct.pack("!L", self.xid))
Dan Talaycof6202252013-07-02 01:00:29 -07007439 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007440 packed.append('\x00' * 4)
7441 length = sum([len(x) for x in packed])
7442 packed[2] = struct.pack("!H", length)
7443 return ''.join(packed)
7444
7445 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007446 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007447 obj = queue_get_config_request()
Dan Talaycof6202252013-07-02 01:00:29 -07007448 _version = reader.read("!B")[0]
7449 assert(_version == 3)
7450 _type = reader.read("!B")[0]
7451 assert(_type == 22)
7452 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007453 orig_reader = reader
7454 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07007455 obj.xid = reader.read("!L")[0]
7456 obj.port = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07007457 reader.skip(4)
7458 return obj
7459
7460 def __eq__(self, other):
7461 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007462 if self.xid != other.xid: return False
7463 if self.port != other.port: return False
7464 return True
7465
Rich Lanec2ee4b82013-04-24 17:12:38 -07007466 def pretty_print(self, q):
7467 q.text("queue_get_config_request {")
7468 with q.group():
7469 with q.indent(2):
7470 q.breakable()
7471 q.text("xid = ");
7472 if self.xid != None:
7473 q.text("%#x" % self.xid)
7474 else:
7475 q.text('None')
7476 q.text(","); q.breakable()
7477 q.text("port = ");
7478 q.text(util.pretty_port(self.port))
7479 q.breakable()
7480 q.text('}')
7481
Rich Lane7dcdf022013-12-11 14:45:27 -08007482message.subtypes[22] = queue_get_config_request
7483
7484class queue_op_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07007485 version = 3
7486 type = 1
7487 err_type = 9
7488
7489 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007490 if xid != None:
7491 self.xid = xid
7492 else:
7493 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07007494 if code != None:
7495 self.code = code
7496 else:
7497 self.code = 0
7498 if data != None:
7499 self.data = data
7500 else:
7501 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08007502 return
Rich Lane6f4978c2013-10-20 21:33:52 -07007503
7504 def pack(self):
7505 packed = []
7506 packed.append(struct.pack("!B", self.version))
7507 packed.append(struct.pack("!B", self.type))
7508 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7509 packed.append(struct.pack("!L", self.xid))
7510 packed.append(struct.pack("!H", self.err_type))
7511 packed.append(struct.pack("!H", self.code))
7512 packed.append(self.data)
7513 length = sum([len(x) for x in packed])
7514 packed[2] = struct.pack("!H", length)
7515 return ''.join(packed)
7516
7517 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007518 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07007519 obj = queue_op_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07007520 _version = reader.read("!B")[0]
7521 assert(_version == 3)
7522 _type = reader.read("!B")[0]
7523 assert(_type == 1)
7524 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007525 orig_reader = reader
7526 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07007527 obj.xid = reader.read("!L")[0]
7528 _err_type = reader.read("!H")[0]
7529 assert(_err_type == 9)
7530 obj.code = reader.read("!H")[0]
7531 obj.data = str(reader.read_all())
7532 return obj
7533
7534 def __eq__(self, other):
7535 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07007536 if self.xid != other.xid: return False
7537 if self.code != other.code: return False
7538 if self.data != other.data: return False
7539 return True
7540
Rich Lane6f4978c2013-10-20 21:33:52 -07007541 def pretty_print(self, q):
7542 q.text("queue_op_failed_error_msg {")
7543 with q.group():
7544 with q.indent(2):
7545 q.breakable()
7546 q.text("xid = ");
7547 if self.xid != None:
7548 q.text("%#x" % self.xid)
7549 else:
7550 q.text('None')
7551 q.text(","); q.breakable()
7552 q.text("code = ");
7553 q.text("%#x" % self.code)
7554 q.text(","); q.breakable()
7555 q.text("data = ");
7556 q.pp(self.data)
7557 q.breakable()
7558 q.text('}')
7559
Rich Lane7dcdf022013-12-11 14:45:27 -08007560error_msg.subtypes[9] = queue_op_failed_error_msg
7561
7562class queue_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07007563 version = 3
7564 type = 19
7565 stats_type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07007566
7567 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007568 if xid != None:
7569 self.xid = xid
7570 else:
7571 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007572 if flags != None:
7573 self.flags = flags
7574 else:
7575 self.flags = 0
7576 if entries != None:
7577 self.entries = entries
7578 else:
7579 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08007580 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007581
7582 def pack(self):
7583 packed = []
7584 packed.append(struct.pack("!B", self.version))
7585 packed.append(struct.pack("!B", self.type))
7586 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7587 packed.append(struct.pack("!L", self.xid))
7588 packed.append(struct.pack("!H", self.stats_type))
7589 packed.append(struct.pack("!H", self.flags))
7590 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08007591 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007592 length = sum([len(x) for x in packed])
7593 packed[2] = struct.pack("!H", length)
7594 return ''.join(packed)
7595
7596 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007597 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007598 obj = queue_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07007599 _version = reader.read("!B")[0]
7600 assert(_version == 3)
7601 _type = reader.read("!B")[0]
7602 assert(_type == 19)
7603 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007604 orig_reader = reader
7605 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07007606 obj.xid = reader.read("!L")[0]
7607 _stats_type = reader.read("!H")[0]
7608 assert(_stats_type == 5)
7609 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007610 reader.skip(4)
7611 obj.entries = loxi.generic_util.unpack_list(reader, common.queue_stats_entry.unpack)
7612 return obj
7613
7614 def __eq__(self, other):
7615 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007616 if self.xid != other.xid: return False
7617 if self.flags != other.flags: return False
7618 if self.entries != other.entries: return False
7619 return True
7620
Rich Lanec2ee4b82013-04-24 17:12:38 -07007621 def pretty_print(self, q):
7622 q.text("queue_stats_reply {")
7623 with q.group():
7624 with q.indent(2):
7625 q.breakable()
7626 q.text("xid = ");
7627 if self.xid != None:
7628 q.text("%#x" % self.xid)
7629 else:
7630 q.text('None')
7631 q.text(","); q.breakable()
7632 q.text("flags = ");
7633 q.text("%#x" % self.flags)
7634 q.text(","); q.breakable()
7635 q.text("entries = ");
7636 q.pp(self.entries)
7637 q.breakable()
7638 q.text('}')
7639
Rich Lane7dcdf022013-12-11 14:45:27 -08007640stats_reply.subtypes[5] = queue_stats_reply
7641
7642class queue_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07007643 version = 3
7644 type = 18
7645 stats_type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07007646
7647 def __init__(self, xid=None, flags=None, port_no=None, queue_id=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007648 if xid != None:
7649 self.xid = xid
7650 else:
7651 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007652 if flags != None:
7653 self.flags = flags
7654 else:
7655 self.flags = 0
7656 if port_no != None:
7657 self.port_no = port_no
7658 else:
7659 self.port_no = 0
7660 if queue_id != None:
7661 self.queue_id = queue_id
7662 else:
7663 self.queue_id = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08007664 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007665
7666 def pack(self):
7667 packed = []
7668 packed.append(struct.pack("!B", self.version))
7669 packed.append(struct.pack("!B", self.type))
7670 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7671 packed.append(struct.pack("!L", self.xid))
7672 packed.append(struct.pack("!H", self.stats_type))
7673 packed.append(struct.pack("!H", self.flags))
7674 packed.append('\x00' * 4)
Dan Talaycof6202252013-07-02 01:00:29 -07007675 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007676 packed.append(struct.pack("!L", self.queue_id))
7677 length = sum([len(x) for x in packed])
7678 packed[2] = struct.pack("!H", length)
7679 return ''.join(packed)
7680
7681 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007682 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007683 obj = queue_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07007684 _version = reader.read("!B")[0]
7685 assert(_version == 3)
7686 _type = reader.read("!B")[0]
7687 assert(_type == 18)
7688 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007689 orig_reader = reader
7690 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07007691 obj.xid = reader.read("!L")[0]
7692 _stats_type = reader.read("!H")[0]
7693 assert(_stats_type == 5)
7694 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007695 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07007696 obj.port_no = util.unpack_port_no(reader)
7697 obj.queue_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007698 return obj
7699
7700 def __eq__(self, other):
7701 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007702 if self.xid != other.xid: return False
7703 if self.flags != other.flags: return False
7704 if self.port_no != other.port_no: return False
7705 if self.queue_id != other.queue_id: return False
7706 return True
7707
Rich Lanec2ee4b82013-04-24 17:12:38 -07007708 def pretty_print(self, q):
7709 q.text("queue_stats_request {")
7710 with q.group():
7711 with q.indent(2):
7712 q.breakable()
7713 q.text("xid = ");
7714 if self.xid != None:
7715 q.text("%#x" % self.xid)
7716 else:
7717 q.text('None')
7718 q.text(","); q.breakable()
7719 q.text("flags = ");
7720 q.text("%#x" % self.flags)
7721 q.text(","); q.breakable()
7722 q.text("port_no = ");
7723 q.text(util.pretty_port(self.port_no))
7724 q.text(","); q.breakable()
7725 q.text("queue_id = ");
7726 q.text("%#x" % self.queue_id)
7727 q.breakable()
7728 q.text('}')
7729
Rich Lane7dcdf022013-12-11 14:45:27 -08007730stats_request.subtypes[5] = queue_stats_request
7731
7732class role_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -07007733 version = 3
7734 type = 25
Rich Lanec2ee4b82013-04-24 17:12:38 -07007735
Rich Laned9e3f7b2013-11-04 11:40:43 -08007736 def __init__(self, xid=None, role=None, generation_id=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007737 if xid != None:
7738 self.xid = xid
7739 else:
7740 self.xid = None
Rich Laned9e3f7b2013-11-04 11:40:43 -08007741 if role != None:
7742 self.role = role
Rich Lanec2ee4b82013-04-24 17:12:38 -07007743 else:
Rich Laned9e3f7b2013-11-04 11:40:43 -08007744 self.role = 0
7745 if generation_id != None:
7746 self.generation_id = generation_id
7747 else:
7748 self.generation_id = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08007749 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007750
7751 def pack(self):
7752 packed = []
7753 packed.append(struct.pack("!B", self.version))
7754 packed.append(struct.pack("!B", self.type))
7755 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7756 packed.append(struct.pack("!L", self.xid))
Rich Laned9e3f7b2013-11-04 11:40:43 -08007757 packed.append(struct.pack("!L", self.role))
7758 packed.append('\x00' * 4)
7759 packed.append(struct.pack("!Q", self.generation_id))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007760 length = sum([len(x) for x in packed])
7761 packed[2] = struct.pack("!H", length)
7762 return ''.join(packed)
7763
7764 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007765 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007766 obj = role_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07007767 _version = reader.read("!B")[0]
7768 assert(_version == 3)
7769 _type = reader.read("!B")[0]
7770 assert(_type == 25)
7771 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007772 orig_reader = reader
7773 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07007774 obj.xid = reader.read("!L")[0]
Rich Laned9e3f7b2013-11-04 11:40:43 -08007775 obj.role = reader.read("!L")[0]
7776 reader.skip(4)
7777 obj.generation_id = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007778 return obj
7779
7780 def __eq__(self, other):
7781 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007782 if self.xid != other.xid: return False
Rich Laned9e3f7b2013-11-04 11:40:43 -08007783 if self.role != other.role: return False
7784 if self.generation_id != other.generation_id: return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007785 return True
7786
Rich Lanec2ee4b82013-04-24 17:12:38 -07007787 def pretty_print(self, q):
7788 q.text("role_reply {")
7789 with q.group():
7790 with q.indent(2):
7791 q.breakable()
7792 q.text("xid = ");
7793 if self.xid != None:
7794 q.text("%#x" % self.xid)
7795 else:
7796 q.text('None')
7797 q.text(","); q.breakable()
Rich Laned9e3f7b2013-11-04 11:40:43 -08007798 q.text("role = ");
7799 q.text("%#x" % self.role)
7800 q.text(","); q.breakable()
7801 q.text("generation_id = ");
7802 q.text("%#x" % self.generation_id)
Rich Lanec2ee4b82013-04-24 17:12:38 -07007803 q.breakable()
7804 q.text('}')
7805
Rich Lane7dcdf022013-12-11 14:45:27 -08007806message.subtypes[25] = role_reply
7807
7808class role_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -07007809 version = 3
7810 type = 24
Rich Lanec2ee4b82013-04-24 17:12:38 -07007811
7812 def __init__(self, xid=None, role=None, generation_id=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007813 if xid != None:
7814 self.xid = xid
7815 else:
7816 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007817 if role != None:
7818 self.role = role
7819 else:
7820 self.role = 0
7821 if generation_id != None:
7822 self.generation_id = generation_id
7823 else:
7824 self.generation_id = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08007825 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007826
7827 def pack(self):
7828 packed = []
7829 packed.append(struct.pack("!B", self.version))
7830 packed.append(struct.pack("!B", self.type))
7831 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7832 packed.append(struct.pack("!L", self.xid))
7833 packed.append(struct.pack("!L", self.role))
7834 packed.append('\x00' * 4)
7835 packed.append(struct.pack("!Q", self.generation_id))
7836 length = sum([len(x) for x in packed])
7837 packed[2] = struct.pack("!H", length)
7838 return ''.join(packed)
7839
7840 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007841 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007842 obj = role_request()
Dan Talaycof6202252013-07-02 01:00:29 -07007843 _version = reader.read("!B")[0]
7844 assert(_version == 3)
7845 _type = reader.read("!B")[0]
7846 assert(_type == 24)
7847 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007848 orig_reader = reader
7849 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07007850 obj.xid = reader.read("!L")[0]
7851 obj.role = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007852 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07007853 obj.generation_id = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007854 return obj
7855
7856 def __eq__(self, other):
7857 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007858 if self.xid != other.xid: return False
7859 if self.role != other.role: return False
7860 if self.generation_id != other.generation_id: return False
7861 return True
7862
Rich Lanec2ee4b82013-04-24 17:12:38 -07007863 def pretty_print(self, q):
7864 q.text("role_request {")
7865 with q.group():
7866 with q.indent(2):
7867 q.breakable()
7868 q.text("xid = ");
7869 if self.xid != None:
7870 q.text("%#x" % self.xid)
7871 else:
7872 q.text('None')
7873 q.text(","); q.breakable()
7874 q.text("role = ");
7875 q.text("%#x" % self.role)
7876 q.text(","); q.breakable()
7877 q.text("generation_id = ");
7878 q.text("%#x" % self.generation_id)
7879 q.breakable()
7880 q.text('}')
7881
Rich Lane7dcdf022013-12-11 14:45:27 -08007882message.subtypes[24] = role_request
7883
7884class role_request_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07007885 version = 3
7886 type = 1
7887 err_type = 11
7888
7889 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007890 if xid != None:
7891 self.xid = xid
7892 else:
7893 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07007894 if code != None:
7895 self.code = code
7896 else:
7897 self.code = 0
7898 if data != None:
7899 self.data = data
7900 else:
7901 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08007902 return
Rich Lane6f4978c2013-10-20 21:33:52 -07007903
7904 def pack(self):
7905 packed = []
7906 packed.append(struct.pack("!B", self.version))
7907 packed.append(struct.pack("!B", self.type))
7908 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7909 packed.append(struct.pack("!L", self.xid))
7910 packed.append(struct.pack("!H", self.err_type))
7911 packed.append(struct.pack("!H", self.code))
7912 packed.append(self.data)
7913 length = sum([len(x) for x in packed])
7914 packed[2] = struct.pack("!H", length)
7915 return ''.join(packed)
7916
7917 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007918 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07007919 obj = role_request_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07007920 _version = reader.read("!B")[0]
7921 assert(_version == 3)
7922 _type = reader.read("!B")[0]
7923 assert(_type == 1)
7924 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007925 orig_reader = reader
7926 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07007927 obj.xid = reader.read("!L")[0]
7928 _err_type = reader.read("!H")[0]
7929 assert(_err_type == 11)
7930 obj.code = reader.read("!H")[0]
7931 obj.data = str(reader.read_all())
7932 return obj
7933
7934 def __eq__(self, other):
7935 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07007936 if self.xid != other.xid: return False
7937 if self.code != other.code: return False
7938 if self.data != other.data: return False
7939 return True
7940
Rich Lane6f4978c2013-10-20 21:33:52 -07007941 def pretty_print(self, q):
7942 q.text("role_request_failed_error_msg {")
7943 with q.group():
7944 with q.indent(2):
7945 q.breakable()
7946 q.text("xid = ");
7947 if self.xid != None:
7948 q.text("%#x" % self.xid)
7949 else:
7950 q.text('None')
7951 q.text(","); q.breakable()
7952 q.text("code = ");
7953 q.text("%#x" % self.code)
7954 q.text(","); q.breakable()
7955 q.text("data = ");
7956 q.pp(self.data)
7957 q.breakable()
7958 q.text('}')
7959
Rich Lane7dcdf022013-12-11 14:45:27 -08007960error_msg.subtypes[11] = role_request_failed_error_msg
7961
7962class set_config(message):
Dan Talaycof6202252013-07-02 01:00:29 -07007963 version = 3
7964 type = 9
Rich Lanec2ee4b82013-04-24 17:12:38 -07007965
7966 def __init__(self, xid=None, flags=None, miss_send_len=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007967 if xid != None:
7968 self.xid = xid
7969 else:
7970 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007971 if flags != None:
7972 self.flags = flags
7973 else:
7974 self.flags = 0
7975 if miss_send_len != None:
7976 self.miss_send_len = miss_send_len
7977 else:
7978 self.miss_send_len = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08007979 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007980
7981 def pack(self):
7982 packed = []
7983 packed.append(struct.pack("!B", self.version))
7984 packed.append(struct.pack("!B", self.type))
7985 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7986 packed.append(struct.pack("!L", self.xid))
7987 packed.append(struct.pack("!H", self.flags))
7988 packed.append(struct.pack("!H", self.miss_send_len))
7989 length = sum([len(x) for x in packed])
7990 packed[2] = struct.pack("!H", length)
7991 return ''.join(packed)
7992
7993 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007994 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007995 obj = set_config()
Dan Talaycof6202252013-07-02 01:00:29 -07007996 _version = reader.read("!B")[0]
7997 assert(_version == 3)
7998 _type = reader.read("!B")[0]
7999 assert(_type == 9)
8000 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08008001 orig_reader = reader
8002 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07008003 obj.xid = reader.read("!L")[0]
8004 obj.flags = reader.read("!H")[0]
8005 obj.miss_send_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07008006 return obj
8007
8008 def __eq__(self, other):
8009 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07008010 if self.xid != other.xid: return False
8011 if self.flags != other.flags: return False
8012 if self.miss_send_len != other.miss_send_len: return False
8013 return True
8014
Rich Lanec2ee4b82013-04-24 17:12:38 -07008015 def pretty_print(self, q):
8016 q.text("set_config {")
8017 with q.group():
8018 with q.indent(2):
8019 q.breakable()
8020 q.text("xid = ");
8021 if self.xid != None:
8022 q.text("%#x" % self.xid)
8023 else:
8024 q.text('None')
8025 q.text(","); q.breakable()
8026 q.text("flags = ");
8027 q.text("%#x" % self.flags)
8028 q.text(","); q.breakable()
8029 q.text("miss_send_len = ");
8030 q.text("%#x" % self.miss_send_len)
8031 q.breakable()
8032 q.text('}')
8033
Rich Lane7dcdf022013-12-11 14:45:27 -08008034message.subtypes[9] = set_config
8035
8036class switch_config_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07008037 version = 3
8038 type = 1
8039 err_type = 10
8040
8041 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08008042 if xid != None:
8043 self.xid = xid
8044 else:
8045 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07008046 if code != None:
8047 self.code = code
8048 else:
8049 self.code = 0
8050 if data != None:
8051 self.data = data
8052 else:
8053 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08008054 return
Rich Lane6f4978c2013-10-20 21:33:52 -07008055
8056 def pack(self):
8057 packed = []
8058 packed.append(struct.pack("!B", self.version))
8059 packed.append(struct.pack("!B", self.type))
8060 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
8061 packed.append(struct.pack("!L", self.xid))
8062 packed.append(struct.pack("!H", self.err_type))
8063 packed.append(struct.pack("!H", self.code))
8064 packed.append(self.data)
8065 length = sum([len(x) for x in packed])
8066 packed[2] = struct.pack("!H", length)
8067 return ''.join(packed)
8068
8069 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08008070 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07008071 obj = switch_config_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07008072 _version = reader.read("!B")[0]
8073 assert(_version == 3)
8074 _type = reader.read("!B")[0]
8075 assert(_type == 1)
8076 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08008077 orig_reader = reader
8078 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07008079 obj.xid = reader.read("!L")[0]
8080 _err_type = reader.read("!H")[0]
8081 assert(_err_type == 10)
8082 obj.code = reader.read("!H")[0]
8083 obj.data = str(reader.read_all())
8084 return obj
8085
8086 def __eq__(self, other):
8087 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07008088 if self.xid != other.xid: return False
8089 if self.code != other.code: return False
8090 if self.data != other.data: return False
8091 return True
8092
Rich Lane6f4978c2013-10-20 21:33:52 -07008093 def pretty_print(self, q):
8094 q.text("switch_config_failed_error_msg {")
8095 with q.group():
8096 with q.indent(2):
8097 q.breakable()
8098 q.text("xid = ");
8099 if self.xid != None:
8100 q.text("%#x" % self.xid)
8101 else:
8102 q.text('None')
8103 q.text(","); q.breakable()
8104 q.text("code = ");
8105 q.text("%#x" % self.code)
8106 q.text(","); q.breakable()
8107 q.text("data = ");
8108 q.pp(self.data)
8109 q.breakable()
8110 q.text('}')
8111
Rich Lane7dcdf022013-12-11 14:45:27 -08008112error_msg.subtypes[10] = switch_config_failed_error_msg
8113
8114class table_mod(message):
Dan Talaycof6202252013-07-02 01:00:29 -07008115 version = 3
8116 type = 17
Rich Lanec2ee4b82013-04-24 17:12:38 -07008117
8118 def __init__(self, xid=None, table_id=None, config=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08008119 if xid != None:
8120 self.xid = xid
8121 else:
8122 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07008123 if table_id != None:
8124 self.table_id = table_id
8125 else:
8126 self.table_id = 0
8127 if config != None:
8128 self.config = config
8129 else:
8130 self.config = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08008131 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07008132
8133 def pack(self):
8134 packed = []
8135 packed.append(struct.pack("!B", self.version))
8136 packed.append(struct.pack("!B", self.type))
8137 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
8138 packed.append(struct.pack("!L", self.xid))
8139 packed.append(struct.pack("!B", self.table_id))
8140 packed.append('\x00' * 3)
8141 packed.append(struct.pack("!L", self.config))
8142 length = sum([len(x) for x in packed])
8143 packed[2] = struct.pack("!H", length)
8144 return ''.join(packed)
8145
8146 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08008147 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07008148 obj = table_mod()
Dan Talaycof6202252013-07-02 01:00:29 -07008149 _version = reader.read("!B")[0]
8150 assert(_version == 3)
8151 _type = reader.read("!B")[0]
8152 assert(_type == 17)
8153 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08008154 orig_reader = reader
8155 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07008156 obj.xid = reader.read("!L")[0]
8157 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07008158 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07008159 obj.config = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07008160 return obj
8161
8162 def __eq__(self, other):
8163 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07008164 if self.xid != other.xid: return False
8165 if self.table_id != other.table_id: return False
8166 if self.config != other.config: return False
8167 return True
8168
Rich Lanec2ee4b82013-04-24 17:12:38 -07008169 def pretty_print(self, q):
8170 q.text("table_mod {")
8171 with q.group():
8172 with q.indent(2):
8173 q.breakable()
8174 q.text("xid = ");
8175 if self.xid != None:
8176 q.text("%#x" % self.xid)
8177 else:
8178 q.text('None')
8179 q.text(","); q.breakable()
8180 q.text("table_id = ");
8181 q.text("%#x" % self.table_id)
8182 q.text(","); q.breakable()
8183 q.text("config = ");
8184 q.text("%#x" % self.config)
8185 q.breakable()
8186 q.text('}')
8187
Rich Lane7dcdf022013-12-11 14:45:27 -08008188message.subtypes[17] = table_mod
8189
8190class table_mod_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07008191 version = 3
8192 type = 1
8193 err_type = 8
8194
8195 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08008196 if xid != None:
8197 self.xid = xid
8198 else:
8199 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07008200 if code != None:
8201 self.code = code
8202 else:
8203 self.code = 0
8204 if data != None:
8205 self.data = data
8206 else:
8207 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08008208 return
Rich Lane6f4978c2013-10-20 21:33:52 -07008209
8210 def pack(self):
8211 packed = []
8212 packed.append(struct.pack("!B", self.version))
8213 packed.append(struct.pack("!B", self.type))
8214 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
8215 packed.append(struct.pack("!L", self.xid))
8216 packed.append(struct.pack("!H", self.err_type))
8217 packed.append(struct.pack("!H", self.code))
8218 packed.append(self.data)
8219 length = sum([len(x) for x in packed])
8220 packed[2] = struct.pack("!H", length)
8221 return ''.join(packed)
8222
8223 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08008224 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07008225 obj = table_mod_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07008226 _version = reader.read("!B")[0]
8227 assert(_version == 3)
8228 _type = reader.read("!B")[0]
8229 assert(_type == 1)
8230 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08008231 orig_reader = reader
8232 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07008233 obj.xid = reader.read("!L")[0]
8234 _err_type = reader.read("!H")[0]
8235 assert(_err_type == 8)
8236 obj.code = reader.read("!H")[0]
8237 obj.data = str(reader.read_all())
8238 return obj
8239
8240 def __eq__(self, other):
8241 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07008242 if self.xid != other.xid: return False
8243 if self.code != other.code: return False
8244 if self.data != other.data: return False
8245 return True
8246
Rich Lane6f4978c2013-10-20 21:33:52 -07008247 def pretty_print(self, q):
8248 q.text("table_mod_failed_error_msg {")
8249 with q.group():
8250 with q.indent(2):
8251 q.breakable()
8252 q.text("xid = ");
8253 if self.xid != None:
8254 q.text("%#x" % self.xid)
8255 else:
8256 q.text('None')
8257 q.text(","); q.breakable()
8258 q.text("code = ");
8259 q.text("%#x" % self.code)
8260 q.text(","); q.breakable()
8261 q.text("data = ");
8262 q.pp(self.data)
8263 q.breakable()
8264 q.text('}')
8265
Rich Lane7dcdf022013-12-11 14:45:27 -08008266error_msg.subtypes[8] = table_mod_failed_error_msg
8267
8268class table_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07008269 version = 3
8270 type = 19
8271 stats_type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07008272
8273 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08008274 if xid != None:
8275 self.xid = xid
8276 else:
8277 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07008278 if flags != None:
8279 self.flags = flags
8280 else:
8281 self.flags = 0
8282 if entries != None:
8283 self.entries = entries
8284 else:
8285 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08008286 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07008287
8288 def pack(self):
8289 packed = []
8290 packed.append(struct.pack("!B", self.version))
8291 packed.append(struct.pack("!B", self.type))
8292 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
8293 packed.append(struct.pack("!L", self.xid))
8294 packed.append(struct.pack("!H", self.stats_type))
8295 packed.append(struct.pack("!H", self.flags))
8296 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08008297 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07008298 length = sum([len(x) for x in packed])
8299 packed[2] = struct.pack("!H", length)
8300 return ''.join(packed)
8301
8302 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08008303 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07008304 obj = table_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07008305 _version = reader.read("!B")[0]
8306 assert(_version == 3)
8307 _type = reader.read("!B")[0]
8308 assert(_type == 19)
8309 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08008310 orig_reader = reader
8311 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07008312 obj.xid = reader.read("!L")[0]
8313 _stats_type = reader.read("!H")[0]
8314 assert(_stats_type == 3)
8315 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07008316 reader.skip(4)
8317 obj.entries = loxi.generic_util.unpack_list(reader, common.table_stats_entry.unpack)
8318 return obj
8319
8320 def __eq__(self, other):
8321 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07008322 if self.xid != other.xid: return False
8323 if self.flags != other.flags: return False
8324 if self.entries != other.entries: return False
8325 return True
8326
Rich Lanec2ee4b82013-04-24 17:12:38 -07008327 def pretty_print(self, q):
8328 q.text("table_stats_reply {")
8329 with q.group():
8330 with q.indent(2):
8331 q.breakable()
8332 q.text("xid = ");
8333 if self.xid != None:
8334 q.text("%#x" % self.xid)
8335 else:
8336 q.text('None')
8337 q.text(","); q.breakable()
8338 q.text("flags = ");
8339 q.text("%#x" % self.flags)
8340 q.text(","); q.breakable()
8341 q.text("entries = ");
8342 q.pp(self.entries)
8343 q.breakable()
8344 q.text('}')
8345
Rich Lane7dcdf022013-12-11 14:45:27 -08008346stats_reply.subtypes[3] = table_stats_reply
8347
8348class table_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07008349 version = 3
8350 type = 18
8351 stats_type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07008352
8353 def __init__(self, xid=None, flags=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08008354 if xid != None:
8355 self.xid = xid
8356 else:
8357 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07008358 if flags != None:
8359 self.flags = flags
8360 else:
8361 self.flags = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08008362 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07008363
8364 def pack(self):
8365 packed = []
8366 packed.append(struct.pack("!B", self.version))
8367 packed.append(struct.pack("!B", self.type))
8368 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
8369 packed.append(struct.pack("!L", self.xid))
8370 packed.append(struct.pack("!H", self.stats_type))
8371 packed.append(struct.pack("!H", self.flags))
8372 packed.append('\x00' * 4)
8373 length = sum([len(x) for x in packed])
8374 packed[2] = struct.pack("!H", length)
8375 return ''.join(packed)
8376
8377 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08008378 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07008379 obj = table_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07008380 _version = reader.read("!B")[0]
8381 assert(_version == 3)
8382 _type = reader.read("!B")[0]
8383 assert(_type == 18)
8384 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08008385 orig_reader = reader
8386 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07008387 obj.xid = reader.read("!L")[0]
8388 _stats_type = reader.read("!H")[0]
8389 assert(_stats_type == 3)
8390 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07008391 reader.skip(4)
8392 return obj
8393
8394 def __eq__(self, other):
8395 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07008396 if self.xid != other.xid: return False
8397 if self.flags != other.flags: return False
8398 return True
8399
Rich Lanec2ee4b82013-04-24 17:12:38 -07008400 def pretty_print(self, q):
8401 q.text("table_stats_request {")
8402 with q.group():
8403 with q.indent(2):
8404 q.breakable()
8405 q.text("xid = ");
8406 if self.xid != None:
8407 q.text("%#x" % self.xid)
8408 else:
8409 q.text('None')
8410 q.text(","); q.breakable()
8411 q.text("flags = ");
8412 q.text("%#x" % self.flags)
8413 q.breakable()
8414 q.text('}')
8415
Rich Lane7dcdf022013-12-11 14:45:27 -08008416stats_request.subtypes[3] = table_stats_request
8417
Rich Lanec2ee4b82013-04-24 17:12:38 -07008418
8419def parse_header(buf):
8420 if len(buf) < 8:
8421 raise loxi.ProtocolError("too short to be an OpenFlow message")
8422 return struct.unpack_from("!BBHL", buf)
8423
8424def parse_message(buf):
8425 msg_ver, msg_type, msg_len, msg_xid = parse_header(buf)
Rich Lanefe600f52013-07-09 13:22:32 -07008426 if msg_ver != const.OFP_VERSION and msg_type != const.OFPT_HELLO:
8427 raise loxi.ProtocolError("wrong OpenFlow version (expected %d, got %d)" % (const.OFP_VERSION, msg_ver))
Rich Lanec2ee4b82013-04-24 17:12:38 -07008428 if len(buf) != msg_len:
8429 raise loxi.ProtocolError("incorrect message size")
Rich Lane7dcdf022013-12-11 14:45:27 -08008430 return message.unpack(loxi.generic_util.OFReader(buf))