blob: 103ba8936488580cea689bf10accabb8fd0a7431 [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
12import common
Rich Lane7dcdf022013-12-11 14:45:27 -080013import action
14import instruction
15import oxm
Rich Lanec2ee4b82013-04-24 17:12:38 -070016import util
17import loxi.generic_util
18
Rich Lane7dcdf022013-12-11 14:45:27 -080019class message(loxi.OFObject):
20 subtypes = {}
Rich Lanec2ee4b82013-04-24 17:12:38 -070021
Rich Lane95f7fc92014-01-27 17:08:16 -080022 version = 3
23
24 def __init__(self, type=None, xid=None):
25 if type != None:
26 self.type = type
27 else:
28 self.type = 0
29 if xid != None:
30 self.xid = xid
31 else:
32 self.xid = None
33 return
34
35 def pack(self):
36 packed = []
37 packed.append(struct.pack("!B", self.version))
38 packed.append(struct.pack("!B", self.type))
39 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
40 packed.append(struct.pack("!L", self.xid))
41 length = sum([len(x) for x in packed])
42 packed[2] = struct.pack("!H", length)
43 return ''.join(packed)
44
Rich Lane7dcdf022013-12-11 14:45:27 -080045 @staticmethod
46 def unpack(reader):
47 subtype, = reader.peek('B', 1)
Rich Lane95f7fc92014-01-27 17:08:16 -080048 subclass = message.subtypes.get(subtype)
49 if subclass:
50 return subclass.unpack(reader)
51
52 obj = message()
53 _version = reader.read("!B")[0]
54 assert(_version == 3)
55 obj.type = reader.read("!B")[0]
56 _length = reader.read("!H")[0]
57 orig_reader = reader
58 reader = orig_reader.slice(_length - (2 + 2))
59 obj.xid = reader.read("!L")[0]
60 return obj
61
62 def __eq__(self, other):
63 if type(self) != type(other): return False
64 if self.type != other.type: return False
65 if self.xid != other.xid: return False
66 return True
67
68 def pretty_print(self, q):
69 q.text("message {")
70 with q.group():
71 with q.indent(2):
72 q.breakable()
73 q.text("xid = ");
74 if self.xid != None:
75 q.text("%#x" % self.xid)
76 else:
77 q.text('None')
78 q.breakable()
79 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -080080
81
82class stats_reply(message):
83 subtypes = {}
84
Rich Lane95f7fc92014-01-27 17:08:16 -080085 version = 3
86 type = 19
87
88 def __init__(self, xid=None, stats_type=None, flags=None):
89 if xid != None:
90 self.xid = xid
91 else:
92 self.xid = None
93 if stats_type != None:
94 self.stats_type = stats_type
95 else:
96 self.stats_type = 0
97 if flags != None:
98 self.flags = flags
99 else:
100 self.flags = 0
101 return
102
103 def pack(self):
104 packed = []
105 packed.append(struct.pack("!B", self.version))
106 packed.append(struct.pack("!B", self.type))
107 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
108 packed.append(struct.pack("!L", self.xid))
109 packed.append(struct.pack("!H", self.stats_type))
110 packed.append(struct.pack("!H", self.flags))
111 packed.append('\x00' * 4)
112 length = sum([len(x) for x in packed])
113 packed[2] = struct.pack("!H", length)
114 return ''.join(packed)
115
Rich Lane7dcdf022013-12-11 14:45:27 -0800116 @staticmethod
117 def unpack(reader):
118 subtype, = reader.peek('!H', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800119 subclass = stats_reply.subtypes.get(subtype)
120 if subclass:
121 return subclass.unpack(reader)
122
123 obj = stats_reply()
124 _version = reader.read("!B")[0]
125 assert(_version == 3)
126 _type = reader.read("!B")[0]
127 assert(_type == 19)
128 _length = reader.read("!H")[0]
129 orig_reader = reader
130 reader = orig_reader.slice(_length - (2 + 2))
131 obj.xid = reader.read("!L")[0]
132 obj.stats_type = reader.read("!H")[0]
133 obj.flags = reader.read("!H")[0]
134 reader.skip(4)
135 return obj
136
137 def __eq__(self, other):
138 if type(self) != type(other): return False
139 if self.xid != other.xid: return False
140 if self.stats_type != other.stats_type: return False
141 if self.flags != other.flags: return False
142 return True
143
144 def pretty_print(self, q):
145 q.text("stats_reply {")
146 with q.group():
147 with q.indent(2):
148 q.breakable()
149 q.text("xid = ");
150 if self.xid != None:
151 q.text("%#x" % self.xid)
152 else:
153 q.text('None')
154 q.text(","); q.breakable()
155 q.text("flags = ");
156 q.text("%#x" % self.flags)
157 q.breakable()
158 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800159
160message.subtypes[19] = stats_reply
161
162class aggregate_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -0700163 version = 3
164 type = 19
165 stats_type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -0700166
167 def __init__(self, xid=None, flags=None, packet_count=None, byte_count=None, flow_count=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800168 if xid != None:
169 self.xid = xid
170 else:
171 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -0700172 if flags != None:
173 self.flags = flags
174 else:
175 self.flags = 0
176 if packet_count != None:
177 self.packet_count = packet_count
178 else:
179 self.packet_count = 0
180 if byte_count != None:
181 self.byte_count = byte_count
182 else:
183 self.byte_count = 0
184 if flow_count != None:
185 self.flow_count = flow_count
186 else:
187 self.flow_count = 0
Rich Lane7dcdf022013-12-11 14:45:27 -0800188 return
Rich Lanec2ee4b82013-04-24 17:12:38 -0700189
190 def pack(self):
191 packed = []
192 packed.append(struct.pack("!B", self.version))
193 packed.append(struct.pack("!B", self.type))
194 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
195 packed.append(struct.pack("!L", self.xid))
196 packed.append(struct.pack("!H", self.stats_type))
197 packed.append(struct.pack("!H", self.flags))
198 packed.append('\x00' * 4)
199 packed.append(struct.pack("!Q", self.packet_count))
200 packed.append(struct.pack("!Q", self.byte_count))
201 packed.append(struct.pack("!L", self.flow_count))
202 packed.append('\x00' * 4)
203 length = sum([len(x) for x in packed])
204 packed[2] = struct.pack("!H", length)
205 return ''.join(packed)
206
207 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800208 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700209 obj = aggregate_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -0700210 _version = reader.read("!B")[0]
211 assert(_version == 3)
212 _type = reader.read("!B")[0]
213 assert(_type == 19)
214 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800215 orig_reader = reader
216 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700217 obj.xid = reader.read("!L")[0]
218 _stats_type = reader.read("!H")[0]
219 assert(_stats_type == 2)
220 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700221 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -0700222 obj.packet_count = reader.read("!Q")[0]
223 obj.byte_count = reader.read("!Q")[0]
224 obj.flow_count = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700225 reader.skip(4)
226 return obj
227
228 def __eq__(self, other):
229 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700230 if self.xid != other.xid: return False
231 if self.flags != other.flags: return False
232 if self.packet_count != other.packet_count: return False
233 if self.byte_count != other.byte_count: return False
234 if self.flow_count != other.flow_count: return False
235 return True
236
Rich Lanec2ee4b82013-04-24 17:12:38 -0700237 def pretty_print(self, q):
238 q.text("aggregate_stats_reply {")
239 with q.group():
240 with q.indent(2):
241 q.breakable()
242 q.text("xid = ");
243 if self.xid != None:
244 q.text("%#x" % self.xid)
245 else:
246 q.text('None')
247 q.text(","); q.breakable()
248 q.text("flags = ");
249 q.text("%#x" % self.flags)
250 q.text(","); q.breakable()
251 q.text("packet_count = ");
252 q.text("%#x" % self.packet_count)
253 q.text(","); q.breakable()
254 q.text("byte_count = ");
255 q.text("%#x" % self.byte_count)
256 q.text(","); q.breakable()
257 q.text("flow_count = ");
258 q.text("%#x" % self.flow_count)
259 q.breakable()
260 q.text('}')
261
Rich Lane7dcdf022013-12-11 14:45:27 -0800262stats_reply.subtypes[2] = aggregate_stats_reply
263
264class stats_request(message):
265 subtypes = {}
266
Rich Lane95f7fc92014-01-27 17:08:16 -0800267 version = 3
268 type = 18
269
270 def __init__(self, xid=None, stats_type=None, flags=None):
271 if xid != None:
272 self.xid = xid
273 else:
274 self.xid = None
275 if stats_type != None:
276 self.stats_type = stats_type
277 else:
278 self.stats_type = 0
279 if flags != None:
280 self.flags = flags
281 else:
282 self.flags = 0
283 return
284
285 def pack(self):
286 packed = []
287 packed.append(struct.pack("!B", self.version))
288 packed.append(struct.pack("!B", self.type))
289 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
290 packed.append(struct.pack("!L", self.xid))
291 packed.append(struct.pack("!H", self.stats_type))
292 packed.append(struct.pack("!H", self.flags))
293 packed.append('\x00' * 4)
294 length = sum([len(x) for x in packed])
295 packed[2] = struct.pack("!H", length)
296 return ''.join(packed)
297
Rich Lane7dcdf022013-12-11 14:45:27 -0800298 @staticmethod
299 def unpack(reader):
300 subtype, = reader.peek('!H', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800301 subclass = stats_request.subtypes.get(subtype)
302 if subclass:
303 return subclass.unpack(reader)
304
305 obj = stats_request()
306 _version = reader.read("!B")[0]
307 assert(_version == 3)
308 _type = reader.read("!B")[0]
309 assert(_type == 18)
310 _length = reader.read("!H")[0]
311 orig_reader = reader
312 reader = orig_reader.slice(_length - (2 + 2))
313 obj.xid = reader.read("!L")[0]
314 obj.stats_type = reader.read("!H")[0]
315 obj.flags = reader.read("!H")[0]
316 reader.skip(4)
317 return obj
318
319 def __eq__(self, other):
320 if type(self) != type(other): return False
321 if self.xid != other.xid: return False
322 if self.stats_type != other.stats_type: return False
323 if self.flags != other.flags: return False
324 return True
325
326 def pretty_print(self, q):
327 q.text("stats_request {")
328 with q.group():
329 with q.indent(2):
330 q.breakable()
331 q.text("xid = ");
332 if self.xid != None:
333 q.text("%#x" % self.xid)
334 else:
335 q.text('None')
336 q.text(","); q.breakable()
337 q.text("flags = ");
338 q.text("%#x" % self.flags)
339 q.breakable()
340 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800341
342message.subtypes[18] = stats_request
343
344class aggregate_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -0700345 version = 3
346 type = 18
347 stats_type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -0700348
349 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 -0800350 if xid != None:
351 self.xid = xid
352 else:
353 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -0700354 if flags != None:
355 self.flags = flags
356 else:
357 self.flags = 0
358 if table_id != None:
359 self.table_id = table_id
360 else:
361 self.table_id = 0
362 if out_port != None:
363 self.out_port = out_port
364 else:
365 self.out_port = 0
366 if out_group != None:
367 self.out_group = out_group
368 else:
369 self.out_group = 0
370 if cookie != None:
371 self.cookie = cookie
372 else:
373 self.cookie = 0
374 if cookie_mask != None:
375 self.cookie_mask = cookie_mask
376 else:
377 self.cookie_mask = 0
378 if match != None:
379 self.match = match
380 else:
381 self.match = common.match()
Rich Lane7dcdf022013-12-11 14:45:27 -0800382 return
Rich Lanec2ee4b82013-04-24 17:12:38 -0700383
384 def pack(self):
385 packed = []
386 packed.append(struct.pack("!B", self.version))
387 packed.append(struct.pack("!B", self.type))
388 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
389 packed.append(struct.pack("!L", self.xid))
390 packed.append(struct.pack("!H", self.stats_type))
391 packed.append(struct.pack("!H", self.flags))
392 packed.append('\x00' * 4)
393 packed.append(struct.pack("!B", self.table_id))
394 packed.append('\x00' * 3)
Dan Talaycof6202252013-07-02 01:00:29 -0700395 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700396 packed.append(struct.pack("!L", self.out_group))
397 packed.append('\x00' * 4)
398 packed.append(struct.pack("!Q", self.cookie))
399 packed.append(struct.pack("!Q", self.cookie_mask))
400 packed.append(self.match.pack())
401 length = sum([len(x) for x in packed])
402 packed[2] = struct.pack("!H", length)
403 return ''.join(packed)
404
405 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800406 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700407 obj = aggregate_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -0700408 _version = reader.read("!B")[0]
409 assert(_version == 3)
410 _type = reader.read("!B")[0]
411 assert(_type == 18)
412 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800413 orig_reader = reader
414 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700415 obj.xid = reader.read("!L")[0]
416 _stats_type = reader.read("!H")[0]
417 assert(_stats_type == 2)
418 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700419 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -0700420 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700421 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -0700422 obj.out_port = util.unpack_port_no(reader)
423 obj.out_group = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700424 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -0700425 obj.cookie = reader.read("!Q")[0]
426 obj.cookie_mask = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700427 obj.match = common.match.unpack(reader)
428 return obj
429
430 def __eq__(self, other):
431 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700432 if self.xid != other.xid: return False
433 if self.flags != other.flags: return False
434 if self.table_id != other.table_id: return False
435 if self.out_port != other.out_port: return False
436 if self.out_group != other.out_group: return False
437 if self.cookie != other.cookie: return False
438 if self.cookie_mask != other.cookie_mask: return False
439 if self.match != other.match: return False
440 return True
441
Rich Lanec2ee4b82013-04-24 17:12:38 -0700442 def pretty_print(self, q):
443 q.text("aggregate_stats_request {")
444 with q.group():
445 with q.indent(2):
446 q.breakable()
447 q.text("xid = ");
448 if self.xid != None:
449 q.text("%#x" % self.xid)
450 else:
451 q.text('None')
452 q.text(","); q.breakable()
453 q.text("flags = ");
454 q.text("%#x" % self.flags)
455 q.text(","); q.breakable()
456 q.text("table_id = ");
457 q.text("%#x" % self.table_id)
458 q.text(","); q.breakable()
459 q.text("out_port = ");
460 q.text(util.pretty_port(self.out_port))
461 q.text(","); q.breakable()
462 q.text("out_group = ");
463 q.text("%#x" % self.out_group)
464 q.text(","); q.breakable()
465 q.text("cookie = ");
466 q.text("%#x" % self.cookie)
467 q.text(","); q.breakable()
468 q.text("cookie_mask = ");
469 q.text("%#x" % self.cookie_mask)
470 q.text(","); q.breakable()
471 q.text("match = ");
472 q.pp(self.match)
473 q.breakable()
474 q.text('}')
475
Rich Lane7dcdf022013-12-11 14:45:27 -0800476stats_request.subtypes[2] = aggregate_stats_request
477
478class error_msg(message):
479 subtypes = {}
480
Rich Lane95f7fc92014-01-27 17:08:16 -0800481 version = 3
482 type = 1
483
484 def __init__(self, xid=None, err_type=None):
485 if xid != None:
486 self.xid = xid
487 else:
488 self.xid = None
489 if err_type != None:
490 self.err_type = err_type
491 else:
492 self.err_type = 0
493 return
494
495 def pack(self):
496 packed = []
497 packed.append(struct.pack("!B", self.version))
498 packed.append(struct.pack("!B", self.type))
499 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
500 packed.append(struct.pack("!L", self.xid))
501 packed.append(struct.pack("!H", self.err_type))
502 length = sum([len(x) for x in packed])
503 packed[2] = struct.pack("!H", length)
504 return ''.join(packed)
505
Rich Lane7dcdf022013-12-11 14:45:27 -0800506 @staticmethod
507 def unpack(reader):
508 subtype, = reader.peek('!H', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800509 subclass = error_msg.subtypes.get(subtype)
510 if subclass:
511 return subclass.unpack(reader)
512
513 obj = error_msg()
514 _version = reader.read("!B")[0]
515 assert(_version == 3)
516 _type = reader.read("!B")[0]
517 assert(_type == 1)
518 _length = reader.read("!H")[0]
519 orig_reader = reader
520 reader = orig_reader.slice(_length - (2 + 2))
521 obj.xid = reader.read("!L")[0]
522 obj.err_type = reader.read("!H")[0]
523 return obj
524
525 def __eq__(self, other):
526 if type(self) != type(other): return False
527 if self.xid != other.xid: return False
528 if self.err_type != other.err_type: return False
529 return True
530
531 def pretty_print(self, q):
532 q.text("error_msg {")
533 with q.group():
534 with q.indent(2):
535 q.breakable()
536 q.text("xid = ");
537 if self.xid != None:
538 q.text("%#x" % self.xid)
539 else:
540 q.text('None')
541 q.breakable()
542 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800543
544message.subtypes[1] = error_msg
545
546class bad_action_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -0700547 version = 3
548 type = 1
549 err_type = 2
550
551 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800552 if xid != None:
553 self.xid = xid
554 else:
555 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -0700556 if code != None:
557 self.code = code
558 else:
559 self.code = 0
560 if data != None:
561 self.data = data
562 else:
563 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -0800564 return
Rich Lane6f4978c2013-10-20 21:33:52 -0700565
566 def pack(self):
567 packed = []
568 packed.append(struct.pack("!B", self.version))
569 packed.append(struct.pack("!B", self.type))
570 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
571 packed.append(struct.pack("!L", self.xid))
572 packed.append(struct.pack("!H", self.err_type))
573 packed.append(struct.pack("!H", self.code))
574 packed.append(self.data)
575 length = sum([len(x) for x in packed])
576 packed[2] = struct.pack("!H", length)
577 return ''.join(packed)
578
579 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800580 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -0700581 obj = bad_action_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -0700582 _version = reader.read("!B")[0]
583 assert(_version == 3)
584 _type = reader.read("!B")[0]
585 assert(_type == 1)
586 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800587 orig_reader = reader
588 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -0700589 obj.xid = reader.read("!L")[0]
590 _err_type = reader.read("!H")[0]
591 assert(_err_type == 2)
592 obj.code = reader.read("!H")[0]
593 obj.data = str(reader.read_all())
594 return obj
595
596 def __eq__(self, other):
597 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -0700598 if self.xid != other.xid: return False
599 if self.code != other.code: return False
600 if self.data != other.data: return False
601 return True
602
Rich Lane6f4978c2013-10-20 21:33:52 -0700603 def pretty_print(self, q):
604 q.text("bad_action_error_msg {")
605 with q.group():
606 with q.indent(2):
607 q.breakable()
608 q.text("xid = ");
609 if self.xid != None:
610 q.text("%#x" % self.xid)
611 else:
612 q.text('None')
613 q.text(","); q.breakable()
614 q.text("code = ");
615 q.text("%#x" % self.code)
616 q.text(","); q.breakable()
617 q.text("data = ");
618 q.pp(self.data)
619 q.breakable()
620 q.text('}')
621
Rich Lane7dcdf022013-12-11 14:45:27 -0800622error_msg.subtypes[2] = bad_action_error_msg
623
624class bad_instruction_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -0700625 version = 3
626 type = 1
627 err_type = 3
628
629 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800630 if xid != None:
631 self.xid = xid
632 else:
633 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -0700634 if code != None:
635 self.code = code
636 else:
637 self.code = 0
638 if data != None:
639 self.data = data
640 else:
641 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -0800642 return
Rich Lane6f4978c2013-10-20 21:33:52 -0700643
644 def pack(self):
645 packed = []
646 packed.append(struct.pack("!B", self.version))
647 packed.append(struct.pack("!B", self.type))
648 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
649 packed.append(struct.pack("!L", self.xid))
650 packed.append(struct.pack("!H", self.err_type))
651 packed.append(struct.pack("!H", self.code))
652 packed.append(self.data)
653 length = sum([len(x) for x in packed])
654 packed[2] = struct.pack("!H", length)
655 return ''.join(packed)
656
657 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800658 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -0700659 obj = bad_instruction_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -0700660 _version = reader.read("!B")[0]
661 assert(_version == 3)
662 _type = reader.read("!B")[0]
663 assert(_type == 1)
664 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800665 orig_reader = reader
666 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -0700667 obj.xid = reader.read("!L")[0]
668 _err_type = reader.read("!H")[0]
669 assert(_err_type == 3)
670 obj.code = reader.read("!H")[0]
671 obj.data = str(reader.read_all())
672 return obj
673
674 def __eq__(self, other):
675 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -0700676 if self.xid != other.xid: return False
677 if self.code != other.code: return False
678 if self.data != other.data: return False
679 return True
680
Rich Lane6f4978c2013-10-20 21:33:52 -0700681 def pretty_print(self, q):
682 q.text("bad_instruction_error_msg {")
683 with q.group():
684 with q.indent(2):
685 q.breakable()
686 q.text("xid = ");
687 if self.xid != None:
688 q.text("%#x" % self.xid)
689 else:
690 q.text('None')
691 q.text(","); q.breakable()
692 q.text("code = ");
693 q.text("%#x" % self.code)
694 q.text(","); q.breakable()
695 q.text("data = ");
696 q.pp(self.data)
697 q.breakable()
698 q.text('}')
699
Rich Lane7dcdf022013-12-11 14:45:27 -0800700error_msg.subtypes[3] = bad_instruction_error_msg
701
702class bad_match_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -0700703 version = 3
704 type = 1
705 err_type = 4
706
707 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800708 if xid != None:
709 self.xid = xid
710 else:
711 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -0700712 if code != None:
713 self.code = code
714 else:
715 self.code = 0
716 if data != None:
717 self.data = data
718 else:
719 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -0800720 return
Rich Lane6f4978c2013-10-20 21:33:52 -0700721
722 def pack(self):
723 packed = []
724 packed.append(struct.pack("!B", self.version))
725 packed.append(struct.pack("!B", self.type))
726 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
727 packed.append(struct.pack("!L", self.xid))
728 packed.append(struct.pack("!H", self.err_type))
729 packed.append(struct.pack("!H", self.code))
730 packed.append(self.data)
731 length = sum([len(x) for x in packed])
732 packed[2] = struct.pack("!H", length)
733 return ''.join(packed)
734
735 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800736 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -0700737 obj = bad_match_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -0700738 _version = reader.read("!B")[0]
739 assert(_version == 3)
740 _type = reader.read("!B")[0]
741 assert(_type == 1)
742 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800743 orig_reader = reader
744 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -0700745 obj.xid = reader.read("!L")[0]
746 _err_type = reader.read("!H")[0]
747 assert(_err_type == 4)
748 obj.code = reader.read("!H")[0]
749 obj.data = str(reader.read_all())
750 return obj
751
752 def __eq__(self, other):
753 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -0700754 if self.xid != other.xid: return False
755 if self.code != other.code: return False
756 if self.data != other.data: return False
757 return True
758
Rich Lane6f4978c2013-10-20 21:33:52 -0700759 def pretty_print(self, q):
760 q.text("bad_match_error_msg {")
761 with q.group():
762 with q.indent(2):
763 q.breakable()
764 q.text("xid = ");
765 if self.xid != None:
766 q.text("%#x" % self.xid)
767 else:
768 q.text('None')
769 q.text(","); q.breakable()
770 q.text("code = ");
771 q.text("%#x" % self.code)
772 q.text(","); q.breakable()
773 q.text("data = ");
774 q.pp(self.data)
775 q.breakable()
776 q.text('}')
777
Rich Lane7dcdf022013-12-11 14:45:27 -0800778error_msg.subtypes[4] = bad_match_error_msg
779
780class bad_request_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -0700781 version = 3
782 type = 1
783 err_type = 1
784
785 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800786 if xid != None:
787 self.xid = xid
788 else:
789 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -0700790 if code != None:
791 self.code = code
792 else:
793 self.code = 0
794 if data != None:
795 self.data = data
796 else:
797 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -0800798 return
Rich Lane6f4978c2013-10-20 21:33:52 -0700799
800 def pack(self):
801 packed = []
802 packed.append(struct.pack("!B", self.version))
803 packed.append(struct.pack("!B", self.type))
804 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
805 packed.append(struct.pack("!L", self.xid))
806 packed.append(struct.pack("!H", self.err_type))
807 packed.append(struct.pack("!H", self.code))
808 packed.append(self.data)
809 length = sum([len(x) for x in packed])
810 packed[2] = struct.pack("!H", length)
811 return ''.join(packed)
812
813 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800814 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -0700815 obj = bad_request_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -0700816 _version = reader.read("!B")[0]
817 assert(_version == 3)
818 _type = reader.read("!B")[0]
819 assert(_type == 1)
820 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800821 orig_reader = reader
822 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -0700823 obj.xid = reader.read("!L")[0]
824 _err_type = reader.read("!H")[0]
825 assert(_err_type == 1)
826 obj.code = reader.read("!H")[0]
827 obj.data = str(reader.read_all())
828 return obj
829
830 def __eq__(self, other):
831 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -0700832 if self.xid != other.xid: return False
833 if self.code != other.code: return False
834 if self.data != other.data: return False
835 return True
836
Rich Lane6f4978c2013-10-20 21:33:52 -0700837 def pretty_print(self, q):
838 q.text("bad_request_error_msg {")
839 with q.group():
840 with q.indent(2):
841 q.breakable()
842 q.text("xid = ");
843 if self.xid != None:
844 q.text("%#x" % self.xid)
845 else:
846 q.text('None')
847 q.text(","); q.breakable()
848 q.text("code = ");
849 q.text("%#x" % self.code)
850 q.text(","); q.breakable()
851 q.text("data = ");
852 q.pp(self.data)
853 q.breakable()
854 q.text('}')
855
Rich Lane7dcdf022013-12-11 14:45:27 -0800856error_msg.subtypes[1] = bad_request_error_msg
857
858class barrier_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -0700859 version = 3
860 type = 21
Rich Lanec2ee4b82013-04-24 17:12:38 -0700861
862 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800863 if xid != None:
864 self.xid = xid
865 else:
866 self.xid = None
867 return
Rich Lanec2ee4b82013-04-24 17:12:38 -0700868
869 def pack(self):
870 packed = []
871 packed.append(struct.pack("!B", self.version))
872 packed.append(struct.pack("!B", self.type))
873 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
874 packed.append(struct.pack("!L", self.xid))
875 length = sum([len(x) for x in packed])
876 packed[2] = struct.pack("!H", length)
877 return ''.join(packed)
878
879 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800880 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700881 obj = barrier_reply()
Dan Talaycof6202252013-07-02 01:00:29 -0700882 _version = reader.read("!B")[0]
883 assert(_version == 3)
884 _type = reader.read("!B")[0]
885 assert(_type == 21)
886 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800887 orig_reader = reader
888 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700889 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700890 return obj
891
892 def __eq__(self, other):
893 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700894 if self.xid != other.xid: return False
895 return True
896
Rich Lanec2ee4b82013-04-24 17:12:38 -0700897 def pretty_print(self, q):
898 q.text("barrier_reply {")
899 with q.group():
900 with q.indent(2):
901 q.breakable()
902 q.text("xid = ");
903 if self.xid != None:
904 q.text("%#x" % self.xid)
905 else:
906 q.text('None')
907 q.breakable()
908 q.text('}')
909
Rich Lane7dcdf022013-12-11 14:45:27 -0800910message.subtypes[21] = barrier_reply
911
912class barrier_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -0700913 version = 3
914 type = 20
Rich Lanec2ee4b82013-04-24 17:12:38 -0700915
916 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800917 if xid != None:
918 self.xid = xid
919 else:
920 self.xid = None
921 return
Rich Lanec2ee4b82013-04-24 17:12:38 -0700922
923 def pack(self):
924 packed = []
925 packed.append(struct.pack("!B", self.version))
926 packed.append(struct.pack("!B", self.type))
927 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
928 packed.append(struct.pack("!L", self.xid))
929 length = sum([len(x) for x in packed])
930 packed[2] = struct.pack("!H", length)
931 return ''.join(packed)
932
933 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800934 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700935 obj = barrier_request()
Dan Talaycof6202252013-07-02 01:00:29 -0700936 _version = reader.read("!B")[0]
937 assert(_version == 3)
938 _type = reader.read("!B")[0]
939 assert(_type == 20)
940 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800941 orig_reader = reader
942 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700943 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700944 return obj
945
946 def __eq__(self, other):
947 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700948 if self.xid != other.xid: return False
949 return True
950
Rich Lanec2ee4b82013-04-24 17:12:38 -0700951 def pretty_print(self, q):
952 q.text("barrier_request {")
953 with q.group():
954 with q.indent(2):
955 q.breakable()
956 q.text("xid = ");
957 if self.xid != None:
958 q.text("%#x" % self.xid)
959 else:
960 q.text('None')
961 q.breakable()
962 q.text('}')
963
Rich Lane7dcdf022013-12-11 14:45:27 -0800964message.subtypes[20] = barrier_request
965
966class experimenter(message):
967 subtypes = {}
968
Rich Lane95f7fc92014-01-27 17:08:16 -0800969 version = 3
970 type = 4
971
972 def __init__(self, xid=None, experimenter=None, subtype=None, data=None):
973 if xid != None:
974 self.xid = xid
975 else:
976 self.xid = None
977 if experimenter != None:
978 self.experimenter = experimenter
979 else:
980 self.experimenter = 0
981 if subtype != None:
982 self.subtype = subtype
983 else:
984 self.subtype = 0
985 if data != None:
986 self.data = data
987 else:
988 self.data = ''
989 return
990
991 def pack(self):
992 packed = []
993 packed.append(struct.pack("!B", self.version))
994 packed.append(struct.pack("!B", self.type))
995 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
996 packed.append(struct.pack("!L", self.xid))
997 packed.append(struct.pack("!L", self.experimenter))
998 packed.append(struct.pack("!L", self.subtype))
999 packed.append(self.data)
1000 length = sum([len(x) for x in packed])
1001 packed[2] = struct.pack("!H", length)
1002 return ''.join(packed)
1003
Rich Lane7dcdf022013-12-11 14:45:27 -08001004 @staticmethod
1005 def unpack(reader):
1006 subtype, = reader.peek('!L', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -08001007 subclass = experimenter.subtypes.get(subtype)
1008 if subclass:
1009 return subclass.unpack(reader)
1010
1011 obj = experimenter()
1012 _version = reader.read("!B")[0]
1013 assert(_version == 3)
1014 _type = reader.read("!B")[0]
1015 assert(_type == 4)
1016 _length = reader.read("!H")[0]
1017 orig_reader = reader
1018 reader = orig_reader.slice(_length - (2 + 2))
1019 obj.xid = reader.read("!L")[0]
1020 obj.experimenter = reader.read("!L")[0]
1021 obj.subtype = reader.read("!L")[0]
1022 obj.data = str(reader.read_all())
1023 return obj
1024
1025 def __eq__(self, other):
1026 if type(self) != type(other): return False
1027 if self.xid != other.xid: return False
1028 if self.experimenter != other.experimenter: return False
1029 if self.subtype != other.subtype: return False
1030 if self.data != other.data: return False
1031 return True
1032
1033 def pretty_print(self, q):
1034 q.text("experimenter {")
1035 with q.group():
1036 with q.indent(2):
1037 q.breakable()
1038 q.text("xid = ");
1039 if self.xid != None:
1040 q.text("%#x" % self.xid)
1041 else:
1042 q.text('None')
1043 q.text(","); q.breakable()
1044 q.text("subtype = ");
1045 q.text("%#x" % self.subtype)
1046 q.text(","); q.breakable()
1047 q.text("data = ");
1048 q.pp(self.data)
1049 q.breakable()
1050 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08001051
1052message.subtypes[4] = experimenter
1053
1054class bsn_header(experimenter):
1055 subtypes = {}
1056
Rich Lane95f7fc92014-01-27 17:08:16 -08001057 version = 3
1058 type = 4
1059 experimenter = 6035143
1060
1061 def __init__(self, xid=None, subtype=None):
1062 if xid != None:
1063 self.xid = xid
1064 else:
1065 self.xid = None
1066 if subtype != None:
1067 self.subtype = subtype
1068 else:
1069 self.subtype = 0
1070 return
1071
1072 def pack(self):
1073 packed = []
1074 packed.append(struct.pack("!B", self.version))
1075 packed.append(struct.pack("!B", self.type))
1076 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1077 packed.append(struct.pack("!L", self.xid))
1078 packed.append(struct.pack("!L", self.experimenter))
1079 packed.append(struct.pack("!L", self.subtype))
1080 length = sum([len(x) for x in packed])
1081 packed[2] = struct.pack("!H", length)
1082 return ''.join(packed)
1083
Rich Lane7dcdf022013-12-11 14:45:27 -08001084 @staticmethod
1085 def unpack(reader):
1086 subtype, = reader.peek('!L', 12)
Rich Lane95f7fc92014-01-27 17:08:16 -08001087 subclass = bsn_header.subtypes.get(subtype)
1088 if subclass:
1089 return subclass.unpack(reader)
1090
1091 obj = bsn_header()
1092 _version = reader.read("!B")[0]
1093 assert(_version == 3)
1094 _type = reader.read("!B")[0]
1095 assert(_type == 4)
1096 _length = reader.read("!H")[0]
1097 orig_reader = reader
1098 reader = orig_reader.slice(_length - (2 + 2))
1099 obj.xid = reader.read("!L")[0]
1100 _experimenter = reader.read("!L")[0]
1101 assert(_experimenter == 6035143)
1102 obj.subtype = reader.read("!L")[0]
1103 return obj
1104
1105 def __eq__(self, other):
1106 if type(self) != type(other): return False
1107 if self.xid != other.xid: return False
1108 if self.subtype != other.subtype: return False
1109 return True
1110
1111 def pretty_print(self, q):
1112 q.text("bsn_header {")
1113 with q.group():
1114 with q.indent(2):
1115 q.breakable()
1116 q.text("xid = ");
1117 if self.xid != None:
1118 q.text("%#x" % self.xid)
1119 else:
1120 q.text('None')
1121 q.breakable()
1122 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08001123
1124experimenter.subtypes[6035143] = bsn_header
1125
1126class bsn_bw_clear_data_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001127 version = 3
1128 type = 4
1129 experimenter = 6035143
1130 subtype = 22
1131
1132 def __init__(self, xid=None, status=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001133 if xid != None:
1134 self.xid = xid
1135 else:
1136 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07001137 if status != None:
1138 self.status = status
1139 else:
1140 self.status = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001141 return
Dan Talaycof6202252013-07-02 01:00:29 -07001142
1143 def pack(self):
1144 packed = []
1145 packed.append(struct.pack("!B", self.version))
1146 packed.append(struct.pack("!B", self.type))
1147 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1148 packed.append(struct.pack("!L", self.xid))
1149 packed.append(struct.pack("!L", self.experimenter))
1150 packed.append(struct.pack("!L", self.subtype))
1151 packed.append(struct.pack("!L", self.status))
1152 length = sum([len(x) for x in packed])
1153 packed[2] = struct.pack("!H", length)
1154 return ''.join(packed)
1155
1156 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001157 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001158 obj = bsn_bw_clear_data_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07001159 _version = reader.read("!B")[0]
1160 assert(_version == 3)
1161 _type = reader.read("!B")[0]
1162 assert(_type == 4)
1163 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001164 orig_reader = reader
1165 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001166 obj.xid = reader.read("!L")[0]
1167 _experimenter = reader.read("!L")[0]
1168 assert(_experimenter == 6035143)
1169 _subtype = reader.read("!L")[0]
1170 assert(_subtype == 22)
1171 obj.status = reader.read("!L")[0]
1172 return obj
1173
1174 def __eq__(self, other):
1175 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07001176 if self.xid != other.xid: return False
1177 if self.status != other.status: return False
1178 return True
1179
Dan Talaycof6202252013-07-02 01:00:29 -07001180 def pretty_print(self, q):
1181 q.text("bsn_bw_clear_data_reply {")
1182 with q.group():
1183 with q.indent(2):
1184 q.breakable()
1185 q.text("xid = ");
1186 if self.xid != None:
1187 q.text("%#x" % self.xid)
1188 else:
1189 q.text('None')
1190 q.text(","); q.breakable()
1191 q.text("status = ");
1192 q.text("%#x" % self.status)
1193 q.breakable()
1194 q.text('}')
1195
Rich Lane7dcdf022013-12-11 14:45:27 -08001196bsn_header.subtypes[22] = bsn_bw_clear_data_reply
1197
1198class bsn_bw_clear_data_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001199 version = 3
1200 type = 4
1201 experimenter = 6035143
1202 subtype = 21
1203
1204 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001205 if xid != None:
1206 self.xid = xid
1207 else:
1208 self.xid = None
1209 return
Dan Talaycof6202252013-07-02 01:00:29 -07001210
1211 def pack(self):
1212 packed = []
1213 packed.append(struct.pack("!B", self.version))
1214 packed.append(struct.pack("!B", self.type))
1215 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1216 packed.append(struct.pack("!L", self.xid))
1217 packed.append(struct.pack("!L", self.experimenter))
1218 packed.append(struct.pack("!L", self.subtype))
1219 length = sum([len(x) for x in packed])
1220 packed[2] = struct.pack("!H", length)
1221 return ''.join(packed)
1222
1223 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001224 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001225 obj = bsn_bw_clear_data_request()
Dan Talaycof6202252013-07-02 01:00:29 -07001226 _version = reader.read("!B")[0]
1227 assert(_version == 3)
1228 _type = reader.read("!B")[0]
1229 assert(_type == 4)
1230 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001231 orig_reader = reader
1232 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001233 obj.xid = reader.read("!L")[0]
1234 _experimenter = reader.read("!L")[0]
1235 assert(_experimenter == 6035143)
1236 _subtype = reader.read("!L")[0]
1237 assert(_subtype == 21)
1238 return obj
1239
1240 def __eq__(self, other):
1241 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07001242 if self.xid != other.xid: return False
1243 return True
1244
Dan Talaycof6202252013-07-02 01:00:29 -07001245 def pretty_print(self, q):
1246 q.text("bsn_bw_clear_data_request {")
1247 with q.group():
1248 with q.indent(2):
1249 q.breakable()
1250 q.text("xid = ");
1251 if self.xid != None:
1252 q.text("%#x" % self.xid)
1253 else:
1254 q.text('None')
1255 q.breakable()
1256 q.text('}')
1257
Rich Lane7dcdf022013-12-11 14:45:27 -08001258bsn_header.subtypes[21] = bsn_bw_clear_data_request
1259
1260class bsn_bw_enable_get_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001261 version = 3
1262 type = 4
1263 experimenter = 6035143
1264 subtype = 20
1265
1266 def __init__(self, xid=None, enabled=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001267 if xid != None:
1268 self.xid = xid
1269 else:
1270 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07001271 if enabled != None:
1272 self.enabled = enabled
1273 else:
1274 self.enabled = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001275 return
Dan Talaycof6202252013-07-02 01:00:29 -07001276
1277 def pack(self):
1278 packed = []
1279 packed.append(struct.pack("!B", self.version))
1280 packed.append(struct.pack("!B", self.type))
1281 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1282 packed.append(struct.pack("!L", self.xid))
1283 packed.append(struct.pack("!L", self.experimenter))
1284 packed.append(struct.pack("!L", self.subtype))
1285 packed.append(struct.pack("!L", self.enabled))
1286 length = sum([len(x) for x in packed])
1287 packed[2] = struct.pack("!H", length)
1288 return ''.join(packed)
1289
1290 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001291 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001292 obj = bsn_bw_enable_get_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07001293 _version = reader.read("!B")[0]
1294 assert(_version == 3)
1295 _type = reader.read("!B")[0]
1296 assert(_type == 4)
1297 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001298 orig_reader = reader
1299 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001300 obj.xid = reader.read("!L")[0]
1301 _experimenter = reader.read("!L")[0]
1302 assert(_experimenter == 6035143)
1303 _subtype = reader.read("!L")[0]
1304 assert(_subtype == 20)
1305 obj.enabled = reader.read("!L")[0]
1306 return obj
1307
1308 def __eq__(self, other):
1309 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07001310 if self.xid != other.xid: return False
1311 if self.enabled != other.enabled: return False
1312 return True
1313
Dan Talaycof6202252013-07-02 01:00:29 -07001314 def pretty_print(self, q):
1315 q.text("bsn_bw_enable_get_reply {")
1316 with q.group():
1317 with q.indent(2):
1318 q.breakable()
1319 q.text("xid = ");
1320 if self.xid != None:
1321 q.text("%#x" % self.xid)
1322 else:
1323 q.text('None')
1324 q.text(","); q.breakable()
1325 q.text("enabled = ");
1326 q.text("%#x" % self.enabled)
1327 q.breakable()
1328 q.text('}')
1329
Rich Lane7dcdf022013-12-11 14:45:27 -08001330bsn_header.subtypes[20] = bsn_bw_enable_get_reply
1331
1332class bsn_bw_enable_get_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001333 version = 3
1334 type = 4
1335 experimenter = 6035143
1336 subtype = 19
1337
1338 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001339 if xid != None:
1340 self.xid = xid
1341 else:
1342 self.xid = None
1343 return
Dan Talaycof6202252013-07-02 01:00:29 -07001344
1345 def pack(self):
1346 packed = []
1347 packed.append(struct.pack("!B", self.version))
1348 packed.append(struct.pack("!B", self.type))
1349 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1350 packed.append(struct.pack("!L", self.xid))
1351 packed.append(struct.pack("!L", self.experimenter))
1352 packed.append(struct.pack("!L", self.subtype))
1353 length = sum([len(x) for x in packed])
1354 packed[2] = struct.pack("!H", length)
1355 return ''.join(packed)
1356
1357 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001358 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001359 obj = bsn_bw_enable_get_request()
Dan Talaycof6202252013-07-02 01:00:29 -07001360 _version = reader.read("!B")[0]
1361 assert(_version == 3)
1362 _type = reader.read("!B")[0]
1363 assert(_type == 4)
1364 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001365 orig_reader = reader
1366 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001367 obj.xid = reader.read("!L")[0]
1368 _experimenter = reader.read("!L")[0]
1369 assert(_experimenter == 6035143)
1370 _subtype = reader.read("!L")[0]
1371 assert(_subtype == 19)
1372 return obj
1373
1374 def __eq__(self, other):
1375 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07001376 if self.xid != other.xid: return False
1377 return True
1378
Dan Talaycof6202252013-07-02 01:00:29 -07001379 def pretty_print(self, q):
1380 q.text("bsn_bw_enable_get_request {")
1381 with q.group():
1382 with q.indent(2):
1383 q.breakable()
1384 q.text("xid = ");
1385 if self.xid != None:
1386 q.text("%#x" % self.xid)
1387 else:
1388 q.text('None')
1389 q.breakable()
1390 q.text('}')
1391
Rich Lane7dcdf022013-12-11 14:45:27 -08001392bsn_header.subtypes[19] = bsn_bw_enable_get_request
1393
1394class bsn_bw_enable_set_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001395 version = 3
1396 type = 4
1397 experimenter = 6035143
1398 subtype = 23
1399
1400 def __init__(self, xid=None, enable=None, status=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001401 if xid != None:
1402 self.xid = xid
1403 else:
1404 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07001405 if enable != None:
1406 self.enable = enable
1407 else:
1408 self.enable = 0
1409 if status != None:
1410 self.status = status
1411 else:
1412 self.status = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001413 return
Dan Talaycof6202252013-07-02 01:00:29 -07001414
1415 def pack(self):
1416 packed = []
1417 packed.append(struct.pack("!B", self.version))
1418 packed.append(struct.pack("!B", self.type))
1419 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1420 packed.append(struct.pack("!L", self.xid))
1421 packed.append(struct.pack("!L", self.experimenter))
1422 packed.append(struct.pack("!L", self.subtype))
1423 packed.append(struct.pack("!L", self.enable))
1424 packed.append(struct.pack("!L", self.status))
1425 length = sum([len(x) for x in packed])
1426 packed[2] = struct.pack("!H", length)
1427 return ''.join(packed)
1428
1429 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001430 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001431 obj = bsn_bw_enable_set_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07001432 _version = reader.read("!B")[0]
1433 assert(_version == 3)
1434 _type = reader.read("!B")[0]
1435 assert(_type == 4)
1436 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001437 orig_reader = reader
1438 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001439 obj.xid = reader.read("!L")[0]
1440 _experimenter = reader.read("!L")[0]
1441 assert(_experimenter == 6035143)
1442 _subtype = reader.read("!L")[0]
1443 assert(_subtype == 23)
1444 obj.enable = reader.read("!L")[0]
1445 obj.status = reader.read("!L")[0]
1446 return obj
1447
1448 def __eq__(self, other):
1449 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07001450 if self.xid != other.xid: return False
1451 if self.enable != other.enable: return False
1452 if self.status != other.status: return False
1453 return True
1454
Dan Talaycof6202252013-07-02 01:00:29 -07001455 def pretty_print(self, q):
1456 q.text("bsn_bw_enable_set_reply {")
1457 with q.group():
1458 with q.indent(2):
1459 q.breakable()
1460 q.text("xid = ");
1461 if self.xid != None:
1462 q.text("%#x" % self.xid)
1463 else:
1464 q.text('None')
1465 q.text(","); q.breakable()
1466 q.text("enable = ");
1467 q.text("%#x" % self.enable)
1468 q.text(","); q.breakable()
1469 q.text("status = ");
1470 q.text("%#x" % self.status)
1471 q.breakable()
1472 q.text('}')
1473
Rich Lane7dcdf022013-12-11 14:45:27 -08001474bsn_header.subtypes[23] = bsn_bw_enable_set_reply
1475
1476class bsn_bw_enable_set_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001477 version = 3
1478 type = 4
1479 experimenter = 6035143
1480 subtype = 18
1481
1482 def __init__(self, xid=None, enable=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001483 if xid != None:
1484 self.xid = xid
1485 else:
1486 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07001487 if enable != None:
1488 self.enable = enable
1489 else:
1490 self.enable = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001491 return
Dan Talaycof6202252013-07-02 01:00:29 -07001492
1493 def pack(self):
1494 packed = []
1495 packed.append(struct.pack("!B", self.version))
1496 packed.append(struct.pack("!B", self.type))
1497 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1498 packed.append(struct.pack("!L", self.xid))
1499 packed.append(struct.pack("!L", self.experimenter))
1500 packed.append(struct.pack("!L", self.subtype))
1501 packed.append(struct.pack("!L", self.enable))
1502 length = sum([len(x) for x in packed])
1503 packed[2] = struct.pack("!H", length)
1504 return ''.join(packed)
1505
1506 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001507 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001508 obj = bsn_bw_enable_set_request()
Dan Talaycof6202252013-07-02 01:00:29 -07001509 _version = reader.read("!B")[0]
1510 assert(_version == 3)
1511 _type = reader.read("!B")[0]
1512 assert(_type == 4)
1513 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001514 orig_reader = reader
1515 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001516 obj.xid = reader.read("!L")[0]
1517 _experimenter = reader.read("!L")[0]
1518 assert(_experimenter == 6035143)
1519 _subtype = reader.read("!L")[0]
1520 assert(_subtype == 18)
1521 obj.enable = reader.read("!L")[0]
1522 return obj
1523
1524 def __eq__(self, other):
1525 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07001526 if self.xid != other.xid: return False
1527 if self.enable != other.enable: return False
1528 return True
1529
Dan Talaycof6202252013-07-02 01:00:29 -07001530 def pretty_print(self, q):
1531 q.text("bsn_bw_enable_set_request {")
1532 with q.group():
1533 with q.indent(2):
1534 q.breakable()
1535 q.text("xid = ");
1536 if self.xid != None:
1537 q.text("%#x" % self.xid)
1538 else:
1539 q.text('None')
1540 q.text(","); q.breakable()
1541 q.text("enable = ");
1542 q.text("%#x" % self.enable)
1543 q.breakable()
1544 q.text('}')
1545
Rich Lane7dcdf022013-12-11 14:45:27 -08001546bsn_header.subtypes[18] = bsn_bw_enable_set_request
1547
1548class bsn_get_interfaces_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001549 version = 3
1550 type = 4
1551 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07001552 subtype = 10
1553
1554 def __init__(self, xid=None, interfaces=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001555 if xid != None:
1556 self.xid = xid
1557 else:
1558 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07001559 if interfaces != None:
1560 self.interfaces = interfaces
1561 else:
1562 self.interfaces = []
Rich Lane7dcdf022013-12-11 14:45:27 -08001563 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07001564
1565 def pack(self):
1566 packed = []
1567 packed.append(struct.pack("!B", self.version))
1568 packed.append(struct.pack("!B", self.type))
1569 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1570 packed.append(struct.pack("!L", self.xid))
1571 packed.append(struct.pack("!L", self.experimenter))
1572 packed.append(struct.pack("!L", self.subtype))
Rich Lane7dcdf022013-12-11 14:45:27 -08001573 packed.append(loxi.generic_util.pack_list(self.interfaces))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001574 length = sum([len(x) for x in packed])
1575 packed[2] = struct.pack("!H", length)
1576 return ''.join(packed)
1577
1578 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001579 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001580 obj = bsn_get_interfaces_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07001581 _version = reader.read("!B")[0]
1582 assert(_version == 3)
1583 _type = reader.read("!B")[0]
1584 assert(_type == 4)
1585 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001586 orig_reader = reader
1587 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001588 obj.xid = reader.read("!L")[0]
1589 _experimenter = reader.read("!L")[0]
1590 assert(_experimenter == 6035143)
1591 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001592 assert(_subtype == 10)
1593 obj.interfaces = loxi.generic_util.unpack_list(reader, common.bsn_interface.unpack)
1594 return obj
1595
1596 def __eq__(self, other):
1597 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001598 if self.xid != other.xid: return False
1599 if self.interfaces != other.interfaces: return False
1600 return True
1601
Rich Lanec2ee4b82013-04-24 17:12:38 -07001602 def pretty_print(self, q):
1603 q.text("bsn_get_interfaces_reply {")
1604 with q.group():
1605 with q.indent(2):
1606 q.breakable()
1607 q.text("xid = ");
1608 if self.xid != None:
1609 q.text("%#x" % self.xid)
1610 else:
1611 q.text('None')
1612 q.text(","); q.breakable()
1613 q.text("interfaces = ");
1614 q.pp(self.interfaces)
1615 q.breakable()
1616 q.text('}')
1617
Rich Lane7dcdf022013-12-11 14:45:27 -08001618bsn_header.subtypes[10] = bsn_get_interfaces_reply
1619
1620class bsn_get_interfaces_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001621 version = 3
1622 type = 4
1623 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07001624 subtype = 9
1625
1626 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001627 if xid != None:
1628 self.xid = xid
1629 else:
1630 self.xid = None
1631 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07001632
1633 def pack(self):
1634 packed = []
1635 packed.append(struct.pack("!B", self.version))
1636 packed.append(struct.pack("!B", self.type))
1637 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1638 packed.append(struct.pack("!L", self.xid))
1639 packed.append(struct.pack("!L", self.experimenter))
1640 packed.append(struct.pack("!L", self.subtype))
1641 length = sum([len(x) for x in packed])
1642 packed[2] = struct.pack("!H", length)
1643 return ''.join(packed)
1644
1645 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001646 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001647 obj = bsn_get_interfaces_request()
Dan Talaycof6202252013-07-02 01:00:29 -07001648 _version = reader.read("!B")[0]
1649 assert(_version == 3)
1650 _type = reader.read("!B")[0]
1651 assert(_type == 4)
1652 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001653 orig_reader = reader
1654 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001655 obj.xid = reader.read("!L")[0]
1656 _experimenter = reader.read("!L")[0]
1657 assert(_experimenter == 6035143)
1658 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001659 assert(_subtype == 9)
1660 return obj
1661
1662 def __eq__(self, other):
1663 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001664 if self.xid != other.xid: return False
1665 return True
1666
Rich Lanec2ee4b82013-04-24 17:12:38 -07001667 def pretty_print(self, q):
1668 q.text("bsn_get_interfaces_request {")
1669 with q.group():
1670 with q.indent(2):
1671 q.breakable()
1672 q.text("xid = ");
1673 if self.xid != None:
1674 q.text("%#x" % self.xid)
1675 else:
1676 q.text('None')
1677 q.breakable()
1678 q.text('}')
1679
Rich Lane7dcdf022013-12-11 14:45:27 -08001680bsn_header.subtypes[9] = bsn_get_interfaces_request
1681
1682class bsn_get_mirroring_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001683 version = 3
1684 type = 4
1685 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07001686 subtype = 5
1687
1688 def __init__(self, xid=None, report_mirror_ports=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001689 if xid != None:
1690 self.xid = xid
1691 else:
1692 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07001693 if report_mirror_ports != None:
1694 self.report_mirror_ports = report_mirror_ports
1695 else:
1696 self.report_mirror_ports = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001697 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07001698
1699 def pack(self):
1700 packed = []
1701 packed.append(struct.pack("!B", self.version))
1702 packed.append(struct.pack("!B", self.type))
1703 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1704 packed.append(struct.pack("!L", self.xid))
1705 packed.append(struct.pack("!L", self.experimenter))
1706 packed.append(struct.pack("!L", self.subtype))
1707 packed.append(struct.pack("!B", self.report_mirror_ports))
1708 packed.append('\x00' * 3)
1709 length = sum([len(x) for x in packed])
1710 packed[2] = struct.pack("!H", length)
1711 return ''.join(packed)
1712
1713 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001714 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001715 obj = bsn_get_mirroring_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07001716 _version = reader.read("!B")[0]
1717 assert(_version == 3)
1718 _type = reader.read("!B")[0]
1719 assert(_type == 4)
1720 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001721 orig_reader = reader
1722 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001723 obj.xid = reader.read("!L")[0]
1724 _experimenter = reader.read("!L")[0]
1725 assert(_experimenter == 6035143)
1726 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001727 assert(_subtype == 5)
Dan Talaycof6202252013-07-02 01:00:29 -07001728 obj.report_mirror_ports = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001729 reader.skip(3)
1730 return obj
1731
1732 def __eq__(self, other):
1733 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001734 if self.xid != other.xid: return False
1735 if self.report_mirror_ports != other.report_mirror_ports: return False
1736 return True
1737
Rich Lanec2ee4b82013-04-24 17:12:38 -07001738 def pretty_print(self, q):
1739 q.text("bsn_get_mirroring_reply {")
1740 with q.group():
1741 with q.indent(2):
1742 q.breakable()
1743 q.text("xid = ");
1744 if self.xid != None:
1745 q.text("%#x" % self.xid)
1746 else:
1747 q.text('None')
1748 q.text(","); q.breakable()
1749 q.text("report_mirror_ports = ");
1750 q.text("%#x" % self.report_mirror_ports)
1751 q.breakable()
1752 q.text('}')
1753
Rich Lane7dcdf022013-12-11 14:45:27 -08001754bsn_header.subtypes[5] = bsn_get_mirroring_reply
1755
1756class bsn_get_mirroring_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001757 version = 3
1758 type = 4
1759 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07001760 subtype = 4
1761
1762 def __init__(self, xid=None, report_mirror_ports=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001763 if xid != None:
1764 self.xid = xid
1765 else:
1766 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07001767 if report_mirror_ports != None:
1768 self.report_mirror_ports = report_mirror_ports
1769 else:
1770 self.report_mirror_ports = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001771 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07001772
1773 def pack(self):
1774 packed = []
1775 packed.append(struct.pack("!B", self.version))
1776 packed.append(struct.pack("!B", self.type))
1777 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1778 packed.append(struct.pack("!L", self.xid))
1779 packed.append(struct.pack("!L", self.experimenter))
1780 packed.append(struct.pack("!L", self.subtype))
1781 packed.append(struct.pack("!B", self.report_mirror_ports))
1782 packed.append('\x00' * 3)
1783 length = sum([len(x) for x in packed])
1784 packed[2] = struct.pack("!H", length)
1785 return ''.join(packed)
1786
1787 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001788 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001789 obj = bsn_get_mirroring_request()
Dan Talaycof6202252013-07-02 01:00:29 -07001790 _version = reader.read("!B")[0]
1791 assert(_version == 3)
1792 _type = reader.read("!B")[0]
1793 assert(_type == 4)
1794 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001795 orig_reader = reader
1796 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001797 obj.xid = reader.read("!L")[0]
1798 _experimenter = reader.read("!L")[0]
1799 assert(_experimenter == 6035143)
1800 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001801 assert(_subtype == 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001802 obj.report_mirror_ports = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001803 reader.skip(3)
1804 return obj
1805
1806 def __eq__(self, other):
1807 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001808 if self.xid != other.xid: return False
1809 if self.report_mirror_ports != other.report_mirror_ports: return False
1810 return True
1811
Rich Lanec2ee4b82013-04-24 17:12:38 -07001812 def pretty_print(self, q):
1813 q.text("bsn_get_mirroring_request {")
1814 with q.group():
1815 with q.indent(2):
1816 q.breakable()
1817 q.text("xid = ");
1818 if self.xid != None:
1819 q.text("%#x" % self.xid)
1820 else:
1821 q.text('None')
1822 q.text(","); q.breakable()
1823 q.text("report_mirror_ports = ");
1824 q.text("%#x" % self.report_mirror_ports)
1825 q.breakable()
1826 q.text('}')
1827
Rich Lane7dcdf022013-12-11 14:45:27 -08001828bsn_header.subtypes[4] = bsn_get_mirroring_request
1829
1830class bsn_pdu_rx_reply(bsn_header):
Rich Lane6f4978c2013-10-20 21:33:52 -07001831 version = 3
1832 type = 4
1833 experimenter = 6035143
1834 subtype = 34
1835
Rich Lane7b0f2012013-11-22 14:15:26 -08001836 def __init__(self, xid=None, status=None, port_no=None, slot_num=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001837 if xid != None:
1838 self.xid = xid
1839 else:
1840 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07001841 if status != None:
1842 self.status = status
1843 else:
1844 self.status = 0
Rich Lane7b0f2012013-11-22 14:15:26 -08001845 if port_no != None:
1846 self.port_no = port_no
1847 else:
1848 self.port_no = 0
1849 if slot_num != None:
1850 self.slot_num = slot_num
1851 else:
1852 self.slot_num = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001853 return
Rich Lane6f4978c2013-10-20 21:33:52 -07001854
1855 def pack(self):
1856 packed = []
1857 packed.append(struct.pack("!B", self.version))
1858 packed.append(struct.pack("!B", self.type))
1859 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1860 packed.append(struct.pack("!L", self.xid))
1861 packed.append(struct.pack("!L", self.experimenter))
1862 packed.append(struct.pack("!L", self.subtype))
1863 packed.append(struct.pack("!L", self.status))
Rich Lane7b0f2012013-11-22 14:15:26 -08001864 packed.append(util.pack_port_no(self.port_no))
1865 packed.append(struct.pack("!B", self.slot_num))
Rich Lane6f4978c2013-10-20 21:33:52 -07001866 length = sum([len(x) for x in packed])
1867 packed[2] = struct.pack("!H", length)
1868 return ''.join(packed)
1869
1870 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001871 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07001872 obj = bsn_pdu_rx_reply()
Rich Lane6f4978c2013-10-20 21:33:52 -07001873 _version = reader.read("!B")[0]
1874 assert(_version == 3)
1875 _type = reader.read("!B")[0]
1876 assert(_type == 4)
1877 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001878 orig_reader = reader
1879 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07001880 obj.xid = reader.read("!L")[0]
1881 _experimenter = reader.read("!L")[0]
1882 assert(_experimenter == 6035143)
1883 _subtype = reader.read("!L")[0]
1884 assert(_subtype == 34)
1885 obj.status = reader.read("!L")[0]
Rich Lane7b0f2012013-11-22 14:15:26 -08001886 obj.port_no = util.unpack_port_no(reader)
1887 obj.slot_num = reader.read("!B")[0]
Rich Lane6f4978c2013-10-20 21:33:52 -07001888 return obj
1889
1890 def __eq__(self, other):
1891 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001892 if self.xid != other.xid: return False
1893 if self.status != other.status: return False
Rich Lane7b0f2012013-11-22 14:15:26 -08001894 if self.port_no != other.port_no: return False
1895 if self.slot_num != other.slot_num: return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001896 return True
1897
Rich Lane6f4978c2013-10-20 21:33:52 -07001898 def pretty_print(self, q):
1899 q.text("bsn_pdu_rx_reply {")
1900 with q.group():
1901 with q.indent(2):
1902 q.breakable()
1903 q.text("xid = ");
1904 if self.xid != None:
1905 q.text("%#x" % self.xid)
1906 else:
1907 q.text('None')
1908 q.text(","); q.breakable()
1909 q.text("status = ");
1910 q.text("%#x" % self.status)
Rich Lane7b0f2012013-11-22 14:15:26 -08001911 q.text(","); q.breakable()
1912 q.text("port_no = ");
1913 q.text(util.pretty_port(self.port_no))
1914 q.text(","); q.breakable()
1915 q.text("slot_num = ");
1916 q.text("%#x" % self.slot_num)
Rich Lane6f4978c2013-10-20 21:33:52 -07001917 q.breakable()
1918 q.text('}')
1919
Rich Lane7dcdf022013-12-11 14:45:27 -08001920bsn_header.subtypes[34] = bsn_pdu_rx_reply
1921
1922class bsn_pdu_rx_request(bsn_header):
Rich Lane6f4978c2013-10-20 21:33:52 -07001923 version = 3
1924 type = 4
1925 experimenter = 6035143
1926 subtype = 33
1927
1928 def __init__(self, xid=None, timeout_ms=None, port_no=None, slot_num=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001929 if xid != None:
1930 self.xid = xid
1931 else:
1932 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07001933 if timeout_ms != None:
1934 self.timeout_ms = timeout_ms
1935 else:
1936 self.timeout_ms = 0
1937 if port_no != None:
1938 self.port_no = port_no
1939 else:
1940 self.port_no = 0
1941 if slot_num != None:
1942 self.slot_num = slot_num
1943 else:
1944 self.slot_num = 0
1945 if data != None:
1946 self.data = data
1947 else:
1948 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08001949 return
Rich Lane6f4978c2013-10-20 21:33:52 -07001950
1951 def pack(self):
1952 packed = []
1953 packed.append(struct.pack("!B", self.version))
1954 packed.append(struct.pack("!B", self.type))
1955 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1956 packed.append(struct.pack("!L", self.xid))
1957 packed.append(struct.pack("!L", self.experimenter))
1958 packed.append(struct.pack("!L", self.subtype))
1959 packed.append(struct.pack("!L", self.timeout_ms))
1960 packed.append(util.pack_port_no(self.port_no))
1961 packed.append(struct.pack("!B", self.slot_num))
1962 packed.append('\x00' * 3)
1963 packed.append(self.data)
1964 length = sum([len(x) for x in packed])
1965 packed[2] = struct.pack("!H", length)
1966 return ''.join(packed)
1967
1968 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001969 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07001970 obj = bsn_pdu_rx_request()
Rich Lane6f4978c2013-10-20 21:33:52 -07001971 _version = reader.read("!B")[0]
1972 assert(_version == 3)
1973 _type = reader.read("!B")[0]
1974 assert(_type == 4)
1975 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001976 orig_reader = reader
1977 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07001978 obj.xid = reader.read("!L")[0]
1979 _experimenter = reader.read("!L")[0]
1980 assert(_experimenter == 6035143)
1981 _subtype = reader.read("!L")[0]
1982 assert(_subtype == 33)
1983 obj.timeout_ms = reader.read("!L")[0]
1984 obj.port_no = util.unpack_port_no(reader)
1985 obj.slot_num = reader.read("!B")[0]
1986 reader.skip(3)
1987 obj.data = str(reader.read_all())
1988 return obj
1989
1990 def __eq__(self, other):
1991 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001992 if self.xid != other.xid: return False
1993 if self.timeout_ms != other.timeout_ms: return False
1994 if self.port_no != other.port_no: return False
1995 if self.slot_num != other.slot_num: return False
1996 if self.data != other.data: return False
1997 return True
1998
Rich Lane6f4978c2013-10-20 21:33:52 -07001999 def pretty_print(self, q):
2000 q.text("bsn_pdu_rx_request {")
2001 with q.group():
2002 with q.indent(2):
2003 q.breakable()
2004 q.text("xid = ");
2005 if self.xid != None:
2006 q.text("%#x" % self.xid)
2007 else:
2008 q.text('None')
2009 q.text(","); q.breakable()
2010 q.text("timeout_ms = ");
2011 q.text("%#x" % self.timeout_ms)
2012 q.text(","); q.breakable()
2013 q.text("port_no = ");
2014 q.text(util.pretty_port(self.port_no))
2015 q.text(","); q.breakable()
2016 q.text("slot_num = ");
2017 q.text("%#x" % self.slot_num)
2018 q.text(","); q.breakable()
2019 q.text("data = ");
2020 q.pp(self.data)
2021 q.breakable()
2022 q.text('}')
2023
Rich Lane7dcdf022013-12-11 14:45:27 -08002024bsn_header.subtypes[33] = bsn_pdu_rx_request
2025
2026class bsn_pdu_rx_timeout(bsn_header):
Rich Lane6f4978c2013-10-20 21:33:52 -07002027 version = 3
2028 type = 4
2029 experimenter = 6035143
2030 subtype = 35
2031
2032 def __init__(self, xid=None, port_no=None, slot_num=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002033 if xid != None:
2034 self.xid = xid
2035 else:
2036 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07002037 if port_no != None:
2038 self.port_no = port_no
2039 else:
2040 self.port_no = 0
2041 if slot_num != None:
2042 self.slot_num = slot_num
2043 else:
2044 self.slot_num = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002045 return
Rich Lane6f4978c2013-10-20 21:33:52 -07002046
2047 def pack(self):
2048 packed = []
2049 packed.append(struct.pack("!B", self.version))
2050 packed.append(struct.pack("!B", self.type))
2051 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2052 packed.append(struct.pack("!L", self.xid))
2053 packed.append(struct.pack("!L", self.experimenter))
2054 packed.append(struct.pack("!L", self.subtype))
2055 packed.append(util.pack_port_no(self.port_no))
2056 packed.append(struct.pack("!B", self.slot_num))
2057 length = sum([len(x) for x in packed])
2058 packed[2] = struct.pack("!H", length)
2059 return ''.join(packed)
2060
2061 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002062 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07002063 obj = bsn_pdu_rx_timeout()
Rich Lane6f4978c2013-10-20 21:33:52 -07002064 _version = reader.read("!B")[0]
2065 assert(_version == 3)
2066 _type = reader.read("!B")[0]
2067 assert(_type == 4)
2068 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002069 orig_reader = reader
2070 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07002071 obj.xid = reader.read("!L")[0]
2072 _experimenter = reader.read("!L")[0]
2073 assert(_experimenter == 6035143)
2074 _subtype = reader.read("!L")[0]
2075 assert(_subtype == 35)
2076 obj.port_no = util.unpack_port_no(reader)
2077 obj.slot_num = reader.read("!B")[0]
2078 return obj
2079
2080 def __eq__(self, other):
2081 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07002082 if self.xid != other.xid: return False
2083 if self.port_no != other.port_no: return False
2084 if self.slot_num != other.slot_num: return False
2085 return True
2086
Rich Lane6f4978c2013-10-20 21:33:52 -07002087 def pretty_print(self, q):
2088 q.text("bsn_pdu_rx_timeout {")
2089 with q.group():
2090 with q.indent(2):
2091 q.breakable()
2092 q.text("xid = ");
2093 if self.xid != None:
2094 q.text("%#x" % self.xid)
2095 else:
2096 q.text('None')
2097 q.text(","); q.breakable()
2098 q.text("port_no = ");
2099 q.text(util.pretty_port(self.port_no))
2100 q.text(","); q.breakable()
2101 q.text("slot_num = ");
2102 q.text("%#x" % self.slot_num)
2103 q.breakable()
2104 q.text('}')
2105
Rich Lane7dcdf022013-12-11 14:45:27 -08002106bsn_header.subtypes[35] = bsn_pdu_rx_timeout
2107
2108class bsn_pdu_tx_reply(bsn_header):
Rich Lane6f4978c2013-10-20 21:33:52 -07002109 version = 3
2110 type = 4
2111 experimenter = 6035143
2112 subtype = 32
2113
Rich Lane7b0f2012013-11-22 14:15:26 -08002114 def __init__(self, xid=None, status=None, port_no=None, slot_num=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002115 if xid != None:
2116 self.xid = xid
2117 else:
2118 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07002119 if status != None:
2120 self.status = status
2121 else:
2122 self.status = 0
Rich Lane7b0f2012013-11-22 14:15:26 -08002123 if port_no != None:
2124 self.port_no = port_no
2125 else:
2126 self.port_no = 0
2127 if slot_num != None:
2128 self.slot_num = slot_num
2129 else:
2130 self.slot_num = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002131 return
Rich Lane6f4978c2013-10-20 21:33:52 -07002132
2133 def pack(self):
2134 packed = []
2135 packed.append(struct.pack("!B", self.version))
2136 packed.append(struct.pack("!B", self.type))
2137 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2138 packed.append(struct.pack("!L", self.xid))
2139 packed.append(struct.pack("!L", self.experimenter))
2140 packed.append(struct.pack("!L", self.subtype))
2141 packed.append(struct.pack("!L", self.status))
Rich Lane7b0f2012013-11-22 14:15:26 -08002142 packed.append(util.pack_port_no(self.port_no))
2143 packed.append(struct.pack("!B", self.slot_num))
Rich Lane6f4978c2013-10-20 21:33:52 -07002144 length = sum([len(x) for x in packed])
2145 packed[2] = struct.pack("!H", length)
2146 return ''.join(packed)
2147
2148 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002149 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07002150 obj = bsn_pdu_tx_reply()
Rich Lane6f4978c2013-10-20 21:33:52 -07002151 _version = reader.read("!B")[0]
2152 assert(_version == 3)
2153 _type = reader.read("!B")[0]
2154 assert(_type == 4)
2155 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002156 orig_reader = reader
2157 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07002158 obj.xid = reader.read("!L")[0]
2159 _experimenter = reader.read("!L")[0]
2160 assert(_experimenter == 6035143)
2161 _subtype = reader.read("!L")[0]
2162 assert(_subtype == 32)
2163 obj.status = reader.read("!L")[0]
Rich Lane7b0f2012013-11-22 14:15:26 -08002164 obj.port_no = util.unpack_port_no(reader)
2165 obj.slot_num = reader.read("!B")[0]
Rich Lane6f4978c2013-10-20 21:33:52 -07002166 return obj
2167
2168 def __eq__(self, other):
2169 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07002170 if self.xid != other.xid: return False
2171 if self.status != other.status: return False
Rich Lane7b0f2012013-11-22 14:15:26 -08002172 if self.port_no != other.port_no: return False
2173 if self.slot_num != other.slot_num: return False
Rich Lane6f4978c2013-10-20 21:33:52 -07002174 return True
2175
Rich Lane6f4978c2013-10-20 21:33:52 -07002176 def pretty_print(self, q):
2177 q.text("bsn_pdu_tx_reply {")
2178 with q.group():
2179 with q.indent(2):
2180 q.breakable()
2181 q.text("xid = ");
2182 if self.xid != None:
2183 q.text("%#x" % self.xid)
2184 else:
2185 q.text('None')
2186 q.text(","); q.breakable()
2187 q.text("status = ");
2188 q.text("%#x" % self.status)
Rich Lane7b0f2012013-11-22 14:15:26 -08002189 q.text(","); q.breakable()
2190 q.text("port_no = ");
2191 q.text(util.pretty_port(self.port_no))
2192 q.text(","); q.breakable()
2193 q.text("slot_num = ");
2194 q.text("%#x" % self.slot_num)
Rich Lane6f4978c2013-10-20 21:33:52 -07002195 q.breakable()
2196 q.text('}')
2197
Rich Lane7dcdf022013-12-11 14:45:27 -08002198bsn_header.subtypes[32] = bsn_pdu_tx_reply
2199
2200class bsn_pdu_tx_request(bsn_header):
Rich Lane6f4978c2013-10-20 21:33:52 -07002201 version = 3
2202 type = 4
2203 experimenter = 6035143
2204 subtype = 31
2205
2206 def __init__(self, xid=None, tx_interval_ms=None, port_no=None, slot_num=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002207 if xid != None:
2208 self.xid = xid
2209 else:
2210 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07002211 if tx_interval_ms != None:
2212 self.tx_interval_ms = tx_interval_ms
2213 else:
2214 self.tx_interval_ms = 0
2215 if port_no != None:
2216 self.port_no = port_no
2217 else:
2218 self.port_no = 0
2219 if slot_num != None:
2220 self.slot_num = slot_num
2221 else:
2222 self.slot_num = 0
2223 if data != None:
2224 self.data = data
2225 else:
2226 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08002227 return
Rich Lane6f4978c2013-10-20 21:33:52 -07002228
2229 def pack(self):
2230 packed = []
2231 packed.append(struct.pack("!B", self.version))
2232 packed.append(struct.pack("!B", self.type))
2233 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2234 packed.append(struct.pack("!L", self.xid))
2235 packed.append(struct.pack("!L", self.experimenter))
2236 packed.append(struct.pack("!L", self.subtype))
2237 packed.append(struct.pack("!L", self.tx_interval_ms))
2238 packed.append(util.pack_port_no(self.port_no))
2239 packed.append(struct.pack("!B", self.slot_num))
2240 packed.append('\x00' * 3)
2241 packed.append(self.data)
2242 length = sum([len(x) for x in packed])
2243 packed[2] = struct.pack("!H", length)
2244 return ''.join(packed)
2245
2246 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002247 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07002248 obj = bsn_pdu_tx_request()
Rich Lane6f4978c2013-10-20 21:33:52 -07002249 _version = reader.read("!B")[0]
2250 assert(_version == 3)
2251 _type = reader.read("!B")[0]
2252 assert(_type == 4)
2253 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002254 orig_reader = reader
2255 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07002256 obj.xid = reader.read("!L")[0]
2257 _experimenter = reader.read("!L")[0]
2258 assert(_experimenter == 6035143)
2259 _subtype = reader.read("!L")[0]
2260 assert(_subtype == 31)
2261 obj.tx_interval_ms = reader.read("!L")[0]
2262 obj.port_no = util.unpack_port_no(reader)
2263 obj.slot_num = reader.read("!B")[0]
2264 reader.skip(3)
2265 obj.data = str(reader.read_all())
2266 return obj
2267
2268 def __eq__(self, other):
2269 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07002270 if self.xid != other.xid: return False
2271 if self.tx_interval_ms != other.tx_interval_ms: return False
2272 if self.port_no != other.port_no: return False
2273 if self.slot_num != other.slot_num: return False
2274 if self.data != other.data: return False
2275 return True
2276
Rich Lane6f4978c2013-10-20 21:33:52 -07002277 def pretty_print(self, q):
2278 q.text("bsn_pdu_tx_request {")
2279 with q.group():
2280 with q.indent(2):
2281 q.breakable()
2282 q.text("xid = ");
2283 if self.xid != None:
2284 q.text("%#x" % self.xid)
2285 else:
2286 q.text('None')
2287 q.text(","); q.breakable()
2288 q.text("tx_interval_ms = ");
2289 q.text("%#x" % self.tx_interval_ms)
2290 q.text(","); q.breakable()
2291 q.text("port_no = ");
2292 q.text(util.pretty_port(self.port_no))
2293 q.text(","); q.breakable()
2294 q.text("slot_num = ");
2295 q.text("%#x" % self.slot_num)
2296 q.text(","); q.breakable()
2297 q.text("data = ");
2298 q.pp(self.data)
2299 q.breakable()
2300 q.text('}')
2301
Rich Lane7dcdf022013-12-11 14:45:27 -08002302bsn_header.subtypes[31] = bsn_pdu_tx_request
2303
2304class bsn_set_mirroring(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07002305 version = 3
2306 type = 4
2307 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07002308 subtype = 3
2309
2310 def __init__(self, xid=None, report_mirror_ports=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002311 if xid != None:
2312 self.xid = xid
2313 else:
2314 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07002315 if report_mirror_ports != None:
2316 self.report_mirror_ports = report_mirror_ports
2317 else:
2318 self.report_mirror_ports = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002319 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07002320
2321 def pack(self):
2322 packed = []
2323 packed.append(struct.pack("!B", self.version))
2324 packed.append(struct.pack("!B", self.type))
2325 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2326 packed.append(struct.pack("!L", self.xid))
2327 packed.append(struct.pack("!L", self.experimenter))
2328 packed.append(struct.pack("!L", self.subtype))
2329 packed.append(struct.pack("!B", self.report_mirror_ports))
2330 packed.append('\x00' * 3)
2331 length = sum([len(x) for x in packed])
2332 packed[2] = struct.pack("!H", length)
2333 return ''.join(packed)
2334
2335 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002336 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002337 obj = bsn_set_mirroring()
Dan Talaycof6202252013-07-02 01:00:29 -07002338 _version = reader.read("!B")[0]
2339 assert(_version == 3)
2340 _type = reader.read("!B")[0]
2341 assert(_type == 4)
2342 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002343 orig_reader = reader
2344 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002345 obj.xid = reader.read("!L")[0]
2346 _experimenter = reader.read("!L")[0]
2347 assert(_experimenter == 6035143)
2348 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002349 assert(_subtype == 3)
Dan Talaycof6202252013-07-02 01:00:29 -07002350 obj.report_mirror_ports = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002351 reader.skip(3)
2352 return obj
2353
2354 def __eq__(self, other):
2355 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002356 if self.xid != other.xid: return False
2357 if self.report_mirror_ports != other.report_mirror_ports: return False
2358 return True
2359
Rich Lanec2ee4b82013-04-24 17:12:38 -07002360 def pretty_print(self, q):
2361 q.text("bsn_set_mirroring {")
2362 with q.group():
2363 with q.indent(2):
2364 q.breakable()
2365 q.text("xid = ");
2366 if self.xid != None:
2367 q.text("%#x" % self.xid)
2368 else:
2369 q.text('None')
2370 q.text(","); q.breakable()
2371 q.text("report_mirror_ports = ");
2372 q.text("%#x" % self.report_mirror_ports)
2373 q.breakable()
2374 q.text('}')
2375
Rich Lane7dcdf022013-12-11 14:45:27 -08002376bsn_header.subtypes[3] = bsn_set_mirroring
2377
2378class bsn_set_pktin_suppression_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07002379 version = 3
2380 type = 4
2381 experimenter = 6035143
2382 subtype = 25
2383
2384 def __init__(self, xid=None, status=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002385 if xid != None:
2386 self.xid = xid
2387 else:
2388 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07002389 if status != None:
2390 self.status = status
2391 else:
2392 self.status = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002393 return
Dan Talaycof6202252013-07-02 01:00:29 -07002394
2395 def pack(self):
2396 packed = []
2397 packed.append(struct.pack("!B", self.version))
2398 packed.append(struct.pack("!B", self.type))
2399 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2400 packed.append(struct.pack("!L", self.xid))
2401 packed.append(struct.pack("!L", self.experimenter))
2402 packed.append(struct.pack("!L", self.subtype))
2403 packed.append(struct.pack("!L", self.status))
2404 length = sum([len(x) for x in packed])
2405 packed[2] = struct.pack("!H", length)
2406 return ''.join(packed)
2407
2408 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002409 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07002410 obj = bsn_set_pktin_suppression_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07002411 _version = reader.read("!B")[0]
2412 assert(_version == 3)
2413 _type = reader.read("!B")[0]
2414 assert(_type == 4)
2415 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002416 orig_reader = reader
2417 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002418 obj.xid = reader.read("!L")[0]
2419 _experimenter = reader.read("!L")[0]
2420 assert(_experimenter == 6035143)
2421 _subtype = reader.read("!L")[0]
2422 assert(_subtype == 25)
2423 obj.status = reader.read("!L")[0]
2424 return obj
2425
2426 def __eq__(self, other):
2427 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07002428 if self.xid != other.xid: return False
2429 if self.status != other.status: return False
2430 return True
2431
Dan Talaycof6202252013-07-02 01:00:29 -07002432 def pretty_print(self, q):
2433 q.text("bsn_set_pktin_suppression_reply {")
2434 with q.group():
2435 with q.indent(2):
2436 q.breakable()
2437 q.text("xid = ");
2438 if self.xid != None:
2439 q.text("%#x" % self.xid)
2440 else:
2441 q.text('None')
2442 q.text(","); q.breakable()
2443 q.text("status = ");
2444 q.text("%#x" % self.status)
2445 q.breakable()
2446 q.text('}')
2447
Rich Lane7dcdf022013-12-11 14:45:27 -08002448bsn_header.subtypes[25] = bsn_set_pktin_suppression_reply
2449
2450class bsn_set_pktin_suppression_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07002451 version = 3
2452 type = 4
2453 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07002454 subtype = 11
2455
2456 def __init__(self, xid=None, enabled=None, idle_timeout=None, hard_timeout=None, priority=None, cookie=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002457 if xid != None:
2458 self.xid = xid
2459 else:
2460 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07002461 if enabled != None:
2462 self.enabled = enabled
2463 else:
2464 self.enabled = 0
2465 if idle_timeout != None:
2466 self.idle_timeout = idle_timeout
2467 else:
2468 self.idle_timeout = 0
2469 if hard_timeout != None:
2470 self.hard_timeout = hard_timeout
2471 else:
2472 self.hard_timeout = 0
2473 if priority != None:
2474 self.priority = priority
2475 else:
2476 self.priority = 0
2477 if cookie != None:
2478 self.cookie = cookie
2479 else:
2480 self.cookie = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002481 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07002482
2483 def pack(self):
2484 packed = []
2485 packed.append(struct.pack("!B", self.version))
2486 packed.append(struct.pack("!B", self.type))
2487 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2488 packed.append(struct.pack("!L", self.xid))
2489 packed.append(struct.pack("!L", self.experimenter))
2490 packed.append(struct.pack("!L", self.subtype))
2491 packed.append(struct.pack("!B", self.enabled))
2492 packed.append('\x00' * 1)
2493 packed.append(struct.pack("!H", self.idle_timeout))
2494 packed.append(struct.pack("!H", self.hard_timeout))
2495 packed.append(struct.pack("!H", self.priority))
2496 packed.append(struct.pack("!Q", self.cookie))
2497 length = sum([len(x) for x in packed])
2498 packed[2] = struct.pack("!H", length)
2499 return ''.join(packed)
2500
2501 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002502 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07002503 obj = bsn_set_pktin_suppression_request()
Dan Talaycof6202252013-07-02 01:00:29 -07002504 _version = reader.read("!B")[0]
2505 assert(_version == 3)
2506 _type = reader.read("!B")[0]
2507 assert(_type == 4)
2508 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002509 orig_reader = reader
2510 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002511 obj.xid = reader.read("!L")[0]
2512 _experimenter = reader.read("!L")[0]
2513 assert(_experimenter == 6035143)
2514 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002515 assert(_subtype == 11)
Dan Talaycof6202252013-07-02 01:00:29 -07002516 obj.enabled = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002517 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -07002518 obj.idle_timeout = reader.read("!H")[0]
2519 obj.hard_timeout = reader.read("!H")[0]
2520 obj.priority = reader.read("!H")[0]
2521 obj.cookie = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002522 return obj
2523
2524 def __eq__(self, other):
2525 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002526 if self.xid != other.xid: return False
2527 if self.enabled != other.enabled: return False
2528 if self.idle_timeout != other.idle_timeout: return False
2529 if self.hard_timeout != other.hard_timeout: return False
2530 if self.priority != other.priority: return False
2531 if self.cookie != other.cookie: return False
2532 return True
2533
Rich Lanec2ee4b82013-04-24 17:12:38 -07002534 def pretty_print(self, q):
Dan Talaycof6202252013-07-02 01:00:29 -07002535 q.text("bsn_set_pktin_suppression_request {")
Rich Lanec2ee4b82013-04-24 17:12:38 -07002536 with q.group():
2537 with q.indent(2):
2538 q.breakable()
2539 q.text("xid = ");
2540 if self.xid != None:
2541 q.text("%#x" % self.xid)
2542 else:
2543 q.text('None')
2544 q.text(","); q.breakable()
2545 q.text("enabled = ");
2546 q.text("%#x" % self.enabled)
2547 q.text(","); q.breakable()
2548 q.text("idle_timeout = ");
2549 q.text("%#x" % self.idle_timeout)
2550 q.text(","); q.breakable()
2551 q.text("hard_timeout = ");
2552 q.text("%#x" % self.hard_timeout)
2553 q.text(","); q.breakable()
2554 q.text("priority = ");
2555 q.text("%#x" % self.priority)
2556 q.text(","); q.breakable()
2557 q.text("cookie = ");
2558 q.text("%#x" % self.cookie)
2559 q.breakable()
2560 q.text('}')
2561
Rich Lane7dcdf022013-12-11 14:45:27 -08002562bsn_header.subtypes[11] = bsn_set_pktin_suppression_request
2563
2564class experimenter_stats_reply(stats_reply):
2565 subtypes = {}
2566
Rich Lane95f7fc92014-01-27 17:08:16 -08002567 version = 3
2568 type = 19
2569 stats_type = 65535
2570
2571 def __init__(self, xid=None, flags=None, experimenter=None, subtype=None, data=None):
2572 if xid != None:
2573 self.xid = xid
2574 else:
2575 self.xid = None
2576 if flags != None:
2577 self.flags = flags
2578 else:
2579 self.flags = 0
2580 if experimenter != None:
2581 self.experimenter = experimenter
2582 else:
2583 self.experimenter = 0
2584 if subtype != None:
2585 self.subtype = subtype
2586 else:
2587 self.subtype = 0
2588 if data != None:
2589 self.data = data
2590 else:
2591 self.data = ''
2592 return
2593
2594 def pack(self):
2595 packed = []
2596 packed.append(struct.pack("!B", self.version))
2597 packed.append(struct.pack("!B", self.type))
2598 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2599 packed.append(struct.pack("!L", self.xid))
2600 packed.append(struct.pack("!H", self.stats_type))
2601 packed.append(struct.pack("!H", self.flags))
2602 packed.append('\x00' * 4)
2603 packed.append(struct.pack("!L", self.experimenter))
2604 packed.append(struct.pack("!L", self.subtype))
2605 packed.append(self.data)
2606 length = sum([len(x) for x in packed])
2607 packed[2] = struct.pack("!H", length)
2608 return ''.join(packed)
2609
Rich Lane7dcdf022013-12-11 14:45:27 -08002610 @staticmethod
2611 def unpack(reader):
2612 subtype, = reader.peek('!L', 16)
Rich Lane95f7fc92014-01-27 17:08:16 -08002613 subclass = experimenter_stats_reply.subtypes.get(subtype)
2614 if subclass:
2615 return subclass.unpack(reader)
2616
2617 obj = experimenter_stats_reply()
2618 _version = reader.read("!B")[0]
2619 assert(_version == 3)
2620 _type = reader.read("!B")[0]
2621 assert(_type == 19)
2622 _length = reader.read("!H")[0]
2623 orig_reader = reader
2624 reader = orig_reader.slice(_length - (2 + 2))
2625 obj.xid = reader.read("!L")[0]
2626 _stats_type = reader.read("!H")[0]
2627 assert(_stats_type == 65535)
2628 obj.flags = reader.read("!H")[0]
2629 reader.skip(4)
2630 obj.experimenter = reader.read("!L")[0]
2631 obj.subtype = reader.read("!L")[0]
2632 obj.data = str(reader.read_all())
2633 return obj
2634
2635 def __eq__(self, other):
2636 if type(self) != type(other): return False
2637 if self.xid != other.xid: return False
2638 if self.flags != other.flags: return False
2639 if self.experimenter != other.experimenter: return False
2640 if self.subtype != other.subtype: return False
2641 if self.data != other.data: return False
2642 return True
2643
2644 def pretty_print(self, q):
2645 q.text("experimenter_stats_reply {")
2646 with q.group():
2647 with q.indent(2):
2648 q.breakable()
2649 q.text("xid = ");
2650 if self.xid != None:
2651 q.text("%#x" % self.xid)
2652 else:
2653 q.text('None')
2654 q.text(","); q.breakable()
2655 q.text("flags = ");
2656 q.text("%#x" % self.flags)
2657 q.text(","); q.breakable()
2658 q.text("subtype = ");
2659 q.text("%#x" % self.subtype)
2660 q.text(","); q.breakable()
2661 q.text("data = ");
2662 q.pp(self.data)
2663 q.breakable()
2664 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002665
2666stats_reply.subtypes[65535] = experimenter_stats_reply
2667
2668class bsn_stats_reply(experimenter_stats_reply):
2669 subtypes = {}
2670
Rich Lane95f7fc92014-01-27 17:08:16 -08002671 version = 3
2672 type = 19
2673 stats_type = 65535
2674 experimenter = 6035143
2675
2676 def __init__(self, xid=None, flags=None, subtype=None):
2677 if xid != None:
2678 self.xid = xid
2679 else:
2680 self.xid = None
2681 if flags != None:
2682 self.flags = flags
2683 else:
2684 self.flags = 0
2685 if subtype != None:
2686 self.subtype = subtype
2687 else:
2688 self.subtype = 0
2689 return
2690
2691 def pack(self):
2692 packed = []
2693 packed.append(struct.pack("!B", self.version))
2694 packed.append(struct.pack("!B", self.type))
2695 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2696 packed.append(struct.pack("!L", self.xid))
2697 packed.append(struct.pack("!H", self.stats_type))
2698 packed.append(struct.pack("!H", self.flags))
2699 packed.append('\x00' * 4)
2700 packed.append(struct.pack("!L", self.experimenter))
2701 packed.append(struct.pack("!L", self.subtype))
2702 length = sum([len(x) for x in packed])
2703 packed[2] = struct.pack("!H", length)
2704 return ''.join(packed)
2705
Rich Lane7dcdf022013-12-11 14:45:27 -08002706 @staticmethod
2707 def unpack(reader):
2708 subtype, = reader.peek('!L', 20)
Rich Lane95f7fc92014-01-27 17:08:16 -08002709 subclass = bsn_stats_reply.subtypes.get(subtype)
2710 if subclass:
2711 return subclass.unpack(reader)
2712
2713 obj = bsn_stats_reply()
2714 _version = reader.read("!B")[0]
2715 assert(_version == 3)
2716 _type = reader.read("!B")[0]
2717 assert(_type == 19)
2718 _length = reader.read("!H")[0]
2719 orig_reader = reader
2720 reader = orig_reader.slice(_length - (2 + 2))
2721 obj.xid = reader.read("!L")[0]
2722 _stats_type = reader.read("!H")[0]
2723 assert(_stats_type == 65535)
2724 obj.flags = reader.read("!H")[0]
2725 reader.skip(4)
2726 _experimenter = reader.read("!L")[0]
2727 assert(_experimenter == 6035143)
2728 obj.subtype = reader.read("!L")[0]
2729 return obj
2730
2731 def __eq__(self, other):
2732 if type(self) != type(other): return False
2733 if self.xid != other.xid: return False
2734 if self.flags != other.flags: return False
2735 if self.subtype != other.subtype: return False
2736 return True
2737
2738 def pretty_print(self, q):
2739 q.text("bsn_stats_reply {")
2740 with q.group():
2741 with q.indent(2):
2742 q.breakable()
2743 q.text("xid = ");
2744 if self.xid != None:
2745 q.text("%#x" % self.xid)
2746 else:
2747 q.text('None')
2748 q.text(","); q.breakable()
2749 q.text("flags = ");
2750 q.text("%#x" % self.flags)
2751 q.breakable()
2752 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002753
2754experimenter_stats_reply.subtypes[6035143] = bsn_stats_reply
2755
2756class experimenter_stats_request(stats_request):
2757 subtypes = {}
2758
Rich Lane95f7fc92014-01-27 17:08:16 -08002759 version = 3
2760 type = 18
2761 stats_type = 65535
2762
2763 def __init__(self, xid=None, flags=None, experimenter=None, subtype=None, data=None):
2764 if xid != None:
2765 self.xid = xid
2766 else:
2767 self.xid = None
2768 if flags != None:
2769 self.flags = flags
2770 else:
2771 self.flags = 0
2772 if experimenter != None:
2773 self.experimenter = experimenter
2774 else:
2775 self.experimenter = 0
2776 if subtype != None:
2777 self.subtype = subtype
2778 else:
2779 self.subtype = 0
2780 if data != None:
2781 self.data = data
2782 else:
2783 self.data = ''
2784 return
2785
2786 def pack(self):
2787 packed = []
2788 packed.append(struct.pack("!B", self.version))
2789 packed.append(struct.pack("!B", self.type))
2790 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2791 packed.append(struct.pack("!L", self.xid))
2792 packed.append(struct.pack("!H", self.stats_type))
2793 packed.append(struct.pack("!H", self.flags))
2794 packed.append('\x00' * 4)
2795 packed.append(struct.pack("!L", self.experimenter))
2796 packed.append(struct.pack("!L", self.subtype))
2797 packed.append(self.data)
2798 length = sum([len(x) for x in packed])
2799 packed[2] = struct.pack("!H", length)
2800 return ''.join(packed)
2801
Rich Lane7dcdf022013-12-11 14:45:27 -08002802 @staticmethod
2803 def unpack(reader):
2804 subtype, = reader.peek('!L', 16)
Rich Lane95f7fc92014-01-27 17:08:16 -08002805 subclass = experimenter_stats_request.subtypes.get(subtype)
2806 if subclass:
2807 return subclass.unpack(reader)
2808
2809 obj = experimenter_stats_request()
2810 _version = reader.read("!B")[0]
2811 assert(_version == 3)
2812 _type = reader.read("!B")[0]
2813 assert(_type == 18)
2814 _length = reader.read("!H")[0]
2815 orig_reader = reader
2816 reader = orig_reader.slice(_length - (2 + 2))
2817 obj.xid = reader.read("!L")[0]
2818 _stats_type = reader.read("!H")[0]
2819 assert(_stats_type == 65535)
2820 obj.flags = reader.read("!H")[0]
2821 reader.skip(4)
2822 obj.experimenter = reader.read("!L")[0]
2823 obj.subtype = reader.read("!L")[0]
2824 obj.data = str(reader.read_all())
2825 return obj
2826
2827 def __eq__(self, other):
2828 if type(self) != type(other): return False
2829 if self.xid != other.xid: return False
2830 if self.flags != other.flags: return False
2831 if self.experimenter != other.experimenter: return False
2832 if self.subtype != other.subtype: return False
2833 if self.data != other.data: return False
2834 return True
2835
2836 def pretty_print(self, q):
2837 q.text("experimenter_stats_request {")
2838 with q.group():
2839 with q.indent(2):
2840 q.breakable()
2841 q.text("xid = ");
2842 if self.xid != None:
2843 q.text("%#x" % self.xid)
2844 else:
2845 q.text('None')
2846 q.text(","); q.breakable()
2847 q.text("flags = ");
2848 q.text("%#x" % self.flags)
2849 q.text(","); q.breakable()
2850 q.text("subtype = ");
2851 q.text("%#x" % self.subtype)
2852 q.text(","); q.breakable()
2853 q.text("data = ");
2854 q.pp(self.data)
2855 q.breakable()
2856 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002857
2858stats_request.subtypes[65535] = experimenter_stats_request
2859
2860class bsn_stats_request(experimenter_stats_request):
2861 subtypes = {}
2862
Rich Lane95f7fc92014-01-27 17:08:16 -08002863 version = 3
2864 type = 18
2865 stats_type = 65535
2866 experimenter = 6035143
2867
2868 def __init__(self, xid=None, flags=None, subtype=None):
2869 if xid != None:
2870 self.xid = xid
2871 else:
2872 self.xid = None
2873 if flags != None:
2874 self.flags = flags
2875 else:
2876 self.flags = 0
2877 if subtype != None:
2878 self.subtype = subtype
2879 else:
2880 self.subtype = 0
2881 return
2882
2883 def pack(self):
2884 packed = []
2885 packed.append(struct.pack("!B", self.version))
2886 packed.append(struct.pack("!B", self.type))
2887 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2888 packed.append(struct.pack("!L", self.xid))
2889 packed.append(struct.pack("!H", self.stats_type))
2890 packed.append(struct.pack("!H", self.flags))
2891 packed.append('\x00' * 4)
2892 packed.append(struct.pack("!L", self.experimenter))
2893 packed.append(struct.pack("!L", self.subtype))
2894 length = sum([len(x) for x in packed])
2895 packed[2] = struct.pack("!H", length)
2896 return ''.join(packed)
2897
Rich Lane7dcdf022013-12-11 14:45:27 -08002898 @staticmethod
2899 def unpack(reader):
2900 subtype, = reader.peek('!L', 20)
Rich Lane95f7fc92014-01-27 17:08:16 -08002901 subclass = bsn_stats_request.subtypes.get(subtype)
2902 if subclass:
2903 return subclass.unpack(reader)
2904
2905 obj = bsn_stats_request()
2906 _version = reader.read("!B")[0]
2907 assert(_version == 3)
2908 _type = reader.read("!B")[0]
2909 assert(_type == 18)
2910 _length = reader.read("!H")[0]
2911 orig_reader = reader
2912 reader = orig_reader.slice(_length - (2 + 2))
2913 obj.xid = reader.read("!L")[0]
2914 _stats_type = reader.read("!H")[0]
2915 assert(_stats_type == 65535)
2916 obj.flags = reader.read("!H")[0]
2917 reader.skip(4)
2918 _experimenter = reader.read("!L")[0]
2919 assert(_experimenter == 6035143)
2920 obj.subtype = reader.read("!L")[0]
2921 return obj
2922
2923 def __eq__(self, other):
2924 if type(self) != type(other): return False
2925 if self.xid != other.xid: return False
2926 if self.flags != other.flags: return False
2927 if self.subtype != other.subtype: return False
2928 return True
2929
2930 def pretty_print(self, q):
2931 q.text("bsn_stats_request {")
2932 with q.group():
2933 with q.indent(2):
2934 q.breakable()
2935 q.text("xid = ");
2936 if self.xid != None:
2937 q.text("%#x" % self.xid)
2938 else:
2939 q.text('None')
2940 q.text(","); q.breakable()
2941 q.text("flags = ");
2942 q.text("%#x" % self.flags)
2943 q.breakable()
2944 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002945
2946experimenter_stats_request.subtypes[6035143] = bsn_stats_request
2947
2948class bsn_virtual_port_create_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07002949 version = 3
2950 type = 4
2951 experimenter = 6035143
2952 subtype = 16
2953
2954 def __init__(self, xid=None, status=None, vport_no=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002955 if xid != None:
2956 self.xid = xid
2957 else:
2958 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07002959 if status != None:
2960 self.status = status
2961 else:
2962 self.status = 0
2963 if vport_no != None:
2964 self.vport_no = vport_no
2965 else:
2966 self.vport_no = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002967 return
Dan Talaycof6202252013-07-02 01:00:29 -07002968
2969 def pack(self):
2970 packed = []
2971 packed.append(struct.pack("!B", self.version))
2972 packed.append(struct.pack("!B", self.type))
2973 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2974 packed.append(struct.pack("!L", self.xid))
2975 packed.append(struct.pack("!L", self.experimenter))
2976 packed.append(struct.pack("!L", self.subtype))
2977 packed.append(struct.pack("!L", self.status))
2978 packed.append(struct.pack("!L", self.vport_no))
2979 length = sum([len(x) for x in packed])
2980 packed[2] = struct.pack("!H", length)
2981 return ''.join(packed)
2982
2983 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002984 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07002985 obj = bsn_virtual_port_create_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07002986 _version = reader.read("!B")[0]
2987 assert(_version == 3)
2988 _type = reader.read("!B")[0]
2989 assert(_type == 4)
2990 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002991 orig_reader = reader
2992 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002993 obj.xid = reader.read("!L")[0]
2994 _experimenter = reader.read("!L")[0]
2995 assert(_experimenter == 6035143)
2996 _subtype = reader.read("!L")[0]
2997 assert(_subtype == 16)
2998 obj.status = reader.read("!L")[0]
2999 obj.vport_no = reader.read("!L")[0]
3000 return obj
3001
3002 def __eq__(self, other):
3003 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07003004 if self.xid != other.xid: return False
3005 if self.status != other.status: return False
3006 if self.vport_no != other.vport_no: return False
3007 return True
3008
Dan Talaycof6202252013-07-02 01:00:29 -07003009 def pretty_print(self, q):
3010 q.text("bsn_virtual_port_create_reply {")
3011 with q.group():
3012 with q.indent(2):
3013 q.breakable()
3014 q.text("xid = ");
3015 if self.xid != None:
3016 q.text("%#x" % self.xid)
3017 else:
3018 q.text('None')
3019 q.text(","); q.breakable()
3020 q.text("status = ");
3021 q.text("%#x" % self.status)
3022 q.text(","); q.breakable()
3023 q.text("vport_no = ");
3024 q.text("%#x" % self.vport_no)
3025 q.breakable()
3026 q.text('}')
3027
Rich Lane7dcdf022013-12-11 14:45:27 -08003028bsn_header.subtypes[16] = bsn_virtual_port_create_reply
3029
3030class bsn_virtual_port_create_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07003031 version = 3
3032 type = 4
3033 experimenter = 6035143
3034 subtype = 15
3035
3036 def __init__(self, xid=None, vport=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003037 if xid != None:
3038 self.xid = xid
3039 else:
3040 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07003041 if vport != None:
3042 self.vport = vport
3043 else:
Rich Lane93b33132014-04-21 12:20:58 -07003044 self.vport = common.bsn_vport()
Rich Lane7dcdf022013-12-11 14:45:27 -08003045 return
Dan Talaycof6202252013-07-02 01:00:29 -07003046
3047 def pack(self):
3048 packed = []
3049 packed.append(struct.pack("!B", self.version))
3050 packed.append(struct.pack("!B", self.type))
3051 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3052 packed.append(struct.pack("!L", self.xid))
3053 packed.append(struct.pack("!L", self.experimenter))
3054 packed.append(struct.pack("!L", self.subtype))
3055 packed.append(self.vport.pack())
3056 length = sum([len(x) for x in packed])
3057 packed[2] = struct.pack("!H", length)
3058 return ''.join(packed)
3059
3060 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003061 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07003062 obj = bsn_virtual_port_create_request()
Dan Talaycof6202252013-07-02 01:00:29 -07003063 _version = reader.read("!B")[0]
3064 assert(_version == 3)
3065 _type = reader.read("!B")[0]
3066 assert(_type == 4)
3067 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003068 orig_reader = reader
3069 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003070 obj.xid = reader.read("!L")[0]
3071 _experimenter = reader.read("!L")[0]
3072 assert(_experimenter == 6035143)
3073 _subtype = reader.read("!L")[0]
3074 assert(_subtype == 15)
Rich Lane93b33132014-04-21 12:20:58 -07003075 obj.vport = common.bsn_vport.unpack(reader)
Dan Talaycof6202252013-07-02 01:00:29 -07003076 return obj
3077
3078 def __eq__(self, other):
3079 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07003080 if self.xid != other.xid: return False
3081 if self.vport != other.vport: return False
3082 return True
3083
Dan Talaycof6202252013-07-02 01:00:29 -07003084 def pretty_print(self, q):
3085 q.text("bsn_virtual_port_create_request {")
3086 with q.group():
3087 with q.indent(2):
3088 q.breakable()
3089 q.text("xid = ");
3090 if self.xid != None:
3091 q.text("%#x" % self.xid)
3092 else:
3093 q.text('None')
3094 q.text(","); q.breakable()
3095 q.text("vport = ");
3096 q.pp(self.vport)
3097 q.breakable()
3098 q.text('}')
3099
Rich Lane7dcdf022013-12-11 14:45:27 -08003100bsn_header.subtypes[15] = bsn_virtual_port_create_request
3101
3102class bsn_virtual_port_remove_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07003103 version = 3
3104 type = 4
3105 experimenter = 6035143
3106 subtype = 26
3107
3108 def __init__(self, xid=None, status=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003109 if xid != None:
3110 self.xid = xid
3111 else:
3112 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07003113 if status != None:
3114 self.status = status
3115 else:
3116 self.status = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08003117 return
Dan Talaycof6202252013-07-02 01:00:29 -07003118
3119 def pack(self):
3120 packed = []
3121 packed.append(struct.pack("!B", self.version))
3122 packed.append(struct.pack("!B", self.type))
3123 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3124 packed.append(struct.pack("!L", self.xid))
3125 packed.append(struct.pack("!L", self.experimenter))
3126 packed.append(struct.pack("!L", self.subtype))
3127 packed.append(struct.pack("!L", self.status))
3128 length = sum([len(x) for x in packed])
3129 packed[2] = struct.pack("!H", length)
3130 return ''.join(packed)
3131
3132 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003133 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07003134 obj = bsn_virtual_port_remove_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07003135 _version = reader.read("!B")[0]
3136 assert(_version == 3)
3137 _type = reader.read("!B")[0]
3138 assert(_type == 4)
3139 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003140 orig_reader = reader
3141 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003142 obj.xid = reader.read("!L")[0]
3143 _experimenter = reader.read("!L")[0]
3144 assert(_experimenter == 6035143)
3145 _subtype = reader.read("!L")[0]
3146 assert(_subtype == 26)
3147 obj.status = reader.read("!L")[0]
3148 return obj
3149
3150 def __eq__(self, other):
3151 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07003152 if self.xid != other.xid: return False
3153 if self.status != other.status: return False
3154 return True
3155
Dan Talaycof6202252013-07-02 01:00:29 -07003156 def pretty_print(self, q):
3157 q.text("bsn_virtual_port_remove_reply {")
3158 with q.group():
3159 with q.indent(2):
3160 q.breakable()
3161 q.text("xid = ");
3162 if self.xid != None:
3163 q.text("%#x" % self.xid)
3164 else:
3165 q.text('None')
3166 q.text(","); q.breakable()
3167 q.text("status = ");
3168 q.text("%#x" % self.status)
3169 q.breakable()
3170 q.text('}')
3171
Rich Lane7dcdf022013-12-11 14:45:27 -08003172bsn_header.subtypes[26] = bsn_virtual_port_remove_reply
3173
3174class bsn_virtual_port_remove_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07003175 version = 3
3176 type = 4
3177 experimenter = 6035143
3178 subtype = 17
3179
3180 def __init__(self, xid=None, vport_no=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003181 if xid != None:
3182 self.xid = xid
3183 else:
3184 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07003185 if vport_no != None:
3186 self.vport_no = vport_no
3187 else:
3188 self.vport_no = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08003189 return
Dan Talaycof6202252013-07-02 01:00:29 -07003190
3191 def pack(self):
3192 packed = []
3193 packed.append(struct.pack("!B", self.version))
3194 packed.append(struct.pack("!B", self.type))
3195 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3196 packed.append(struct.pack("!L", self.xid))
3197 packed.append(struct.pack("!L", self.experimenter))
3198 packed.append(struct.pack("!L", self.subtype))
3199 packed.append(struct.pack("!L", self.vport_no))
3200 length = sum([len(x) for x in packed])
3201 packed[2] = struct.pack("!H", length)
3202 return ''.join(packed)
3203
3204 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003205 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07003206 obj = bsn_virtual_port_remove_request()
Dan Talaycof6202252013-07-02 01:00:29 -07003207 _version = reader.read("!B")[0]
3208 assert(_version == 3)
3209 _type = reader.read("!B")[0]
3210 assert(_type == 4)
3211 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003212 orig_reader = reader
3213 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003214 obj.xid = reader.read("!L")[0]
3215 _experimenter = reader.read("!L")[0]
3216 assert(_experimenter == 6035143)
3217 _subtype = reader.read("!L")[0]
3218 assert(_subtype == 17)
3219 obj.vport_no = reader.read("!L")[0]
3220 return obj
3221
3222 def __eq__(self, other):
3223 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07003224 if self.xid != other.xid: return False
3225 if self.vport_no != other.vport_no: return False
3226 return True
3227
Dan Talaycof6202252013-07-02 01:00:29 -07003228 def pretty_print(self, q):
3229 q.text("bsn_virtual_port_remove_request {")
3230 with q.group():
3231 with q.indent(2):
3232 q.breakable()
3233 q.text("xid = ");
3234 if self.xid != None:
3235 q.text("%#x" % self.xid)
3236 else:
3237 q.text('None')
3238 q.text(","); q.breakable()
3239 q.text("vport_no = ");
3240 q.text("%#x" % self.vport_no)
3241 q.breakable()
3242 q.text('}')
3243
Rich Lane7dcdf022013-12-11 14:45:27 -08003244bsn_header.subtypes[17] = bsn_virtual_port_remove_request
3245
3246class desc_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07003247 version = 3
3248 type = 19
3249 stats_type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07003250
3251 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 -08003252 if xid != None:
3253 self.xid = xid
3254 else:
3255 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003256 if flags != None:
3257 self.flags = flags
3258 else:
3259 self.flags = 0
3260 if mfr_desc != None:
3261 self.mfr_desc = mfr_desc
3262 else:
3263 self.mfr_desc = ""
3264 if hw_desc != None:
3265 self.hw_desc = hw_desc
3266 else:
3267 self.hw_desc = ""
3268 if sw_desc != None:
3269 self.sw_desc = sw_desc
3270 else:
3271 self.sw_desc = ""
3272 if serial_num != None:
3273 self.serial_num = serial_num
3274 else:
3275 self.serial_num = ""
3276 if dp_desc != None:
3277 self.dp_desc = dp_desc
3278 else:
3279 self.dp_desc = ""
Rich Lane7dcdf022013-12-11 14:45:27 -08003280 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003281
3282 def pack(self):
3283 packed = []
3284 packed.append(struct.pack("!B", self.version))
3285 packed.append(struct.pack("!B", self.type))
3286 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3287 packed.append(struct.pack("!L", self.xid))
3288 packed.append(struct.pack("!H", self.stats_type))
3289 packed.append(struct.pack("!H", self.flags))
3290 packed.append('\x00' * 4)
3291 packed.append(struct.pack("!256s", self.mfr_desc))
3292 packed.append(struct.pack("!256s", self.hw_desc))
3293 packed.append(struct.pack("!256s", self.sw_desc))
3294 packed.append(struct.pack("!32s", self.serial_num))
3295 packed.append(struct.pack("!256s", self.dp_desc))
3296 length = sum([len(x) for x in packed])
3297 packed[2] = struct.pack("!H", length)
3298 return ''.join(packed)
3299
3300 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003301 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003302 obj = desc_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07003303 _version = reader.read("!B")[0]
3304 assert(_version == 3)
3305 _type = reader.read("!B")[0]
3306 assert(_type == 19)
3307 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003308 orig_reader = reader
3309 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003310 obj.xid = reader.read("!L")[0]
3311 _stats_type = reader.read("!H")[0]
3312 assert(_stats_type == 0)
3313 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003314 reader.skip(4)
3315 obj.mfr_desc = reader.read("!256s")[0].rstrip("\x00")
3316 obj.hw_desc = reader.read("!256s")[0].rstrip("\x00")
3317 obj.sw_desc = reader.read("!256s")[0].rstrip("\x00")
3318 obj.serial_num = reader.read("!32s")[0].rstrip("\x00")
3319 obj.dp_desc = reader.read("!256s")[0].rstrip("\x00")
3320 return obj
3321
3322 def __eq__(self, other):
3323 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003324 if self.xid != other.xid: return False
3325 if self.flags != other.flags: return False
3326 if self.mfr_desc != other.mfr_desc: return False
3327 if self.hw_desc != other.hw_desc: return False
3328 if self.sw_desc != other.sw_desc: return False
3329 if self.serial_num != other.serial_num: return False
3330 if self.dp_desc != other.dp_desc: return False
3331 return True
3332
Rich Lanec2ee4b82013-04-24 17:12:38 -07003333 def pretty_print(self, q):
3334 q.text("desc_stats_reply {")
3335 with q.group():
3336 with q.indent(2):
3337 q.breakable()
3338 q.text("xid = ");
3339 if self.xid != None:
3340 q.text("%#x" % self.xid)
3341 else:
3342 q.text('None')
3343 q.text(","); q.breakable()
3344 q.text("flags = ");
3345 q.text("%#x" % self.flags)
3346 q.text(","); q.breakable()
3347 q.text("mfr_desc = ");
3348 q.pp(self.mfr_desc)
3349 q.text(","); q.breakable()
3350 q.text("hw_desc = ");
3351 q.pp(self.hw_desc)
3352 q.text(","); q.breakable()
3353 q.text("sw_desc = ");
3354 q.pp(self.sw_desc)
3355 q.text(","); q.breakable()
3356 q.text("serial_num = ");
3357 q.pp(self.serial_num)
3358 q.text(","); q.breakable()
3359 q.text("dp_desc = ");
3360 q.pp(self.dp_desc)
3361 q.breakable()
3362 q.text('}')
3363
Rich Lane7dcdf022013-12-11 14:45:27 -08003364stats_reply.subtypes[0] = desc_stats_reply
3365
3366class desc_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07003367 version = 3
3368 type = 18
3369 stats_type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07003370
3371 def __init__(self, xid=None, flags=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003372 if xid != None:
3373 self.xid = xid
3374 else:
3375 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003376 if flags != None:
3377 self.flags = flags
3378 else:
3379 self.flags = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08003380 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003381
3382 def pack(self):
3383 packed = []
3384 packed.append(struct.pack("!B", self.version))
3385 packed.append(struct.pack("!B", self.type))
3386 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3387 packed.append(struct.pack("!L", self.xid))
3388 packed.append(struct.pack("!H", self.stats_type))
3389 packed.append(struct.pack("!H", self.flags))
3390 packed.append('\x00' * 4)
3391 length = sum([len(x) for x in packed])
3392 packed[2] = struct.pack("!H", length)
3393 return ''.join(packed)
3394
3395 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003396 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003397 obj = desc_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07003398 _version = reader.read("!B")[0]
3399 assert(_version == 3)
3400 _type = reader.read("!B")[0]
3401 assert(_type == 18)
3402 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003403 orig_reader = reader
3404 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003405 obj.xid = reader.read("!L")[0]
3406 _stats_type = reader.read("!H")[0]
3407 assert(_stats_type == 0)
3408 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003409 reader.skip(4)
3410 return obj
3411
3412 def __eq__(self, other):
3413 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003414 if self.xid != other.xid: return False
3415 if self.flags != other.flags: return False
3416 return True
3417
Rich Lanec2ee4b82013-04-24 17:12:38 -07003418 def pretty_print(self, q):
3419 q.text("desc_stats_request {")
3420 with q.group():
3421 with q.indent(2):
3422 q.breakable()
3423 q.text("xid = ");
3424 if self.xid != None:
3425 q.text("%#x" % self.xid)
3426 else:
3427 q.text('None')
3428 q.text(","); q.breakable()
3429 q.text("flags = ");
3430 q.text("%#x" % self.flags)
3431 q.breakable()
3432 q.text('}')
3433
Rich Lane7dcdf022013-12-11 14:45:27 -08003434stats_request.subtypes[0] = desc_stats_request
3435
3436class echo_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -07003437 version = 3
3438 type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07003439
3440 def __init__(self, xid=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003441 if xid != None:
3442 self.xid = xid
3443 else:
3444 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003445 if data != None:
3446 self.data = data
3447 else:
Dan Talaycof6202252013-07-02 01:00:29 -07003448 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08003449 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003450
3451 def pack(self):
3452 packed = []
3453 packed.append(struct.pack("!B", self.version))
3454 packed.append(struct.pack("!B", self.type))
3455 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3456 packed.append(struct.pack("!L", self.xid))
3457 packed.append(self.data)
3458 length = sum([len(x) for x in packed])
3459 packed[2] = struct.pack("!H", length)
3460 return ''.join(packed)
3461
3462 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003463 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003464 obj = echo_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07003465 _version = reader.read("!B")[0]
3466 assert(_version == 3)
3467 _type = reader.read("!B")[0]
3468 assert(_type == 3)
3469 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003470 orig_reader = reader
3471 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003472 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003473 obj.data = str(reader.read_all())
3474 return obj
3475
3476 def __eq__(self, other):
3477 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003478 if self.xid != other.xid: return False
3479 if self.data != other.data: return False
3480 return True
3481
Rich Lanec2ee4b82013-04-24 17:12:38 -07003482 def pretty_print(self, q):
3483 q.text("echo_reply {")
3484 with q.group():
3485 with q.indent(2):
3486 q.breakable()
3487 q.text("xid = ");
3488 if self.xid != None:
3489 q.text("%#x" % self.xid)
3490 else:
3491 q.text('None')
3492 q.text(","); q.breakable()
3493 q.text("data = ");
3494 q.pp(self.data)
3495 q.breakable()
3496 q.text('}')
3497
Rich Lane7dcdf022013-12-11 14:45:27 -08003498message.subtypes[3] = echo_reply
3499
3500class echo_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -07003501 version = 3
3502 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07003503
3504 def __init__(self, xid=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003505 if xid != None:
3506 self.xid = xid
3507 else:
3508 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003509 if data != None:
3510 self.data = data
3511 else:
Dan Talaycof6202252013-07-02 01:00:29 -07003512 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08003513 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003514
3515 def pack(self):
3516 packed = []
3517 packed.append(struct.pack("!B", self.version))
3518 packed.append(struct.pack("!B", self.type))
3519 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3520 packed.append(struct.pack("!L", self.xid))
3521 packed.append(self.data)
3522 length = sum([len(x) for x in packed])
3523 packed[2] = struct.pack("!H", length)
3524 return ''.join(packed)
3525
3526 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003527 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003528 obj = echo_request()
Dan Talaycof6202252013-07-02 01:00:29 -07003529 _version = reader.read("!B")[0]
3530 assert(_version == 3)
3531 _type = reader.read("!B")[0]
3532 assert(_type == 2)
3533 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003534 orig_reader = reader
3535 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003536 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003537 obj.data = str(reader.read_all())
3538 return obj
3539
3540 def __eq__(self, other):
3541 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003542 if self.xid != other.xid: return False
3543 if self.data != other.data: return False
3544 return True
3545
Rich Lanec2ee4b82013-04-24 17:12:38 -07003546 def pretty_print(self, q):
3547 q.text("echo_request {")
3548 with q.group():
3549 with q.indent(2):
3550 q.breakable()
3551 q.text("xid = ");
3552 if self.xid != None:
3553 q.text("%#x" % self.xid)
3554 else:
3555 q.text('None')
3556 q.text(","); q.breakable()
3557 q.text("data = ");
3558 q.pp(self.data)
3559 q.breakable()
3560 q.text('}')
3561
Rich Lane7dcdf022013-12-11 14:45:27 -08003562message.subtypes[2] = echo_request
3563
3564class experimenter_error_msg(error_msg):
Dan Talaycof6202252013-07-02 01:00:29 -07003565 version = 3
3566 type = 1
Rich Lane6f4978c2013-10-20 21:33:52 -07003567 err_type = 65535
Rich Lanec2ee4b82013-04-24 17:12:38 -07003568
Rich Lane6f4978c2013-10-20 21:33:52 -07003569 def __init__(self, xid=None, subtype=None, experimenter=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003570 if xid != None:
3571 self.xid = xid
3572 else:
3573 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07003574 if subtype != None:
3575 self.subtype = subtype
Rich Lanec2ee4b82013-04-24 17:12:38 -07003576 else:
Rich Lane6f4978c2013-10-20 21:33:52 -07003577 self.subtype = 0
3578 if experimenter != None:
3579 self.experimenter = experimenter
Rich Lanec2ee4b82013-04-24 17:12:38 -07003580 else:
Rich Lane6f4978c2013-10-20 21:33:52 -07003581 self.experimenter = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07003582 if data != None:
3583 self.data = data
3584 else:
Dan Talaycof6202252013-07-02 01:00:29 -07003585 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08003586 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003587
3588 def pack(self):
3589 packed = []
3590 packed.append(struct.pack("!B", self.version))
3591 packed.append(struct.pack("!B", self.type))
3592 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3593 packed.append(struct.pack("!L", self.xid))
3594 packed.append(struct.pack("!H", self.err_type))
Rich Lane6f4978c2013-10-20 21:33:52 -07003595 packed.append(struct.pack("!H", self.subtype))
3596 packed.append(struct.pack("!L", self.experimenter))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003597 packed.append(self.data)
3598 length = sum([len(x) for x in packed])
3599 packed[2] = struct.pack("!H", length)
3600 return ''.join(packed)
3601
3602 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003603 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07003604 obj = experimenter_error_msg()
Dan Talaycof6202252013-07-02 01:00:29 -07003605 _version = reader.read("!B")[0]
3606 assert(_version == 3)
3607 _type = reader.read("!B")[0]
3608 assert(_type == 1)
3609 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003610 orig_reader = reader
3611 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003612 obj.xid = reader.read("!L")[0]
Rich Lane6f4978c2013-10-20 21:33:52 -07003613 _err_type = reader.read("!H")[0]
3614 assert(_err_type == 65535)
3615 obj.subtype = reader.read("!H")[0]
3616 obj.experimenter = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003617 obj.data = str(reader.read_all())
3618 return obj
3619
3620 def __eq__(self, other):
3621 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003622 if self.xid != other.xid: return False
Rich Lane6f4978c2013-10-20 21:33:52 -07003623 if self.subtype != other.subtype: return False
3624 if self.experimenter != other.experimenter: return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003625 if self.data != other.data: return False
3626 return True
3627
Rich Lanec2ee4b82013-04-24 17:12:38 -07003628 def pretty_print(self, q):
Rich Lane6f4978c2013-10-20 21:33:52 -07003629 q.text("experimenter_error_msg {")
Rich Lanec2ee4b82013-04-24 17:12:38 -07003630 with q.group():
3631 with q.indent(2):
3632 q.breakable()
3633 q.text("xid = ");
3634 if self.xid != None:
3635 q.text("%#x" % self.xid)
3636 else:
3637 q.text('None')
3638 q.text(","); q.breakable()
Rich Lane6f4978c2013-10-20 21:33:52 -07003639 q.text("subtype = ");
3640 q.text("%#x" % self.subtype)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003641 q.text(","); q.breakable()
Rich Lane6f4978c2013-10-20 21:33:52 -07003642 q.text("experimenter = ");
3643 q.text("%#x" % self.experimenter)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003644 q.text(","); q.breakable()
3645 q.text("data = ");
3646 q.pp(self.data)
3647 q.breakable()
3648 q.text('}')
3649
Rich Lane7dcdf022013-12-11 14:45:27 -08003650error_msg.subtypes[65535] = experimenter_error_msg
3651
3652class features_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -07003653 version = 3
3654 type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07003655
3656 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 -08003657 if xid != None:
3658 self.xid = xid
3659 else:
3660 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003661 if datapath_id != None:
3662 self.datapath_id = datapath_id
3663 else:
3664 self.datapath_id = 0
3665 if n_buffers != None:
3666 self.n_buffers = n_buffers
3667 else:
3668 self.n_buffers = 0
3669 if n_tables != None:
3670 self.n_tables = n_tables
3671 else:
3672 self.n_tables = 0
3673 if capabilities != None:
3674 self.capabilities = capabilities
3675 else:
3676 self.capabilities = 0
3677 if reserved != None:
3678 self.reserved = reserved
3679 else:
3680 self.reserved = 0
3681 if ports != None:
3682 self.ports = ports
3683 else:
3684 self.ports = []
Rich Lane7dcdf022013-12-11 14:45:27 -08003685 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003686
3687 def pack(self):
3688 packed = []
3689 packed.append(struct.pack("!B", self.version))
3690 packed.append(struct.pack("!B", self.type))
3691 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3692 packed.append(struct.pack("!L", self.xid))
3693 packed.append(struct.pack("!Q", self.datapath_id))
3694 packed.append(struct.pack("!L", self.n_buffers))
3695 packed.append(struct.pack("!B", self.n_tables))
3696 packed.append('\x00' * 3)
3697 packed.append(struct.pack("!L", self.capabilities))
3698 packed.append(struct.pack("!L", self.reserved))
Rich Lane7dcdf022013-12-11 14:45:27 -08003699 packed.append(loxi.generic_util.pack_list(self.ports))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003700 length = sum([len(x) for x in packed])
3701 packed[2] = struct.pack("!H", length)
3702 return ''.join(packed)
3703
3704 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003705 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003706 obj = features_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07003707 _version = reader.read("!B")[0]
3708 assert(_version == 3)
3709 _type = reader.read("!B")[0]
3710 assert(_type == 6)
3711 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003712 orig_reader = reader
3713 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003714 obj.xid = reader.read("!L")[0]
3715 obj.datapath_id = reader.read("!Q")[0]
3716 obj.n_buffers = reader.read("!L")[0]
3717 obj.n_tables = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003718 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07003719 obj.capabilities = reader.read("!L")[0]
3720 obj.reserved = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003721 obj.ports = loxi.generic_util.unpack_list(reader, common.port_desc.unpack)
3722 return obj
3723
3724 def __eq__(self, other):
3725 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003726 if self.xid != other.xid: return False
3727 if self.datapath_id != other.datapath_id: return False
3728 if self.n_buffers != other.n_buffers: return False
3729 if self.n_tables != other.n_tables: return False
3730 if self.capabilities != other.capabilities: return False
3731 if self.reserved != other.reserved: return False
3732 if self.ports != other.ports: return False
3733 return True
3734
Rich Lanec2ee4b82013-04-24 17:12:38 -07003735 def pretty_print(self, q):
3736 q.text("features_reply {")
3737 with q.group():
3738 with q.indent(2):
3739 q.breakable()
3740 q.text("xid = ");
3741 if self.xid != None:
3742 q.text("%#x" % self.xid)
3743 else:
3744 q.text('None')
3745 q.text(","); q.breakable()
3746 q.text("datapath_id = ");
3747 q.text("%#x" % self.datapath_id)
3748 q.text(","); q.breakable()
3749 q.text("n_buffers = ");
3750 q.text("%#x" % self.n_buffers)
3751 q.text(","); q.breakable()
3752 q.text("n_tables = ");
3753 q.text("%#x" % self.n_tables)
3754 q.text(","); q.breakable()
3755 q.text("capabilities = ");
3756 q.text("%#x" % self.capabilities)
3757 q.text(","); q.breakable()
3758 q.text("reserved = ");
3759 q.text("%#x" % self.reserved)
3760 q.text(","); q.breakable()
3761 q.text("ports = ");
3762 q.pp(self.ports)
3763 q.breakable()
3764 q.text('}')
3765
Rich Lane7dcdf022013-12-11 14:45:27 -08003766message.subtypes[6] = features_reply
3767
3768class features_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -07003769 version = 3
3770 type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07003771
3772 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003773 if xid != None:
3774 self.xid = xid
3775 else:
3776 self.xid = None
3777 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003778
3779 def pack(self):
3780 packed = []
3781 packed.append(struct.pack("!B", self.version))
3782 packed.append(struct.pack("!B", self.type))
3783 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3784 packed.append(struct.pack("!L", self.xid))
3785 length = sum([len(x) for x in packed])
3786 packed[2] = struct.pack("!H", length)
3787 return ''.join(packed)
3788
3789 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003790 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003791 obj = features_request()
Dan Talaycof6202252013-07-02 01:00:29 -07003792 _version = reader.read("!B")[0]
3793 assert(_version == 3)
3794 _type = reader.read("!B")[0]
3795 assert(_type == 5)
3796 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003797 orig_reader = reader
3798 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003799 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003800 return obj
3801
3802 def __eq__(self, other):
3803 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003804 if self.xid != other.xid: return False
3805 return True
3806
Rich Lanec2ee4b82013-04-24 17:12:38 -07003807 def pretty_print(self, q):
3808 q.text("features_request {")
3809 with q.group():
3810 with q.indent(2):
3811 q.breakable()
3812 q.text("xid = ");
3813 if self.xid != None:
3814 q.text("%#x" % self.xid)
3815 else:
3816 q.text('None')
3817 q.breakable()
3818 q.text('}')
3819
Rich Lane7dcdf022013-12-11 14:45:27 -08003820message.subtypes[5] = features_request
3821
3822class flow_mod(message):
3823 subtypes = {}
3824
Rich Lane95f7fc92014-01-27 17:08:16 -08003825 version = 3
3826 type = 14
3827
3828 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):
3829 if xid != None:
3830 self.xid = xid
3831 else:
3832 self.xid = None
3833 if cookie != None:
3834 self.cookie = cookie
3835 else:
3836 self.cookie = 0
3837 if cookie_mask != None:
3838 self.cookie_mask = cookie_mask
3839 else:
3840 self.cookie_mask = 0
3841 if table_id != None:
3842 self.table_id = table_id
3843 else:
3844 self.table_id = 0
3845 if _command != None:
3846 self._command = _command
3847 else:
3848 self._command = 0
3849 if idle_timeout != None:
3850 self.idle_timeout = idle_timeout
3851 else:
3852 self.idle_timeout = 0
3853 if hard_timeout != None:
3854 self.hard_timeout = hard_timeout
3855 else:
3856 self.hard_timeout = 0
3857 if priority != None:
3858 self.priority = priority
3859 else:
3860 self.priority = 0
3861 if buffer_id != None:
3862 self.buffer_id = buffer_id
3863 else:
3864 self.buffer_id = 0
3865 if out_port != None:
3866 self.out_port = out_port
3867 else:
3868 self.out_port = 0
3869 if out_group != None:
3870 self.out_group = out_group
3871 else:
3872 self.out_group = 0
3873 if flags != None:
3874 self.flags = flags
3875 else:
3876 self.flags = 0
3877 if match != None:
3878 self.match = match
3879 else:
3880 self.match = common.match()
3881 if instructions != None:
3882 self.instructions = instructions
3883 else:
3884 self.instructions = []
3885 return
3886
3887 def pack(self):
3888 packed = []
3889 packed.append(struct.pack("!B", self.version))
3890 packed.append(struct.pack("!B", self.type))
3891 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3892 packed.append(struct.pack("!L", self.xid))
3893 packed.append(struct.pack("!Q", self.cookie))
3894 packed.append(struct.pack("!Q", self.cookie_mask))
3895 packed.append(struct.pack("!B", self.table_id))
3896 packed.append(util.pack_fm_cmd(self._command))
3897 packed.append(struct.pack("!H", self.idle_timeout))
3898 packed.append(struct.pack("!H", self.hard_timeout))
3899 packed.append(struct.pack("!H", self.priority))
3900 packed.append(struct.pack("!L", self.buffer_id))
3901 packed.append(util.pack_port_no(self.out_port))
3902 packed.append(struct.pack("!L", self.out_group))
3903 packed.append(struct.pack("!H", self.flags))
3904 packed.append('\x00' * 2)
3905 packed.append(self.match.pack())
3906 packed.append(loxi.generic_util.pack_list(self.instructions))
3907 length = sum([len(x) for x in packed])
3908 packed[2] = struct.pack("!H", length)
3909 return ''.join(packed)
3910
Rich Lane7dcdf022013-12-11 14:45:27 -08003911 @staticmethod
3912 def unpack(reader):
3913 subtype, = reader.peek('B', 25)
Rich Lane95f7fc92014-01-27 17:08:16 -08003914 subclass = flow_mod.subtypes.get(subtype)
3915 if subclass:
3916 return subclass.unpack(reader)
3917
3918 obj = flow_mod()
3919 _version = reader.read("!B")[0]
3920 assert(_version == 3)
3921 _type = reader.read("!B")[0]
3922 assert(_type == 14)
3923 _length = reader.read("!H")[0]
3924 orig_reader = reader
3925 reader = orig_reader.slice(_length - (2 + 2))
3926 obj.xid = reader.read("!L")[0]
3927 obj.cookie = reader.read("!Q")[0]
3928 obj.cookie_mask = reader.read("!Q")[0]
3929 obj.table_id = reader.read("!B")[0]
3930 obj._command = util.unpack_fm_cmd(reader)
3931 obj.idle_timeout = reader.read("!H")[0]
3932 obj.hard_timeout = reader.read("!H")[0]
3933 obj.priority = reader.read("!H")[0]
3934 obj.buffer_id = reader.read("!L")[0]
3935 obj.out_port = util.unpack_port_no(reader)
3936 obj.out_group = reader.read("!L")[0]
3937 obj.flags = reader.read("!H")[0]
3938 reader.skip(2)
3939 obj.match = common.match.unpack(reader)
3940 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
3941 return obj
3942
3943 def __eq__(self, other):
3944 if type(self) != type(other): return False
3945 if self.xid != other.xid: return False
3946 if self.cookie != other.cookie: return False
3947 if self.cookie_mask != other.cookie_mask: return False
3948 if self.table_id != other.table_id: return False
3949 if self._command != other._command: return False
3950 if self.idle_timeout != other.idle_timeout: return False
3951 if self.hard_timeout != other.hard_timeout: return False
3952 if self.priority != other.priority: return False
3953 if self.buffer_id != other.buffer_id: return False
3954 if self.out_port != other.out_port: return False
3955 if self.out_group != other.out_group: return False
3956 if self.flags != other.flags: return False
3957 if self.match != other.match: return False
3958 if self.instructions != other.instructions: return False
3959 return True
3960
3961 def pretty_print(self, q):
3962 q.text("flow_mod {")
3963 with q.group():
3964 with q.indent(2):
3965 q.breakable()
3966 q.text("xid = ");
3967 if self.xid != None:
3968 q.text("%#x" % self.xid)
3969 else:
3970 q.text('None')
3971 q.text(","); q.breakable()
3972 q.text("cookie = ");
3973 q.text("%#x" % self.cookie)
3974 q.text(","); q.breakable()
3975 q.text("cookie_mask = ");
3976 q.text("%#x" % self.cookie_mask)
3977 q.text(","); q.breakable()
3978 q.text("table_id = ");
3979 q.text("%#x" % self.table_id)
3980 q.text(","); q.breakable()
3981 q.text("idle_timeout = ");
3982 q.text("%#x" % self.idle_timeout)
3983 q.text(","); q.breakable()
3984 q.text("hard_timeout = ");
3985 q.text("%#x" % self.hard_timeout)
3986 q.text(","); q.breakable()
3987 q.text("priority = ");
3988 q.text("%#x" % self.priority)
3989 q.text(","); q.breakable()
3990 q.text("buffer_id = ");
3991 q.text("%#x" % self.buffer_id)
3992 q.text(","); q.breakable()
3993 q.text("out_port = ");
3994 q.text(util.pretty_port(self.out_port))
3995 q.text(","); q.breakable()
3996 q.text("out_group = ");
3997 q.text("%#x" % self.out_group)
3998 q.text(","); q.breakable()
3999 q.text("flags = ");
4000 q.text("%#x" % self.flags)
4001 q.text(","); q.breakable()
4002 q.text("match = ");
4003 q.pp(self.match)
4004 q.text(","); q.breakable()
4005 q.text("instructions = ");
4006 q.pp(self.instructions)
4007 q.breakable()
4008 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08004009
4010message.subtypes[14] = flow_mod
4011
4012class flow_add(flow_mod):
Dan Talaycof6202252013-07-02 01:00:29 -07004013 version = 3
4014 type = 14
4015 _command = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07004016
4017 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 -08004018 if xid != None:
4019 self.xid = xid
4020 else:
4021 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004022 if cookie != None:
4023 self.cookie = cookie
4024 else:
4025 self.cookie = 0
4026 if cookie_mask != None:
4027 self.cookie_mask = cookie_mask
4028 else:
4029 self.cookie_mask = 0
4030 if table_id != None:
4031 self.table_id = table_id
4032 else:
4033 self.table_id = 0
4034 if idle_timeout != None:
4035 self.idle_timeout = idle_timeout
4036 else:
4037 self.idle_timeout = 0
4038 if hard_timeout != None:
4039 self.hard_timeout = hard_timeout
4040 else:
4041 self.hard_timeout = 0
4042 if priority != None:
4043 self.priority = priority
4044 else:
4045 self.priority = 0
4046 if buffer_id != None:
4047 self.buffer_id = buffer_id
4048 else:
4049 self.buffer_id = 0
4050 if out_port != None:
4051 self.out_port = out_port
4052 else:
4053 self.out_port = 0
4054 if out_group != None:
4055 self.out_group = out_group
4056 else:
4057 self.out_group = 0
4058 if flags != None:
4059 self.flags = flags
4060 else:
4061 self.flags = 0
4062 if match != None:
4063 self.match = match
4064 else:
4065 self.match = common.match()
4066 if instructions != None:
4067 self.instructions = instructions
4068 else:
4069 self.instructions = []
Rich Lane7dcdf022013-12-11 14:45:27 -08004070 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004071
4072 def pack(self):
4073 packed = []
4074 packed.append(struct.pack("!B", self.version))
4075 packed.append(struct.pack("!B", self.type))
4076 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4077 packed.append(struct.pack("!L", self.xid))
4078 packed.append(struct.pack("!Q", self.cookie))
4079 packed.append(struct.pack("!Q", self.cookie_mask))
4080 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004081 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004082 packed.append(struct.pack("!H", self.idle_timeout))
4083 packed.append(struct.pack("!H", self.hard_timeout))
4084 packed.append(struct.pack("!H", self.priority))
4085 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004086 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004087 packed.append(struct.pack("!L", self.out_group))
4088 packed.append(struct.pack("!H", self.flags))
4089 packed.append('\x00' * 2)
4090 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08004091 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004092 length = sum([len(x) for x in packed])
4093 packed[2] = struct.pack("!H", length)
4094 return ''.join(packed)
4095
4096 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004097 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004098 obj = flow_add()
Dan Talaycof6202252013-07-02 01:00:29 -07004099 _version = reader.read("!B")[0]
4100 assert(_version == 3)
4101 _type = reader.read("!B")[0]
4102 assert(_type == 14)
4103 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004104 orig_reader = reader
4105 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07004106 obj.xid = reader.read("!L")[0]
4107 obj.cookie = reader.read("!Q")[0]
4108 obj.cookie_mask = reader.read("!Q")[0]
4109 obj.table_id = reader.read("!B")[0]
4110 __command = util.unpack_fm_cmd(reader)
4111 assert(__command == 0)
4112 obj.idle_timeout = reader.read("!H")[0]
4113 obj.hard_timeout = reader.read("!H")[0]
4114 obj.priority = reader.read("!H")[0]
4115 obj.buffer_id = reader.read("!L")[0]
4116 obj.out_port = util.unpack_port_no(reader)
4117 obj.out_group = reader.read("!L")[0]
4118 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004119 reader.skip(2)
4120 obj.match = common.match.unpack(reader)
Rich Lane7dcdf022013-12-11 14:45:27 -08004121 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07004122 return obj
4123
4124 def __eq__(self, other):
4125 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004126 if self.xid != other.xid: return False
4127 if self.cookie != other.cookie: return False
4128 if self.cookie_mask != other.cookie_mask: return False
4129 if self.table_id != other.table_id: return False
4130 if self.idle_timeout != other.idle_timeout: return False
4131 if self.hard_timeout != other.hard_timeout: return False
4132 if self.priority != other.priority: return False
4133 if self.buffer_id != other.buffer_id: return False
4134 if self.out_port != other.out_port: return False
4135 if self.out_group != other.out_group: return False
4136 if self.flags != other.flags: return False
4137 if self.match != other.match: return False
4138 if self.instructions != other.instructions: return False
4139 return True
4140
Rich Lanec2ee4b82013-04-24 17:12:38 -07004141 def pretty_print(self, q):
4142 q.text("flow_add {")
4143 with q.group():
4144 with q.indent(2):
4145 q.breakable()
4146 q.text("xid = ");
4147 if self.xid != None:
4148 q.text("%#x" % self.xid)
4149 else:
4150 q.text('None')
4151 q.text(","); q.breakable()
4152 q.text("cookie = ");
4153 q.text("%#x" % self.cookie)
4154 q.text(","); q.breakable()
4155 q.text("cookie_mask = ");
4156 q.text("%#x" % self.cookie_mask)
4157 q.text(","); q.breakable()
4158 q.text("table_id = ");
4159 q.text("%#x" % self.table_id)
4160 q.text(","); q.breakable()
4161 q.text("idle_timeout = ");
4162 q.text("%#x" % self.idle_timeout)
4163 q.text(","); q.breakable()
4164 q.text("hard_timeout = ");
4165 q.text("%#x" % self.hard_timeout)
4166 q.text(","); q.breakable()
4167 q.text("priority = ");
4168 q.text("%#x" % self.priority)
4169 q.text(","); q.breakable()
4170 q.text("buffer_id = ");
4171 q.text("%#x" % self.buffer_id)
4172 q.text(","); q.breakable()
4173 q.text("out_port = ");
4174 q.text(util.pretty_port(self.out_port))
4175 q.text(","); q.breakable()
4176 q.text("out_group = ");
4177 q.text("%#x" % self.out_group)
4178 q.text(","); q.breakable()
4179 q.text("flags = ");
4180 q.text("%#x" % self.flags)
4181 q.text(","); q.breakable()
4182 q.text("match = ");
4183 q.pp(self.match)
4184 q.text(","); q.breakable()
4185 q.text("instructions = ");
4186 q.pp(self.instructions)
4187 q.breakable()
4188 q.text('}')
4189
Rich Lane7dcdf022013-12-11 14:45:27 -08004190flow_mod.subtypes[0] = flow_add
4191
4192class flow_delete(flow_mod):
Dan Talaycof6202252013-07-02 01:00:29 -07004193 version = 3
4194 type = 14
4195 _command = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07004196
4197 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 -08004198 if xid != None:
4199 self.xid = xid
4200 else:
4201 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004202 if cookie != None:
4203 self.cookie = cookie
4204 else:
4205 self.cookie = 0
4206 if cookie_mask != None:
4207 self.cookie_mask = cookie_mask
4208 else:
4209 self.cookie_mask = 0
4210 if table_id != None:
4211 self.table_id = table_id
4212 else:
4213 self.table_id = 0
4214 if idle_timeout != None:
4215 self.idle_timeout = idle_timeout
4216 else:
4217 self.idle_timeout = 0
4218 if hard_timeout != None:
4219 self.hard_timeout = hard_timeout
4220 else:
4221 self.hard_timeout = 0
4222 if priority != None:
4223 self.priority = priority
4224 else:
4225 self.priority = 0
4226 if buffer_id != None:
4227 self.buffer_id = buffer_id
4228 else:
4229 self.buffer_id = 0
4230 if out_port != None:
4231 self.out_port = out_port
4232 else:
4233 self.out_port = 0
4234 if out_group != None:
4235 self.out_group = out_group
4236 else:
4237 self.out_group = 0
4238 if flags != None:
4239 self.flags = flags
4240 else:
4241 self.flags = 0
4242 if match != None:
4243 self.match = match
4244 else:
4245 self.match = common.match()
4246 if instructions != None:
4247 self.instructions = instructions
4248 else:
4249 self.instructions = []
Rich Lane7dcdf022013-12-11 14:45:27 -08004250 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004251
4252 def pack(self):
4253 packed = []
4254 packed.append(struct.pack("!B", self.version))
4255 packed.append(struct.pack("!B", self.type))
4256 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4257 packed.append(struct.pack("!L", self.xid))
4258 packed.append(struct.pack("!Q", self.cookie))
4259 packed.append(struct.pack("!Q", self.cookie_mask))
4260 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004261 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004262 packed.append(struct.pack("!H", self.idle_timeout))
4263 packed.append(struct.pack("!H", self.hard_timeout))
4264 packed.append(struct.pack("!H", self.priority))
4265 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004266 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004267 packed.append(struct.pack("!L", self.out_group))
4268 packed.append(struct.pack("!H", self.flags))
4269 packed.append('\x00' * 2)
4270 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08004271 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004272 length = sum([len(x) for x in packed])
4273 packed[2] = struct.pack("!H", length)
4274 return ''.join(packed)
4275
4276 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004277 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004278 obj = flow_delete()
Dan Talaycof6202252013-07-02 01:00:29 -07004279 _version = reader.read("!B")[0]
4280 assert(_version == 3)
4281 _type = reader.read("!B")[0]
4282 assert(_type == 14)
4283 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004284 orig_reader = reader
4285 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07004286 obj.xid = reader.read("!L")[0]
4287 obj.cookie = reader.read("!Q")[0]
4288 obj.cookie_mask = reader.read("!Q")[0]
4289 obj.table_id = reader.read("!B")[0]
4290 __command = util.unpack_fm_cmd(reader)
4291 assert(__command == 3)
4292 obj.idle_timeout = reader.read("!H")[0]
4293 obj.hard_timeout = reader.read("!H")[0]
4294 obj.priority = reader.read("!H")[0]
4295 obj.buffer_id = reader.read("!L")[0]
4296 obj.out_port = util.unpack_port_no(reader)
4297 obj.out_group = reader.read("!L")[0]
4298 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004299 reader.skip(2)
4300 obj.match = common.match.unpack(reader)
Rich Lane7dcdf022013-12-11 14:45:27 -08004301 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07004302 return obj
4303
4304 def __eq__(self, other):
4305 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004306 if self.xid != other.xid: return False
4307 if self.cookie != other.cookie: return False
4308 if self.cookie_mask != other.cookie_mask: return False
4309 if self.table_id != other.table_id: return False
4310 if self.idle_timeout != other.idle_timeout: return False
4311 if self.hard_timeout != other.hard_timeout: return False
4312 if self.priority != other.priority: return False
4313 if self.buffer_id != other.buffer_id: return False
4314 if self.out_port != other.out_port: return False
4315 if self.out_group != other.out_group: return False
4316 if self.flags != other.flags: return False
4317 if self.match != other.match: return False
4318 if self.instructions != other.instructions: return False
4319 return True
4320
Rich Lanec2ee4b82013-04-24 17:12:38 -07004321 def pretty_print(self, q):
4322 q.text("flow_delete {")
4323 with q.group():
4324 with q.indent(2):
4325 q.breakable()
4326 q.text("xid = ");
4327 if self.xid != None:
4328 q.text("%#x" % self.xid)
4329 else:
4330 q.text('None')
4331 q.text(","); q.breakable()
4332 q.text("cookie = ");
4333 q.text("%#x" % self.cookie)
4334 q.text(","); q.breakable()
4335 q.text("cookie_mask = ");
4336 q.text("%#x" % self.cookie_mask)
4337 q.text(","); q.breakable()
4338 q.text("table_id = ");
4339 q.text("%#x" % self.table_id)
4340 q.text(","); q.breakable()
4341 q.text("idle_timeout = ");
4342 q.text("%#x" % self.idle_timeout)
4343 q.text(","); q.breakable()
4344 q.text("hard_timeout = ");
4345 q.text("%#x" % self.hard_timeout)
4346 q.text(","); q.breakable()
4347 q.text("priority = ");
4348 q.text("%#x" % self.priority)
4349 q.text(","); q.breakable()
4350 q.text("buffer_id = ");
4351 q.text("%#x" % self.buffer_id)
4352 q.text(","); q.breakable()
4353 q.text("out_port = ");
4354 q.text(util.pretty_port(self.out_port))
4355 q.text(","); q.breakable()
4356 q.text("out_group = ");
4357 q.text("%#x" % self.out_group)
4358 q.text(","); q.breakable()
4359 q.text("flags = ");
4360 q.text("%#x" % self.flags)
4361 q.text(","); q.breakable()
4362 q.text("match = ");
4363 q.pp(self.match)
4364 q.text(","); q.breakable()
4365 q.text("instructions = ");
4366 q.pp(self.instructions)
4367 q.breakable()
4368 q.text('}')
4369
Rich Lane7dcdf022013-12-11 14:45:27 -08004370flow_mod.subtypes[3] = flow_delete
4371
4372class flow_delete_strict(flow_mod):
Dan Talaycof6202252013-07-02 01:00:29 -07004373 version = 3
4374 type = 14
4375 _command = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07004376
4377 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 -08004378 if xid != None:
4379 self.xid = xid
4380 else:
4381 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004382 if cookie != None:
4383 self.cookie = cookie
4384 else:
4385 self.cookie = 0
4386 if cookie_mask != None:
4387 self.cookie_mask = cookie_mask
4388 else:
4389 self.cookie_mask = 0
4390 if table_id != None:
4391 self.table_id = table_id
4392 else:
4393 self.table_id = 0
4394 if idle_timeout != None:
4395 self.idle_timeout = idle_timeout
4396 else:
4397 self.idle_timeout = 0
4398 if hard_timeout != None:
4399 self.hard_timeout = hard_timeout
4400 else:
4401 self.hard_timeout = 0
4402 if priority != None:
4403 self.priority = priority
4404 else:
4405 self.priority = 0
4406 if buffer_id != None:
4407 self.buffer_id = buffer_id
4408 else:
4409 self.buffer_id = 0
4410 if out_port != None:
4411 self.out_port = out_port
4412 else:
4413 self.out_port = 0
4414 if out_group != None:
4415 self.out_group = out_group
4416 else:
4417 self.out_group = 0
4418 if flags != None:
4419 self.flags = flags
4420 else:
4421 self.flags = 0
4422 if match != None:
4423 self.match = match
4424 else:
4425 self.match = common.match()
4426 if instructions != None:
4427 self.instructions = instructions
4428 else:
4429 self.instructions = []
Rich Lane7dcdf022013-12-11 14:45:27 -08004430 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004431
4432 def pack(self):
4433 packed = []
4434 packed.append(struct.pack("!B", self.version))
4435 packed.append(struct.pack("!B", self.type))
4436 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4437 packed.append(struct.pack("!L", self.xid))
4438 packed.append(struct.pack("!Q", self.cookie))
4439 packed.append(struct.pack("!Q", self.cookie_mask))
4440 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004441 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004442 packed.append(struct.pack("!H", self.idle_timeout))
4443 packed.append(struct.pack("!H", self.hard_timeout))
4444 packed.append(struct.pack("!H", self.priority))
4445 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004446 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004447 packed.append(struct.pack("!L", self.out_group))
4448 packed.append(struct.pack("!H", self.flags))
4449 packed.append('\x00' * 2)
4450 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08004451 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004452 length = sum([len(x) for x in packed])
4453 packed[2] = struct.pack("!H", length)
4454 return ''.join(packed)
4455
4456 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004457 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004458 obj = flow_delete_strict()
Dan Talaycof6202252013-07-02 01:00:29 -07004459 _version = reader.read("!B")[0]
4460 assert(_version == 3)
4461 _type = reader.read("!B")[0]
4462 assert(_type == 14)
4463 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004464 orig_reader = reader
4465 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07004466 obj.xid = reader.read("!L")[0]
4467 obj.cookie = reader.read("!Q")[0]
4468 obj.cookie_mask = reader.read("!Q")[0]
4469 obj.table_id = reader.read("!B")[0]
4470 __command = util.unpack_fm_cmd(reader)
4471 assert(__command == 4)
4472 obj.idle_timeout = reader.read("!H")[0]
4473 obj.hard_timeout = reader.read("!H")[0]
4474 obj.priority = reader.read("!H")[0]
4475 obj.buffer_id = reader.read("!L")[0]
4476 obj.out_port = util.unpack_port_no(reader)
4477 obj.out_group = reader.read("!L")[0]
4478 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004479 reader.skip(2)
4480 obj.match = common.match.unpack(reader)
Rich Lane7dcdf022013-12-11 14:45:27 -08004481 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07004482 return obj
4483
4484 def __eq__(self, other):
4485 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004486 if self.xid != other.xid: return False
4487 if self.cookie != other.cookie: return False
4488 if self.cookie_mask != other.cookie_mask: return False
4489 if self.table_id != other.table_id: return False
4490 if self.idle_timeout != other.idle_timeout: return False
4491 if self.hard_timeout != other.hard_timeout: return False
4492 if self.priority != other.priority: return False
4493 if self.buffer_id != other.buffer_id: return False
4494 if self.out_port != other.out_port: return False
4495 if self.out_group != other.out_group: return False
4496 if self.flags != other.flags: return False
4497 if self.match != other.match: return False
4498 if self.instructions != other.instructions: return False
4499 return True
4500
Rich Lanec2ee4b82013-04-24 17:12:38 -07004501 def pretty_print(self, q):
4502 q.text("flow_delete_strict {")
4503 with q.group():
4504 with q.indent(2):
4505 q.breakable()
4506 q.text("xid = ");
4507 if self.xid != None:
4508 q.text("%#x" % self.xid)
4509 else:
4510 q.text('None')
4511 q.text(","); q.breakable()
4512 q.text("cookie = ");
4513 q.text("%#x" % self.cookie)
4514 q.text(","); q.breakable()
4515 q.text("cookie_mask = ");
4516 q.text("%#x" % self.cookie_mask)
4517 q.text(","); q.breakable()
4518 q.text("table_id = ");
4519 q.text("%#x" % self.table_id)
4520 q.text(","); q.breakable()
4521 q.text("idle_timeout = ");
4522 q.text("%#x" % self.idle_timeout)
4523 q.text(","); q.breakable()
4524 q.text("hard_timeout = ");
4525 q.text("%#x" % self.hard_timeout)
4526 q.text(","); q.breakable()
4527 q.text("priority = ");
4528 q.text("%#x" % self.priority)
4529 q.text(","); q.breakable()
4530 q.text("buffer_id = ");
4531 q.text("%#x" % self.buffer_id)
4532 q.text(","); q.breakable()
4533 q.text("out_port = ");
4534 q.text(util.pretty_port(self.out_port))
4535 q.text(","); q.breakable()
4536 q.text("out_group = ");
4537 q.text("%#x" % self.out_group)
4538 q.text(","); q.breakable()
4539 q.text("flags = ");
4540 q.text("%#x" % self.flags)
4541 q.text(","); q.breakable()
4542 q.text("match = ");
4543 q.pp(self.match)
4544 q.text(","); q.breakable()
4545 q.text("instructions = ");
4546 q.pp(self.instructions)
4547 q.breakable()
4548 q.text('}')
4549
Rich Lane7dcdf022013-12-11 14:45:27 -08004550flow_mod.subtypes[4] = flow_delete_strict
4551
4552class flow_mod_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07004553 version = 3
4554 type = 1
4555 err_type = 5
4556
4557 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08004558 if xid != None:
4559 self.xid = xid
4560 else:
4561 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07004562 if code != None:
4563 self.code = code
4564 else:
4565 self.code = 0
4566 if data != None:
4567 self.data = data
4568 else:
4569 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08004570 return
Rich Lane6f4978c2013-10-20 21:33:52 -07004571
4572 def pack(self):
4573 packed = []
4574 packed.append(struct.pack("!B", self.version))
4575 packed.append(struct.pack("!B", self.type))
4576 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4577 packed.append(struct.pack("!L", self.xid))
4578 packed.append(struct.pack("!H", self.err_type))
4579 packed.append(struct.pack("!H", self.code))
4580 packed.append(self.data)
4581 length = sum([len(x) for x in packed])
4582 packed[2] = struct.pack("!H", length)
4583 return ''.join(packed)
4584
4585 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004586 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07004587 obj = flow_mod_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07004588 _version = reader.read("!B")[0]
4589 assert(_version == 3)
4590 _type = reader.read("!B")[0]
4591 assert(_type == 1)
4592 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004593 orig_reader = reader
4594 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07004595 obj.xid = reader.read("!L")[0]
4596 _err_type = reader.read("!H")[0]
4597 assert(_err_type == 5)
4598 obj.code = reader.read("!H")[0]
4599 obj.data = str(reader.read_all())
4600 return obj
4601
4602 def __eq__(self, other):
4603 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07004604 if self.xid != other.xid: return False
4605 if self.code != other.code: return False
4606 if self.data != other.data: return False
4607 return True
4608
Rich Lane6f4978c2013-10-20 21:33:52 -07004609 def pretty_print(self, q):
4610 q.text("flow_mod_failed_error_msg {")
4611 with q.group():
4612 with q.indent(2):
4613 q.breakable()
4614 q.text("xid = ");
4615 if self.xid != None:
4616 q.text("%#x" % self.xid)
4617 else:
4618 q.text('None')
4619 q.text(","); q.breakable()
4620 q.text("code = ");
4621 q.text("%#x" % self.code)
4622 q.text(","); q.breakable()
4623 q.text("data = ");
4624 q.pp(self.data)
4625 q.breakable()
4626 q.text('}')
4627
Rich Lane7dcdf022013-12-11 14:45:27 -08004628error_msg.subtypes[5] = flow_mod_failed_error_msg
4629
4630class flow_modify(flow_mod):
Dan Talaycof6202252013-07-02 01:00:29 -07004631 version = 3
4632 type = 14
4633 _command = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07004634
4635 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 -08004636 if xid != None:
4637 self.xid = xid
4638 else:
4639 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004640 if cookie != None:
4641 self.cookie = cookie
4642 else:
4643 self.cookie = 0
4644 if cookie_mask != None:
4645 self.cookie_mask = cookie_mask
4646 else:
4647 self.cookie_mask = 0
4648 if table_id != None:
4649 self.table_id = table_id
4650 else:
4651 self.table_id = 0
4652 if idle_timeout != None:
4653 self.idle_timeout = idle_timeout
4654 else:
4655 self.idle_timeout = 0
4656 if hard_timeout != None:
4657 self.hard_timeout = hard_timeout
4658 else:
4659 self.hard_timeout = 0
4660 if priority != None:
4661 self.priority = priority
4662 else:
4663 self.priority = 0
4664 if buffer_id != None:
4665 self.buffer_id = buffer_id
4666 else:
4667 self.buffer_id = 0
4668 if out_port != None:
4669 self.out_port = out_port
4670 else:
4671 self.out_port = 0
4672 if out_group != None:
4673 self.out_group = out_group
4674 else:
4675 self.out_group = 0
4676 if flags != None:
4677 self.flags = flags
4678 else:
4679 self.flags = 0
4680 if match != None:
4681 self.match = match
4682 else:
4683 self.match = common.match()
4684 if instructions != None:
4685 self.instructions = instructions
4686 else:
4687 self.instructions = []
Rich Lane7dcdf022013-12-11 14:45:27 -08004688 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004689
4690 def pack(self):
4691 packed = []
4692 packed.append(struct.pack("!B", self.version))
4693 packed.append(struct.pack("!B", self.type))
4694 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4695 packed.append(struct.pack("!L", self.xid))
4696 packed.append(struct.pack("!Q", self.cookie))
4697 packed.append(struct.pack("!Q", self.cookie_mask))
4698 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004699 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004700 packed.append(struct.pack("!H", self.idle_timeout))
4701 packed.append(struct.pack("!H", self.hard_timeout))
4702 packed.append(struct.pack("!H", self.priority))
4703 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004704 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004705 packed.append(struct.pack("!L", self.out_group))
4706 packed.append(struct.pack("!H", self.flags))
4707 packed.append('\x00' * 2)
4708 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08004709 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004710 length = sum([len(x) for x in packed])
4711 packed[2] = struct.pack("!H", length)
4712 return ''.join(packed)
4713
4714 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004715 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004716 obj = flow_modify()
Dan Talaycof6202252013-07-02 01:00:29 -07004717 _version = reader.read("!B")[0]
4718 assert(_version == 3)
4719 _type = reader.read("!B")[0]
4720 assert(_type == 14)
4721 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004722 orig_reader = reader
4723 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07004724 obj.xid = reader.read("!L")[0]
4725 obj.cookie = reader.read("!Q")[0]
4726 obj.cookie_mask = reader.read("!Q")[0]
4727 obj.table_id = reader.read("!B")[0]
4728 __command = util.unpack_fm_cmd(reader)
4729 assert(__command == 1)
4730 obj.idle_timeout = reader.read("!H")[0]
4731 obj.hard_timeout = reader.read("!H")[0]
4732 obj.priority = reader.read("!H")[0]
4733 obj.buffer_id = reader.read("!L")[0]
4734 obj.out_port = util.unpack_port_no(reader)
4735 obj.out_group = reader.read("!L")[0]
4736 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004737 reader.skip(2)
4738 obj.match = common.match.unpack(reader)
Rich Lane7dcdf022013-12-11 14:45:27 -08004739 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07004740 return obj
4741
4742 def __eq__(self, other):
4743 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004744 if self.xid != other.xid: return False
4745 if self.cookie != other.cookie: return False
4746 if self.cookie_mask != other.cookie_mask: return False
4747 if self.table_id != other.table_id: return False
4748 if self.idle_timeout != other.idle_timeout: return False
4749 if self.hard_timeout != other.hard_timeout: return False
4750 if self.priority != other.priority: return False
4751 if self.buffer_id != other.buffer_id: return False
4752 if self.out_port != other.out_port: return False
4753 if self.out_group != other.out_group: return False
4754 if self.flags != other.flags: return False
4755 if self.match != other.match: return False
4756 if self.instructions != other.instructions: return False
4757 return True
4758
Rich Lanec2ee4b82013-04-24 17:12:38 -07004759 def pretty_print(self, q):
4760 q.text("flow_modify {")
4761 with q.group():
4762 with q.indent(2):
4763 q.breakable()
4764 q.text("xid = ");
4765 if self.xid != None:
4766 q.text("%#x" % self.xid)
4767 else:
4768 q.text('None')
4769 q.text(","); q.breakable()
4770 q.text("cookie = ");
4771 q.text("%#x" % self.cookie)
4772 q.text(","); q.breakable()
4773 q.text("cookie_mask = ");
4774 q.text("%#x" % self.cookie_mask)
4775 q.text(","); q.breakable()
4776 q.text("table_id = ");
4777 q.text("%#x" % self.table_id)
4778 q.text(","); q.breakable()
4779 q.text("idle_timeout = ");
4780 q.text("%#x" % self.idle_timeout)
4781 q.text(","); q.breakable()
4782 q.text("hard_timeout = ");
4783 q.text("%#x" % self.hard_timeout)
4784 q.text(","); q.breakable()
4785 q.text("priority = ");
4786 q.text("%#x" % self.priority)
4787 q.text(","); q.breakable()
4788 q.text("buffer_id = ");
4789 q.text("%#x" % self.buffer_id)
4790 q.text(","); q.breakable()
4791 q.text("out_port = ");
4792 q.text(util.pretty_port(self.out_port))
4793 q.text(","); q.breakable()
4794 q.text("out_group = ");
4795 q.text("%#x" % self.out_group)
4796 q.text(","); q.breakable()
4797 q.text("flags = ");
4798 q.text("%#x" % self.flags)
4799 q.text(","); q.breakable()
4800 q.text("match = ");
4801 q.pp(self.match)
4802 q.text(","); q.breakable()
4803 q.text("instructions = ");
4804 q.pp(self.instructions)
4805 q.breakable()
4806 q.text('}')
4807
Rich Lane7dcdf022013-12-11 14:45:27 -08004808flow_mod.subtypes[1] = flow_modify
4809
4810class flow_modify_strict(flow_mod):
Dan Talaycof6202252013-07-02 01:00:29 -07004811 version = 3
4812 type = 14
4813 _command = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07004814
4815 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 -08004816 if xid != None:
4817 self.xid = xid
4818 else:
4819 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004820 if cookie != None:
4821 self.cookie = cookie
4822 else:
4823 self.cookie = 0
4824 if cookie_mask != None:
4825 self.cookie_mask = cookie_mask
4826 else:
4827 self.cookie_mask = 0
4828 if table_id != None:
4829 self.table_id = table_id
4830 else:
4831 self.table_id = 0
4832 if idle_timeout != None:
4833 self.idle_timeout = idle_timeout
4834 else:
4835 self.idle_timeout = 0
4836 if hard_timeout != None:
4837 self.hard_timeout = hard_timeout
4838 else:
4839 self.hard_timeout = 0
4840 if priority != None:
4841 self.priority = priority
4842 else:
4843 self.priority = 0
4844 if buffer_id != None:
4845 self.buffer_id = buffer_id
4846 else:
4847 self.buffer_id = 0
4848 if out_port != None:
4849 self.out_port = out_port
4850 else:
4851 self.out_port = 0
4852 if out_group != None:
4853 self.out_group = out_group
4854 else:
4855 self.out_group = 0
4856 if flags != None:
4857 self.flags = flags
4858 else:
4859 self.flags = 0
4860 if match != None:
4861 self.match = match
4862 else:
4863 self.match = common.match()
4864 if instructions != None:
4865 self.instructions = instructions
4866 else:
4867 self.instructions = []
Rich Lane7dcdf022013-12-11 14:45:27 -08004868 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004869
4870 def pack(self):
4871 packed = []
4872 packed.append(struct.pack("!B", self.version))
4873 packed.append(struct.pack("!B", self.type))
4874 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4875 packed.append(struct.pack("!L", self.xid))
4876 packed.append(struct.pack("!Q", self.cookie))
4877 packed.append(struct.pack("!Q", self.cookie_mask))
4878 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004879 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004880 packed.append(struct.pack("!H", self.idle_timeout))
4881 packed.append(struct.pack("!H", self.hard_timeout))
4882 packed.append(struct.pack("!H", self.priority))
4883 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004884 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004885 packed.append(struct.pack("!L", self.out_group))
4886 packed.append(struct.pack("!H", self.flags))
4887 packed.append('\x00' * 2)
4888 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08004889 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004890 length = sum([len(x) for x in packed])
4891 packed[2] = struct.pack("!H", length)
4892 return ''.join(packed)
4893
4894 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004895 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004896 obj = flow_modify_strict()
Dan Talaycof6202252013-07-02 01:00:29 -07004897 _version = reader.read("!B")[0]
4898 assert(_version == 3)
4899 _type = reader.read("!B")[0]
4900 assert(_type == 14)
4901 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004902 orig_reader = reader
4903 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07004904 obj.xid = reader.read("!L")[0]
4905 obj.cookie = reader.read("!Q")[0]
4906 obj.cookie_mask = reader.read("!Q")[0]
4907 obj.table_id = reader.read("!B")[0]
4908 __command = util.unpack_fm_cmd(reader)
4909 assert(__command == 2)
4910 obj.idle_timeout = reader.read("!H")[0]
4911 obj.hard_timeout = reader.read("!H")[0]
4912 obj.priority = reader.read("!H")[0]
4913 obj.buffer_id = reader.read("!L")[0]
4914 obj.out_port = util.unpack_port_no(reader)
4915 obj.out_group = reader.read("!L")[0]
4916 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004917 reader.skip(2)
4918 obj.match = common.match.unpack(reader)
Rich Lane7dcdf022013-12-11 14:45:27 -08004919 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07004920 return obj
4921
4922 def __eq__(self, other):
4923 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004924 if self.xid != other.xid: return False
4925 if self.cookie != other.cookie: return False
4926 if self.cookie_mask != other.cookie_mask: return False
4927 if self.table_id != other.table_id: return False
4928 if self.idle_timeout != other.idle_timeout: return False
4929 if self.hard_timeout != other.hard_timeout: return False
4930 if self.priority != other.priority: return False
4931 if self.buffer_id != other.buffer_id: return False
4932 if self.out_port != other.out_port: return False
4933 if self.out_group != other.out_group: return False
4934 if self.flags != other.flags: return False
4935 if self.match != other.match: return False
4936 if self.instructions != other.instructions: return False
4937 return True
4938
Rich Lanec2ee4b82013-04-24 17:12:38 -07004939 def pretty_print(self, q):
4940 q.text("flow_modify_strict {")
4941 with q.group():
4942 with q.indent(2):
4943 q.breakable()
4944 q.text("xid = ");
4945 if self.xid != None:
4946 q.text("%#x" % self.xid)
4947 else:
4948 q.text('None')
4949 q.text(","); q.breakable()
4950 q.text("cookie = ");
4951 q.text("%#x" % self.cookie)
4952 q.text(","); q.breakable()
4953 q.text("cookie_mask = ");
4954 q.text("%#x" % self.cookie_mask)
4955 q.text(","); q.breakable()
4956 q.text("table_id = ");
4957 q.text("%#x" % self.table_id)
4958 q.text(","); q.breakable()
4959 q.text("idle_timeout = ");
4960 q.text("%#x" % self.idle_timeout)
4961 q.text(","); q.breakable()
4962 q.text("hard_timeout = ");
4963 q.text("%#x" % self.hard_timeout)
4964 q.text(","); q.breakable()
4965 q.text("priority = ");
4966 q.text("%#x" % self.priority)
4967 q.text(","); q.breakable()
4968 q.text("buffer_id = ");
4969 q.text("%#x" % self.buffer_id)
4970 q.text(","); q.breakable()
4971 q.text("out_port = ");
4972 q.text(util.pretty_port(self.out_port))
4973 q.text(","); q.breakable()
4974 q.text("out_group = ");
4975 q.text("%#x" % self.out_group)
4976 q.text(","); q.breakable()
4977 q.text("flags = ");
4978 q.text("%#x" % self.flags)
4979 q.text(","); q.breakable()
4980 q.text("match = ");
4981 q.pp(self.match)
4982 q.text(","); q.breakable()
4983 q.text("instructions = ");
4984 q.pp(self.instructions)
4985 q.breakable()
4986 q.text('}')
4987
Rich Lane7dcdf022013-12-11 14:45:27 -08004988flow_mod.subtypes[2] = flow_modify_strict
4989
4990class flow_removed(message):
Dan Talaycof6202252013-07-02 01:00:29 -07004991 version = 3
4992 type = 11
Rich Lanec2ee4b82013-04-24 17:12:38 -07004993
4994 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 -08004995 if xid != None:
4996 self.xid = xid
4997 else:
4998 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004999 if cookie != None:
5000 self.cookie = cookie
5001 else:
5002 self.cookie = 0
5003 if priority != None:
5004 self.priority = priority
5005 else:
5006 self.priority = 0
5007 if reason != None:
5008 self.reason = reason
5009 else:
5010 self.reason = 0
5011 if table_id != None:
5012 self.table_id = table_id
5013 else:
5014 self.table_id = 0
5015 if duration_sec != None:
5016 self.duration_sec = duration_sec
5017 else:
5018 self.duration_sec = 0
5019 if duration_nsec != None:
5020 self.duration_nsec = duration_nsec
5021 else:
5022 self.duration_nsec = 0
5023 if idle_timeout != None:
5024 self.idle_timeout = idle_timeout
5025 else:
5026 self.idle_timeout = 0
5027 if hard_timeout != None:
5028 self.hard_timeout = hard_timeout
5029 else:
5030 self.hard_timeout = 0
5031 if packet_count != None:
5032 self.packet_count = packet_count
5033 else:
5034 self.packet_count = 0
5035 if byte_count != None:
5036 self.byte_count = byte_count
5037 else:
5038 self.byte_count = 0
5039 if match != None:
5040 self.match = match
5041 else:
5042 self.match = common.match()
Rich Lane7dcdf022013-12-11 14:45:27 -08005043 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005044
5045 def pack(self):
5046 packed = []
5047 packed.append(struct.pack("!B", self.version))
5048 packed.append(struct.pack("!B", self.type))
5049 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5050 packed.append(struct.pack("!L", self.xid))
5051 packed.append(struct.pack("!Q", self.cookie))
5052 packed.append(struct.pack("!H", self.priority))
5053 packed.append(struct.pack("!B", self.reason))
5054 packed.append(struct.pack("!B", self.table_id))
5055 packed.append(struct.pack("!L", self.duration_sec))
5056 packed.append(struct.pack("!L", self.duration_nsec))
5057 packed.append(struct.pack("!H", self.idle_timeout))
5058 packed.append(struct.pack("!H", self.hard_timeout))
5059 packed.append(struct.pack("!Q", self.packet_count))
5060 packed.append(struct.pack("!Q", self.byte_count))
5061 packed.append(self.match.pack())
5062 length = sum([len(x) for x in packed])
5063 packed[2] = struct.pack("!H", length)
5064 return ''.join(packed)
5065
5066 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005067 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005068 obj = flow_removed()
Dan Talaycof6202252013-07-02 01:00:29 -07005069 _version = reader.read("!B")[0]
5070 assert(_version == 3)
5071 _type = reader.read("!B")[0]
5072 assert(_type == 11)
5073 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005074 orig_reader = reader
5075 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005076 obj.xid = reader.read("!L")[0]
5077 obj.cookie = reader.read("!Q")[0]
5078 obj.priority = reader.read("!H")[0]
5079 obj.reason = reader.read("!B")[0]
5080 obj.table_id = reader.read("!B")[0]
5081 obj.duration_sec = reader.read("!L")[0]
5082 obj.duration_nsec = reader.read("!L")[0]
5083 obj.idle_timeout = reader.read("!H")[0]
5084 obj.hard_timeout = reader.read("!H")[0]
5085 obj.packet_count = reader.read("!Q")[0]
5086 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005087 obj.match = common.match.unpack(reader)
5088 return obj
5089
5090 def __eq__(self, other):
5091 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005092 if self.xid != other.xid: return False
5093 if self.cookie != other.cookie: return False
5094 if self.priority != other.priority: return False
5095 if self.reason != other.reason: return False
5096 if self.table_id != other.table_id: return False
5097 if self.duration_sec != other.duration_sec: return False
5098 if self.duration_nsec != other.duration_nsec: return False
5099 if self.idle_timeout != other.idle_timeout: return False
5100 if self.hard_timeout != other.hard_timeout: return False
5101 if self.packet_count != other.packet_count: return False
5102 if self.byte_count != other.byte_count: return False
5103 if self.match != other.match: return False
5104 return True
5105
Rich Lanec2ee4b82013-04-24 17:12:38 -07005106 def pretty_print(self, q):
5107 q.text("flow_removed {")
5108 with q.group():
5109 with q.indent(2):
5110 q.breakable()
5111 q.text("xid = ");
5112 if self.xid != None:
5113 q.text("%#x" % self.xid)
5114 else:
5115 q.text('None')
5116 q.text(","); q.breakable()
5117 q.text("cookie = ");
5118 q.text("%#x" % self.cookie)
5119 q.text(","); q.breakable()
5120 q.text("priority = ");
5121 q.text("%#x" % self.priority)
5122 q.text(","); q.breakable()
5123 q.text("reason = ");
5124 q.text("%#x" % self.reason)
5125 q.text(","); q.breakable()
5126 q.text("table_id = ");
5127 q.text("%#x" % self.table_id)
5128 q.text(","); q.breakable()
5129 q.text("duration_sec = ");
5130 q.text("%#x" % self.duration_sec)
5131 q.text(","); q.breakable()
5132 q.text("duration_nsec = ");
5133 q.text("%#x" % self.duration_nsec)
5134 q.text(","); q.breakable()
5135 q.text("idle_timeout = ");
5136 q.text("%#x" % self.idle_timeout)
5137 q.text(","); q.breakable()
5138 q.text("hard_timeout = ");
5139 q.text("%#x" % self.hard_timeout)
5140 q.text(","); q.breakable()
5141 q.text("packet_count = ");
5142 q.text("%#x" % self.packet_count)
5143 q.text(","); q.breakable()
5144 q.text("byte_count = ");
5145 q.text("%#x" % self.byte_count)
5146 q.text(","); q.breakable()
5147 q.text("match = ");
5148 q.pp(self.match)
5149 q.breakable()
5150 q.text('}')
5151
Rich Lane7dcdf022013-12-11 14:45:27 -08005152message.subtypes[11] = flow_removed
5153
5154class flow_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07005155 version = 3
5156 type = 19
5157 stats_type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07005158
5159 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005160 if xid != None:
5161 self.xid = xid
5162 else:
5163 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005164 if flags != None:
5165 self.flags = flags
5166 else:
5167 self.flags = 0
5168 if entries != None:
5169 self.entries = entries
5170 else:
5171 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08005172 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005173
5174 def pack(self):
5175 packed = []
5176 packed.append(struct.pack("!B", self.version))
5177 packed.append(struct.pack("!B", self.type))
5178 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5179 packed.append(struct.pack("!L", self.xid))
5180 packed.append(struct.pack("!H", self.stats_type))
5181 packed.append(struct.pack("!H", self.flags))
5182 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08005183 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005184 length = sum([len(x) for x in packed])
5185 packed[2] = struct.pack("!H", length)
5186 return ''.join(packed)
5187
5188 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005189 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005190 obj = flow_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07005191 _version = reader.read("!B")[0]
5192 assert(_version == 3)
5193 _type = reader.read("!B")[0]
5194 assert(_type == 19)
5195 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005196 orig_reader = reader
5197 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005198 obj.xid = reader.read("!L")[0]
5199 _stats_type = reader.read("!H")[0]
5200 assert(_stats_type == 1)
5201 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005202 reader.skip(4)
Rich Lane7dcdf022013-12-11 14:45:27 -08005203 obj.entries = loxi.generic_util.unpack_list(reader, common.flow_stats_entry.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07005204 return obj
5205
5206 def __eq__(self, other):
5207 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005208 if self.xid != other.xid: return False
5209 if self.flags != other.flags: return False
5210 if self.entries != other.entries: return False
5211 return True
5212
Rich Lanec2ee4b82013-04-24 17:12:38 -07005213 def pretty_print(self, q):
5214 q.text("flow_stats_reply {")
5215 with q.group():
5216 with q.indent(2):
5217 q.breakable()
5218 q.text("xid = ");
5219 if self.xid != None:
5220 q.text("%#x" % self.xid)
5221 else:
5222 q.text('None')
5223 q.text(","); q.breakable()
5224 q.text("flags = ");
5225 q.text("%#x" % self.flags)
5226 q.text(","); q.breakable()
5227 q.text("entries = ");
5228 q.pp(self.entries)
5229 q.breakable()
5230 q.text('}')
5231
Rich Lane7dcdf022013-12-11 14:45:27 -08005232stats_reply.subtypes[1] = flow_stats_reply
5233
5234class flow_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07005235 version = 3
5236 type = 18
5237 stats_type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07005238
5239 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 -08005240 if xid != None:
5241 self.xid = xid
5242 else:
5243 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005244 if flags != None:
5245 self.flags = flags
5246 else:
5247 self.flags = 0
5248 if table_id != None:
5249 self.table_id = table_id
5250 else:
5251 self.table_id = 0
5252 if out_port != None:
5253 self.out_port = out_port
5254 else:
5255 self.out_port = 0
5256 if out_group != None:
5257 self.out_group = out_group
5258 else:
5259 self.out_group = 0
5260 if cookie != None:
5261 self.cookie = cookie
5262 else:
5263 self.cookie = 0
5264 if cookie_mask != None:
5265 self.cookie_mask = cookie_mask
5266 else:
5267 self.cookie_mask = 0
5268 if match != None:
5269 self.match = match
5270 else:
5271 self.match = common.match()
Rich Lane7dcdf022013-12-11 14:45:27 -08005272 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005273
5274 def pack(self):
5275 packed = []
5276 packed.append(struct.pack("!B", self.version))
5277 packed.append(struct.pack("!B", self.type))
5278 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5279 packed.append(struct.pack("!L", self.xid))
5280 packed.append(struct.pack("!H", self.stats_type))
5281 packed.append(struct.pack("!H", self.flags))
5282 packed.append('\x00' * 4)
5283 packed.append(struct.pack("!B", self.table_id))
5284 packed.append('\x00' * 3)
Dan Talaycof6202252013-07-02 01:00:29 -07005285 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005286 packed.append(struct.pack("!L", self.out_group))
5287 packed.append('\x00' * 4)
5288 packed.append(struct.pack("!Q", self.cookie))
5289 packed.append(struct.pack("!Q", self.cookie_mask))
5290 packed.append(self.match.pack())
5291 length = sum([len(x) for x in packed])
5292 packed[2] = struct.pack("!H", length)
5293 return ''.join(packed)
5294
5295 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005296 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005297 obj = flow_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07005298 _version = reader.read("!B")[0]
5299 assert(_version == 3)
5300 _type = reader.read("!B")[0]
5301 assert(_type == 18)
5302 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005303 orig_reader = reader
5304 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005305 obj.xid = reader.read("!L")[0]
5306 _stats_type = reader.read("!H")[0]
5307 assert(_stats_type == 1)
5308 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005309 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07005310 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005311 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07005312 obj.out_port = util.unpack_port_no(reader)
5313 obj.out_group = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005314 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07005315 obj.cookie = reader.read("!Q")[0]
5316 obj.cookie_mask = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005317 obj.match = common.match.unpack(reader)
5318 return obj
5319
5320 def __eq__(self, other):
5321 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005322 if self.xid != other.xid: return False
5323 if self.flags != other.flags: return False
5324 if self.table_id != other.table_id: return False
5325 if self.out_port != other.out_port: return False
5326 if self.out_group != other.out_group: return False
5327 if self.cookie != other.cookie: return False
5328 if self.cookie_mask != other.cookie_mask: return False
5329 if self.match != other.match: return False
5330 return True
5331
Rich Lanec2ee4b82013-04-24 17:12:38 -07005332 def pretty_print(self, q):
5333 q.text("flow_stats_request {")
5334 with q.group():
5335 with q.indent(2):
5336 q.breakable()
5337 q.text("xid = ");
5338 if self.xid != None:
5339 q.text("%#x" % self.xid)
5340 else:
5341 q.text('None')
5342 q.text(","); q.breakable()
5343 q.text("flags = ");
5344 q.text("%#x" % self.flags)
5345 q.text(","); q.breakable()
5346 q.text("table_id = ");
5347 q.text("%#x" % self.table_id)
5348 q.text(","); q.breakable()
5349 q.text("out_port = ");
5350 q.text(util.pretty_port(self.out_port))
5351 q.text(","); q.breakable()
5352 q.text("out_group = ");
5353 q.text("%#x" % self.out_group)
5354 q.text(","); q.breakable()
5355 q.text("cookie = ");
5356 q.text("%#x" % self.cookie)
5357 q.text(","); q.breakable()
5358 q.text("cookie_mask = ");
5359 q.text("%#x" % self.cookie_mask)
5360 q.text(","); q.breakable()
5361 q.text("match = ");
5362 q.pp(self.match)
5363 q.breakable()
5364 q.text('}')
5365
Rich Lane7dcdf022013-12-11 14:45:27 -08005366stats_request.subtypes[1] = flow_stats_request
5367
5368class get_config_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -07005369 version = 3
5370 type = 8
Rich Lanec2ee4b82013-04-24 17:12:38 -07005371
5372 def __init__(self, xid=None, flags=None, miss_send_len=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005373 if xid != None:
5374 self.xid = xid
5375 else:
5376 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005377 if flags != None:
5378 self.flags = flags
5379 else:
5380 self.flags = 0
5381 if miss_send_len != None:
5382 self.miss_send_len = miss_send_len
5383 else:
5384 self.miss_send_len = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08005385 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005386
5387 def pack(self):
5388 packed = []
5389 packed.append(struct.pack("!B", self.version))
5390 packed.append(struct.pack("!B", self.type))
5391 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5392 packed.append(struct.pack("!L", self.xid))
5393 packed.append(struct.pack("!H", self.flags))
5394 packed.append(struct.pack("!H", self.miss_send_len))
5395 length = sum([len(x) for x in packed])
5396 packed[2] = struct.pack("!H", length)
5397 return ''.join(packed)
5398
5399 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005400 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005401 obj = get_config_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07005402 _version = reader.read("!B")[0]
5403 assert(_version == 3)
5404 _type = reader.read("!B")[0]
5405 assert(_type == 8)
5406 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005407 orig_reader = reader
5408 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005409 obj.xid = reader.read("!L")[0]
5410 obj.flags = reader.read("!H")[0]
5411 obj.miss_send_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005412 return obj
5413
5414 def __eq__(self, other):
5415 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005416 if self.xid != other.xid: return False
5417 if self.flags != other.flags: return False
5418 if self.miss_send_len != other.miss_send_len: return False
5419 return True
5420
Rich Lanec2ee4b82013-04-24 17:12:38 -07005421 def pretty_print(self, q):
5422 q.text("get_config_reply {")
5423 with q.group():
5424 with q.indent(2):
5425 q.breakable()
5426 q.text("xid = ");
5427 if self.xid != None:
5428 q.text("%#x" % self.xid)
5429 else:
5430 q.text('None')
5431 q.text(","); q.breakable()
5432 q.text("flags = ");
5433 q.text("%#x" % self.flags)
5434 q.text(","); q.breakable()
5435 q.text("miss_send_len = ");
5436 q.text("%#x" % self.miss_send_len)
5437 q.breakable()
5438 q.text('}')
5439
Rich Lane7dcdf022013-12-11 14:45:27 -08005440message.subtypes[8] = get_config_reply
5441
5442class get_config_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -07005443 version = 3
5444 type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07005445
5446 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005447 if xid != None:
5448 self.xid = xid
5449 else:
5450 self.xid = None
5451 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005452
5453 def pack(self):
5454 packed = []
5455 packed.append(struct.pack("!B", self.version))
5456 packed.append(struct.pack("!B", self.type))
5457 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5458 packed.append(struct.pack("!L", self.xid))
5459 length = sum([len(x) for x in packed])
5460 packed[2] = struct.pack("!H", length)
5461 return ''.join(packed)
5462
5463 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005464 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005465 obj = get_config_request()
Dan Talaycof6202252013-07-02 01:00:29 -07005466 _version = reader.read("!B")[0]
5467 assert(_version == 3)
5468 _type = reader.read("!B")[0]
5469 assert(_type == 7)
5470 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005471 orig_reader = reader
5472 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005473 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005474 return obj
5475
5476 def __eq__(self, other):
5477 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005478 if self.xid != other.xid: return False
5479 return True
5480
Rich Lanec2ee4b82013-04-24 17:12:38 -07005481 def pretty_print(self, q):
5482 q.text("get_config_request {")
5483 with q.group():
5484 with q.indent(2):
5485 q.breakable()
5486 q.text("xid = ");
5487 if self.xid != None:
5488 q.text("%#x" % self.xid)
5489 else:
5490 q.text('None')
5491 q.breakable()
5492 q.text('}')
5493
Rich Lane7dcdf022013-12-11 14:45:27 -08005494message.subtypes[7] = get_config_request
5495
5496class group_mod(message):
5497 subtypes = {}
5498
Rich Lane95f7fc92014-01-27 17:08:16 -08005499 version = 3
5500 type = 15
5501
5502 def __init__(self, xid=None, command=None, group_type=None, group_id=None, buckets=None):
5503 if xid != None:
5504 self.xid = xid
5505 else:
5506 self.xid = None
5507 if command != None:
5508 self.command = command
5509 else:
5510 self.command = 0
5511 if group_type != None:
5512 self.group_type = group_type
5513 else:
5514 self.group_type = 0
5515 if group_id != None:
5516 self.group_id = group_id
5517 else:
5518 self.group_id = 0
5519 if buckets != None:
5520 self.buckets = buckets
5521 else:
5522 self.buckets = []
5523 return
5524
5525 def pack(self):
5526 packed = []
5527 packed.append(struct.pack("!B", self.version))
5528 packed.append(struct.pack("!B", self.type))
5529 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5530 packed.append(struct.pack("!L", self.xid))
5531 packed.append(struct.pack("!H", self.command))
5532 packed.append(struct.pack("!B", self.group_type))
5533 packed.append('\x00' * 1)
5534 packed.append(struct.pack("!L", self.group_id))
5535 packed.append(loxi.generic_util.pack_list(self.buckets))
5536 length = sum([len(x) for x in packed])
5537 packed[2] = struct.pack("!H", length)
5538 return ''.join(packed)
5539
Rich Lane7dcdf022013-12-11 14:45:27 -08005540 @staticmethod
5541 def unpack(reader):
5542 subtype, = reader.peek('!H', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -08005543 subclass = group_mod.subtypes.get(subtype)
5544 if subclass:
5545 return subclass.unpack(reader)
5546
5547 obj = group_mod()
5548 _version = reader.read("!B")[0]
5549 assert(_version == 3)
5550 _type = reader.read("!B")[0]
5551 assert(_type == 15)
5552 _length = reader.read("!H")[0]
5553 orig_reader = reader
5554 reader = orig_reader.slice(_length - (2 + 2))
5555 obj.xid = reader.read("!L")[0]
5556 obj.command = reader.read("!H")[0]
5557 obj.group_type = reader.read("!B")[0]
5558 reader.skip(1)
5559 obj.group_id = reader.read("!L")[0]
5560 obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack)
5561 return obj
5562
5563 def __eq__(self, other):
5564 if type(self) != type(other): return False
5565 if self.xid != other.xid: return False
5566 if self.command != other.command: return False
5567 if self.group_type != other.group_type: return False
5568 if self.group_id != other.group_id: return False
5569 if self.buckets != other.buckets: return False
5570 return True
5571
5572 def pretty_print(self, q):
5573 q.text("group_mod {")
5574 with q.group():
5575 with q.indent(2):
5576 q.breakable()
5577 q.text("xid = ");
5578 if self.xid != None:
5579 q.text("%#x" % self.xid)
5580 else:
5581 q.text('None')
5582 q.text(","); q.breakable()
5583 q.text("group_type = ");
5584 q.text("%#x" % self.group_type)
5585 q.text(","); q.breakable()
5586 q.text("group_id = ");
5587 q.text("%#x" % self.group_id)
5588 q.text(","); q.breakable()
5589 q.text("buckets = ");
5590 q.pp(self.buckets)
5591 q.breakable()
5592 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08005593
5594message.subtypes[15] = group_mod
5595
5596class group_add(group_mod):
Rich Lane7b0f2012013-11-22 14:15:26 -08005597 version = 3
5598 type = 15
5599 command = 0
5600
5601 def __init__(self, xid=None, group_type=None, group_id=None, buckets=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005602 if xid != None:
5603 self.xid = xid
5604 else:
5605 self.xid = None
Rich Lane7b0f2012013-11-22 14:15:26 -08005606 if group_type != None:
5607 self.group_type = group_type
5608 else:
5609 self.group_type = 0
5610 if group_id != None:
5611 self.group_id = group_id
5612 else:
5613 self.group_id = 0
5614 if buckets != None:
5615 self.buckets = buckets
5616 else:
5617 self.buckets = []
Rich Lane7dcdf022013-12-11 14:45:27 -08005618 return
Rich Lane7b0f2012013-11-22 14:15:26 -08005619
5620 def pack(self):
5621 packed = []
5622 packed.append(struct.pack("!B", self.version))
5623 packed.append(struct.pack("!B", self.type))
5624 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5625 packed.append(struct.pack("!L", self.xid))
5626 packed.append(struct.pack("!H", self.command))
5627 packed.append(struct.pack("!B", self.group_type))
5628 packed.append('\x00' * 1)
5629 packed.append(struct.pack("!L", self.group_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08005630 packed.append(loxi.generic_util.pack_list(self.buckets))
Rich Lane7b0f2012013-11-22 14:15:26 -08005631 length = sum([len(x) for x in packed])
5632 packed[2] = struct.pack("!H", length)
5633 return ''.join(packed)
5634
5635 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005636 def unpack(reader):
Rich Lane7b0f2012013-11-22 14:15:26 -08005637 obj = group_add()
Rich Lane7b0f2012013-11-22 14:15:26 -08005638 _version = reader.read("!B")[0]
5639 assert(_version == 3)
5640 _type = reader.read("!B")[0]
5641 assert(_type == 15)
5642 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005643 orig_reader = reader
5644 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane7b0f2012013-11-22 14:15:26 -08005645 obj.xid = reader.read("!L")[0]
5646 _command = reader.read("!H")[0]
5647 assert(_command == 0)
5648 obj.group_type = reader.read("!B")[0]
5649 reader.skip(1)
5650 obj.group_id = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005651 obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack)
Rich Lane7b0f2012013-11-22 14:15:26 -08005652 return obj
5653
5654 def __eq__(self, other):
5655 if type(self) != type(other): return False
Rich Lane7b0f2012013-11-22 14:15:26 -08005656 if self.xid != other.xid: return False
5657 if self.group_type != other.group_type: return False
5658 if self.group_id != other.group_id: return False
5659 if self.buckets != other.buckets: return False
5660 return True
5661
Rich Lane7b0f2012013-11-22 14:15:26 -08005662 def pretty_print(self, q):
5663 q.text("group_add {")
5664 with q.group():
5665 with q.indent(2):
5666 q.breakable()
5667 q.text("xid = ");
5668 if self.xid != None:
5669 q.text("%#x" % self.xid)
5670 else:
5671 q.text('None')
5672 q.text(","); q.breakable()
5673 q.text("group_type = ");
5674 q.text("%#x" % self.group_type)
5675 q.text(","); q.breakable()
5676 q.text("group_id = ");
5677 q.text("%#x" % self.group_id)
5678 q.text(","); q.breakable()
5679 q.text("buckets = ");
5680 q.pp(self.buckets)
5681 q.breakable()
5682 q.text('}')
5683
Rich Lane7dcdf022013-12-11 14:45:27 -08005684group_mod.subtypes[0] = group_add
5685
5686class group_delete(group_mod):
Rich Lane7b0f2012013-11-22 14:15:26 -08005687 version = 3
5688 type = 15
5689 command = 2
5690
5691 def __init__(self, xid=None, group_type=None, group_id=None, buckets=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005692 if xid != None:
5693 self.xid = xid
5694 else:
5695 self.xid = None
Rich Lane7b0f2012013-11-22 14:15:26 -08005696 if group_type != None:
5697 self.group_type = group_type
5698 else:
5699 self.group_type = 0
5700 if group_id != None:
5701 self.group_id = group_id
5702 else:
5703 self.group_id = 0
5704 if buckets != None:
5705 self.buckets = buckets
5706 else:
5707 self.buckets = []
Rich Lane7dcdf022013-12-11 14:45:27 -08005708 return
Rich Lane7b0f2012013-11-22 14:15:26 -08005709
5710 def pack(self):
5711 packed = []
5712 packed.append(struct.pack("!B", self.version))
5713 packed.append(struct.pack("!B", self.type))
5714 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5715 packed.append(struct.pack("!L", self.xid))
5716 packed.append(struct.pack("!H", self.command))
5717 packed.append(struct.pack("!B", self.group_type))
5718 packed.append('\x00' * 1)
5719 packed.append(struct.pack("!L", self.group_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08005720 packed.append(loxi.generic_util.pack_list(self.buckets))
Rich Lane7b0f2012013-11-22 14:15:26 -08005721 length = sum([len(x) for x in packed])
5722 packed[2] = struct.pack("!H", length)
5723 return ''.join(packed)
5724
5725 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005726 def unpack(reader):
Rich Lane7b0f2012013-11-22 14:15:26 -08005727 obj = group_delete()
Rich Lane7b0f2012013-11-22 14:15:26 -08005728 _version = reader.read("!B")[0]
5729 assert(_version == 3)
5730 _type = reader.read("!B")[0]
5731 assert(_type == 15)
5732 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005733 orig_reader = reader
5734 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane7b0f2012013-11-22 14:15:26 -08005735 obj.xid = reader.read("!L")[0]
5736 _command = reader.read("!H")[0]
5737 assert(_command == 2)
5738 obj.group_type = reader.read("!B")[0]
5739 reader.skip(1)
5740 obj.group_id = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005741 obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack)
Rich Lane7b0f2012013-11-22 14:15:26 -08005742 return obj
5743
5744 def __eq__(self, other):
5745 if type(self) != type(other): return False
Rich Lane7b0f2012013-11-22 14:15:26 -08005746 if self.xid != other.xid: return False
5747 if self.group_type != other.group_type: return False
5748 if self.group_id != other.group_id: return False
5749 if self.buckets != other.buckets: return False
5750 return True
5751
Rich Lane7b0f2012013-11-22 14:15:26 -08005752 def pretty_print(self, q):
5753 q.text("group_delete {")
5754 with q.group():
5755 with q.indent(2):
5756 q.breakable()
5757 q.text("xid = ");
5758 if self.xid != None:
5759 q.text("%#x" % self.xid)
5760 else:
5761 q.text('None')
5762 q.text(","); q.breakable()
5763 q.text("group_type = ");
5764 q.text("%#x" % self.group_type)
5765 q.text(","); q.breakable()
5766 q.text("group_id = ");
5767 q.text("%#x" % self.group_id)
5768 q.text(","); q.breakable()
5769 q.text("buckets = ");
5770 q.pp(self.buckets)
5771 q.breakable()
5772 q.text('}')
5773
Rich Lane7dcdf022013-12-11 14:45:27 -08005774group_mod.subtypes[2] = group_delete
5775
5776class group_desc_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07005777 version = 3
5778 type = 19
5779 stats_type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07005780
5781 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005782 if xid != None:
5783 self.xid = xid
5784 else:
5785 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005786 if flags != None:
5787 self.flags = flags
5788 else:
5789 self.flags = 0
5790 if entries != None:
5791 self.entries = entries
5792 else:
5793 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08005794 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005795
5796 def pack(self):
5797 packed = []
5798 packed.append(struct.pack("!B", self.version))
5799 packed.append(struct.pack("!B", self.type))
5800 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5801 packed.append(struct.pack("!L", self.xid))
5802 packed.append(struct.pack("!H", self.stats_type))
5803 packed.append(struct.pack("!H", self.flags))
5804 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08005805 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005806 length = sum([len(x) for x in packed])
5807 packed[2] = struct.pack("!H", length)
5808 return ''.join(packed)
5809
5810 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005811 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005812 obj = group_desc_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07005813 _version = reader.read("!B")[0]
5814 assert(_version == 3)
5815 _type = reader.read("!B")[0]
5816 assert(_type == 19)
5817 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005818 orig_reader = reader
5819 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005820 obj.xid = reader.read("!L")[0]
5821 _stats_type = reader.read("!H")[0]
5822 assert(_stats_type == 7)
5823 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005824 reader.skip(4)
Rich Lane7dcdf022013-12-11 14:45:27 -08005825 obj.entries = loxi.generic_util.unpack_list(reader, common.group_desc_stats_entry.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07005826 return obj
5827
5828 def __eq__(self, other):
5829 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005830 if self.xid != other.xid: return False
5831 if self.flags != other.flags: return False
5832 if self.entries != other.entries: return False
5833 return True
5834
Rich Lanec2ee4b82013-04-24 17:12:38 -07005835 def pretty_print(self, q):
5836 q.text("group_desc_stats_reply {")
5837 with q.group():
5838 with q.indent(2):
5839 q.breakable()
5840 q.text("xid = ");
5841 if self.xid != None:
5842 q.text("%#x" % self.xid)
5843 else:
5844 q.text('None')
5845 q.text(","); q.breakable()
5846 q.text("flags = ");
5847 q.text("%#x" % self.flags)
5848 q.text(","); q.breakable()
5849 q.text("entries = ");
5850 q.pp(self.entries)
5851 q.breakable()
5852 q.text('}')
5853
Rich Lane7dcdf022013-12-11 14:45:27 -08005854stats_reply.subtypes[7] = group_desc_stats_reply
5855
5856class group_desc_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07005857 version = 3
5858 type = 18
5859 stats_type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07005860
5861 def __init__(self, xid=None, flags=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005862 if xid != None:
5863 self.xid = xid
5864 else:
5865 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005866 if flags != None:
5867 self.flags = flags
5868 else:
5869 self.flags = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08005870 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005871
5872 def pack(self):
5873 packed = []
5874 packed.append(struct.pack("!B", self.version))
5875 packed.append(struct.pack("!B", self.type))
5876 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5877 packed.append(struct.pack("!L", self.xid))
5878 packed.append(struct.pack("!H", self.stats_type))
5879 packed.append(struct.pack("!H", self.flags))
5880 packed.append('\x00' * 4)
5881 length = sum([len(x) for x in packed])
5882 packed[2] = struct.pack("!H", length)
5883 return ''.join(packed)
5884
5885 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005886 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005887 obj = group_desc_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07005888 _version = reader.read("!B")[0]
5889 assert(_version == 3)
5890 _type = reader.read("!B")[0]
5891 assert(_type == 18)
5892 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005893 orig_reader = reader
5894 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005895 obj.xid = reader.read("!L")[0]
5896 _stats_type = reader.read("!H")[0]
5897 assert(_stats_type == 7)
5898 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005899 reader.skip(4)
5900 return obj
5901
5902 def __eq__(self, other):
5903 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005904 if self.xid != other.xid: return False
5905 if self.flags != other.flags: return False
5906 return True
5907
Rich Lanec2ee4b82013-04-24 17:12:38 -07005908 def pretty_print(self, q):
5909 q.text("group_desc_stats_request {")
5910 with q.group():
5911 with q.indent(2):
5912 q.breakable()
5913 q.text("xid = ");
5914 if self.xid != None:
5915 q.text("%#x" % self.xid)
5916 else:
5917 q.text('None')
5918 q.text(","); q.breakable()
5919 q.text("flags = ");
5920 q.text("%#x" % self.flags)
5921 q.breakable()
5922 q.text('}')
5923
Rich Lane7dcdf022013-12-11 14:45:27 -08005924stats_request.subtypes[7] = group_desc_stats_request
5925
5926class group_features_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07005927 version = 3
5928 type = 19
5929 stats_type = 8
Rich Lanec2ee4b82013-04-24 17:12:38 -07005930
5931 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 -08005932 if xid != None:
5933 self.xid = xid
5934 else:
5935 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005936 if flags != None:
5937 self.flags = flags
5938 else:
5939 self.flags = 0
5940 if types != None:
5941 self.types = types
5942 else:
5943 self.types = 0
5944 if capabilities != None:
5945 self.capabilities = capabilities
5946 else:
5947 self.capabilities = 0
5948 if max_groups_all != None:
5949 self.max_groups_all = max_groups_all
5950 else:
5951 self.max_groups_all = 0
5952 if max_groups_select != None:
5953 self.max_groups_select = max_groups_select
5954 else:
5955 self.max_groups_select = 0
5956 if max_groups_indirect != None:
5957 self.max_groups_indirect = max_groups_indirect
5958 else:
5959 self.max_groups_indirect = 0
5960 if max_groups_ff != None:
5961 self.max_groups_ff = max_groups_ff
5962 else:
5963 self.max_groups_ff = 0
5964 if actions_all != None:
5965 self.actions_all = actions_all
5966 else:
5967 self.actions_all = 0
5968 if actions_select != None:
5969 self.actions_select = actions_select
5970 else:
5971 self.actions_select = 0
5972 if actions_indirect != None:
5973 self.actions_indirect = actions_indirect
5974 else:
5975 self.actions_indirect = 0
5976 if actions_ff != None:
5977 self.actions_ff = actions_ff
5978 else:
5979 self.actions_ff = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08005980 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005981
5982 def pack(self):
5983 packed = []
5984 packed.append(struct.pack("!B", self.version))
5985 packed.append(struct.pack("!B", self.type))
5986 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5987 packed.append(struct.pack("!L", self.xid))
5988 packed.append(struct.pack("!H", self.stats_type))
5989 packed.append(struct.pack("!H", self.flags))
5990 packed.append('\x00' * 4)
5991 packed.append(struct.pack("!L", self.types))
5992 packed.append(struct.pack("!L", self.capabilities))
5993 packed.append(struct.pack("!L", self.max_groups_all))
5994 packed.append(struct.pack("!L", self.max_groups_select))
5995 packed.append(struct.pack("!L", self.max_groups_indirect))
5996 packed.append(struct.pack("!L", self.max_groups_ff))
5997 packed.append(struct.pack("!L", self.actions_all))
5998 packed.append(struct.pack("!L", self.actions_select))
5999 packed.append(struct.pack("!L", self.actions_indirect))
6000 packed.append(struct.pack("!L", self.actions_ff))
6001 length = sum([len(x) for x in packed])
6002 packed[2] = struct.pack("!H", length)
6003 return ''.join(packed)
6004
6005 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006006 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006007 obj = group_features_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07006008 _version = reader.read("!B")[0]
6009 assert(_version == 3)
6010 _type = reader.read("!B")[0]
6011 assert(_type == 19)
6012 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006013 orig_reader = reader
6014 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006015 obj.xid = reader.read("!L")[0]
6016 _stats_type = reader.read("!H")[0]
6017 assert(_stats_type == 8)
6018 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006019 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07006020 obj.types = reader.read("!L")[0]
6021 obj.capabilities = reader.read("!L")[0]
6022 obj.max_groups_all = reader.read("!L")[0]
6023 obj.max_groups_select = reader.read("!L")[0]
6024 obj.max_groups_indirect = reader.read("!L")[0]
6025 obj.max_groups_ff = reader.read("!L")[0]
6026 obj.actions_all = reader.read("!L")[0]
6027 obj.actions_select = reader.read("!L")[0]
6028 obj.actions_indirect = reader.read("!L")[0]
6029 obj.actions_ff = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006030 return obj
6031
6032 def __eq__(self, other):
6033 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006034 if self.xid != other.xid: return False
6035 if self.flags != other.flags: return False
6036 if self.types != other.types: return False
6037 if self.capabilities != other.capabilities: return False
6038 if self.max_groups_all != other.max_groups_all: return False
6039 if self.max_groups_select != other.max_groups_select: return False
6040 if self.max_groups_indirect != other.max_groups_indirect: return False
6041 if self.max_groups_ff != other.max_groups_ff: return False
6042 if self.actions_all != other.actions_all: return False
6043 if self.actions_select != other.actions_select: return False
6044 if self.actions_indirect != other.actions_indirect: return False
6045 if self.actions_ff != other.actions_ff: return False
6046 return True
6047
Rich Lanec2ee4b82013-04-24 17:12:38 -07006048 def pretty_print(self, q):
6049 q.text("group_features_stats_reply {")
6050 with q.group():
6051 with q.indent(2):
6052 q.breakable()
6053 q.text("xid = ");
6054 if self.xid != None:
6055 q.text("%#x" % self.xid)
6056 else:
6057 q.text('None')
6058 q.text(","); q.breakable()
6059 q.text("flags = ");
6060 q.text("%#x" % self.flags)
6061 q.text(","); q.breakable()
6062 q.text("types = ");
6063 q.text("%#x" % self.types)
6064 q.text(","); q.breakable()
6065 q.text("capabilities = ");
6066 q.text("%#x" % self.capabilities)
6067 q.text(","); q.breakable()
6068 q.text("max_groups_all = ");
6069 q.text("%#x" % self.max_groups_all)
6070 q.text(","); q.breakable()
6071 q.text("max_groups_select = ");
6072 q.text("%#x" % self.max_groups_select)
6073 q.text(","); q.breakable()
6074 q.text("max_groups_indirect = ");
6075 q.text("%#x" % self.max_groups_indirect)
6076 q.text(","); q.breakable()
6077 q.text("max_groups_ff = ");
6078 q.text("%#x" % self.max_groups_ff)
6079 q.text(","); q.breakable()
6080 q.text("actions_all = ");
6081 q.text("%#x" % self.actions_all)
6082 q.text(","); q.breakable()
6083 q.text("actions_select = ");
6084 q.text("%#x" % self.actions_select)
6085 q.text(","); q.breakable()
6086 q.text("actions_indirect = ");
6087 q.text("%#x" % self.actions_indirect)
6088 q.text(","); q.breakable()
6089 q.text("actions_ff = ");
6090 q.text("%#x" % self.actions_ff)
6091 q.breakable()
6092 q.text('}')
6093
Rich Lane7dcdf022013-12-11 14:45:27 -08006094stats_reply.subtypes[8] = group_features_stats_reply
6095
6096class group_features_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07006097 version = 3
6098 type = 18
6099 stats_type = 8
Rich Lanec2ee4b82013-04-24 17:12:38 -07006100
6101 def __init__(self, xid=None, flags=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006102 if xid != None:
6103 self.xid = xid
6104 else:
6105 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006106 if flags != None:
6107 self.flags = flags
6108 else:
6109 self.flags = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08006110 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006111
6112 def pack(self):
6113 packed = []
6114 packed.append(struct.pack("!B", self.version))
6115 packed.append(struct.pack("!B", self.type))
6116 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6117 packed.append(struct.pack("!L", self.xid))
6118 packed.append(struct.pack("!H", self.stats_type))
6119 packed.append(struct.pack("!H", self.flags))
6120 packed.append('\x00' * 4)
6121 length = sum([len(x) for x in packed])
6122 packed[2] = struct.pack("!H", length)
6123 return ''.join(packed)
6124
6125 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006126 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006127 obj = group_features_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07006128 _version = reader.read("!B")[0]
6129 assert(_version == 3)
6130 _type = reader.read("!B")[0]
6131 assert(_type == 18)
6132 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006133 orig_reader = reader
6134 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006135 obj.xid = reader.read("!L")[0]
6136 _stats_type = reader.read("!H")[0]
6137 assert(_stats_type == 8)
6138 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006139 reader.skip(4)
6140 return obj
6141
6142 def __eq__(self, other):
6143 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006144 if self.xid != other.xid: return False
6145 if self.flags != other.flags: return False
6146 return True
6147
Rich Lanec2ee4b82013-04-24 17:12:38 -07006148 def pretty_print(self, q):
6149 q.text("group_features_stats_request {")
6150 with q.group():
6151 with q.indent(2):
6152 q.breakable()
6153 q.text("xid = ");
6154 if self.xid != None:
6155 q.text("%#x" % self.xid)
6156 else:
6157 q.text('None')
6158 q.text(","); q.breakable()
6159 q.text("flags = ");
6160 q.text("%#x" % self.flags)
6161 q.breakable()
6162 q.text('}')
6163
Rich Lane7dcdf022013-12-11 14:45:27 -08006164stats_request.subtypes[8] = group_features_stats_request
6165
6166class group_mod_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07006167 version = 3
6168 type = 1
6169 err_type = 6
6170
6171 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006172 if xid != None:
6173 self.xid = xid
6174 else:
6175 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07006176 if code != None:
6177 self.code = code
6178 else:
6179 self.code = 0
6180 if data != None:
6181 self.data = data
6182 else:
6183 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08006184 return
Rich Lane6f4978c2013-10-20 21:33:52 -07006185
6186 def pack(self):
6187 packed = []
6188 packed.append(struct.pack("!B", self.version))
6189 packed.append(struct.pack("!B", self.type))
6190 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6191 packed.append(struct.pack("!L", self.xid))
6192 packed.append(struct.pack("!H", self.err_type))
6193 packed.append(struct.pack("!H", self.code))
6194 packed.append(self.data)
6195 length = sum([len(x) for x in packed])
6196 packed[2] = struct.pack("!H", length)
6197 return ''.join(packed)
6198
6199 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006200 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07006201 obj = group_mod_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07006202 _version = reader.read("!B")[0]
6203 assert(_version == 3)
6204 _type = reader.read("!B")[0]
6205 assert(_type == 1)
6206 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006207 orig_reader = reader
6208 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07006209 obj.xid = reader.read("!L")[0]
6210 _err_type = reader.read("!H")[0]
6211 assert(_err_type == 6)
6212 obj.code = reader.read("!H")[0]
6213 obj.data = str(reader.read_all())
6214 return obj
6215
6216 def __eq__(self, other):
6217 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07006218 if self.xid != other.xid: return False
6219 if self.code != other.code: return False
6220 if self.data != other.data: return False
6221 return True
6222
Rich Lane6f4978c2013-10-20 21:33:52 -07006223 def pretty_print(self, q):
6224 q.text("group_mod_failed_error_msg {")
6225 with q.group():
6226 with q.indent(2):
6227 q.breakable()
6228 q.text("xid = ");
6229 if self.xid != None:
6230 q.text("%#x" % self.xid)
6231 else:
6232 q.text('None')
6233 q.text(","); q.breakable()
6234 q.text("code = ");
6235 q.text("%#x" % self.code)
6236 q.text(","); q.breakable()
6237 q.text("data = ");
6238 q.pp(self.data)
6239 q.breakable()
6240 q.text('}')
6241
Rich Lane7dcdf022013-12-11 14:45:27 -08006242error_msg.subtypes[6] = group_mod_failed_error_msg
6243
6244class group_modify(group_mod):
Rich Lane7b0f2012013-11-22 14:15:26 -08006245 version = 3
6246 type = 15
6247 command = 1
6248
6249 def __init__(self, xid=None, group_type=None, group_id=None, buckets=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006250 if xid != None:
6251 self.xid = xid
6252 else:
6253 self.xid = None
Rich Lane7b0f2012013-11-22 14:15:26 -08006254 if group_type != None:
6255 self.group_type = group_type
6256 else:
6257 self.group_type = 0
6258 if group_id != None:
6259 self.group_id = group_id
6260 else:
6261 self.group_id = 0
6262 if buckets != None:
6263 self.buckets = buckets
6264 else:
6265 self.buckets = []
Rich Lane7dcdf022013-12-11 14:45:27 -08006266 return
Rich Lane7b0f2012013-11-22 14:15:26 -08006267
6268 def pack(self):
6269 packed = []
6270 packed.append(struct.pack("!B", self.version))
6271 packed.append(struct.pack("!B", self.type))
6272 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6273 packed.append(struct.pack("!L", self.xid))
6274 packed.append(struct.pack("!H", self.command))
6275 packed.append(struct.pack("!B", self.group_type))
6276 packed.append('\x00' * 1)
6277 packed.append(struct.pack("!L", self.group_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08006278 packed.append(loxi.generic_util.pack_list(self.buckets))
Rich Lane7b0f2012013-11-22 14:15:26 -08006279 length = sum([len(x) for x in packed])
6280 packed[2] = struct.pack("!H", length)
6281 return ''.join(packed)
6282
6283 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006284 def unpack(reader):
Rich Lane7b0f2012013-11-22 14:15:26 -08006285 obj = group_modify()
Rich Lane7b0f2012013-11-22 14:15:26 -08006286 _version = reader.read("!B")[0]
6287 assert(_version == 3)
6288 _type = reader.read("!B")[0]
6289 assert(_type == 15)
6290 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006291 orig_reader = reader
6292 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane7b0f2012013-11-22 14:15:26 -08006293 obj.xid = reader.read("!L")[0]
6294 _command = reader.read("!H")[0]
6295 assert(_command == 1)
6296 obj.group_type = reader.read("!B")[0]
6297 reader.skip(1)
6298 obj.group_id = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006299 obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack)
Rich Lane7b0f2012013-11-22 14:15:26 -08006300 return obj
6301
6302 def __eq__(self, other):
6303 if type(self) != type(other): return False
Rich Lane7b0f2012013-11-22 14:15:26 -08006304 if self.xid != other.xid: return False
6305 if self.group_type != other.group_type: return False
6306 if self.group_id != other.group_id: return False
6307 if self.buckets != other.buckets: return False
6308 return True
6309
Rich Lane7b0f2012013-11-22 14:15:26 -08006310 def pretty_print(self, q):
6311 q.text("group_modify {")
6312 with q.group():
6313 with q.indent(2):
6314 q.breakable()
6315 q.text("xid = ");
6316 if self.xid != None:
6317 q.text("%#x" % self.xid)
6318 else:
6319 q.text('None')
6320 q.text(","); q.breakable()
6321 q.text("group_type = ");
6322 q.text("%#x" % self.group_type)
6323 q.text(","); q.breakable()
6324 q.text("group_id = ");
6325 q.text("%#x" % self.group_id)
6326 q.text(","); q.breakable()
6327 q.text("buckets = ");
6328 q.pp(self.buckets)
6329 q.breakable()
6330 q.text('}')
6331
Rich Lane7dcdf022013-12-11 14:45:27 -08006332group_mod.subtypes[1] = group_modify
6333
6334class group_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07006335 version = 3
6336 type = 19
6337 stats_type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07006338
6339 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006340 if xid != None:
6341 self.xid = xid
6342 else:
6343 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006344 if flags != None:
6345 self.flags = flags
6346 else:
6347 self.flags = 0
6348 if entries != None:
6349 self.entries = entries
6350 else:
6351 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08006352 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006353
6354 def pack(self):
6355 packed = []
6356 packed.append(struct.pack("!B", self.version))
6357 packed.append(struct.pack("!B", self.type))
6358 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6359 packed.append(struct.pack("!L", self.xid))
6360 packed.append(struct.pack("!H", self.stats_type))
6361 packed.append(struct.pack("!H", self.flags))
6362 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08006363 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006364 length = sum([len(x) for x in packed])
6365 packed[2] = struct.pack("!H", length)
6366 return ''.join(packed)
6367
6368 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006369 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006370 obj = group_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07006371 _version = reader.read("!B")[0]
6372 assert(_version == 3)
6373 _type = reader.read("!B")[0]
6374 assert(_type == 19)
6375 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006376 orig_reader = reader
6377 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006378 obj.xid = reader.read("!L")[0]
6379 _stats_type = reader.read("!H")[0]
6380 assert(_stats_type == 6)
6381 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006382 reader.skip(4)
Rich Lane7dcdf022013-12-11 14:45:27 -08006383 obj.entries = loxi.generic_util.unpack_list(reader, common.group_stats_entry.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006384 return obj
6385
6386 def __eq__(self, other):
6387 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006388 if self.xid != other.xid: return False
6389 if self.flags != other.flags: return False
6390 if self.entries != other.entries: return False
6391 return True
6392
Rich Lanec2ee4b82013-04-24 17:12:38 -07006393 def pretty_print(self, q):
6394 q.text("group_stats_reply {")
6395 with q.group():
6396 with q.indent(2):
6397 q.breakable()
6398 q.text("xid = ");
6399 if self.xid != None:
6400 q.text("%#x" % self.xid)
6401 else:
6402 q.text('None')
6403 q.text(","); q.breakable()
6404 q.text("flags = ");
6405 q.text("%#x" % self.flags)
6406 q.text(","); q.breakable()
6407 q.text("entries = ");
6408 q.pp(self.entries)
6409 q.breakable()
6410 q.text('}')
6411
Rich Lane7dcdf022013-12-11 14:45:27 -08006412stats_reply.subtypes[6] = group_stats_reply
6413
6414class group_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07006415 version = 3
6416 type = 18
6417 stats_type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07006418
6419 def __init__(self, xid=None, flags=None, group_id=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006420 if xid != None:
6421 self.xid = xid
6422 else:
6423 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006424 if flags != None:
6425 self.flags = flags
6426 else:
6427 self.flags = 0
6428 if group_id != None:
6429 self.group_id = group_id
6430 else:
6431 self.group_id = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08006432 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006433
6434 def pack(self):
6435 packed = []
6436 packed.append(struct.pack("!B", self.version))
6437 packed.append(struct.pack("!B", self.type))
6438 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6439 packed.append(struct.pack("!L", self.xid))
6440 packed.append(struct.pack("!H", self.stats_type))
6441 packed.append(struct.pack("!H", self.flags))
6442 packed.append('\x00' * 4)
6443 packed.append(struct.pack("!L", self.group_id))
6444 packed.append('\x00' * 4)
6445 length = sum([len(x) for x in packed])
6446 packed[2] = struct.pack("!H", length)
6447 return ''.join(packed)
6448
6449 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006450 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006451 obj = group_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07006452 _version = reader.read("!B")[0]
6453 assert(_version == 3)
6454 _type = reader.read("!B")[0]
6455 assert(_type == 18)
6456 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006457 orig_reader = reader
6458 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006459 obj.xid = reader.read("!L")[0]
6460 _stats_type = reader.read("!H")[0]
6461 assert(_stats_type == 6)
6462 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006463 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07006464 obj.group_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006465 reader.skip(4)
6466 return obj
6467
6468 def __eq__(self, other):
6469 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006470 if self.xid != other.xid: return False
6471 if self.flags != other.flags: return False
6472 if self.group_id != other.group_id: return False
6473 return True
6474
Rich Lanec2ee4b82013-04-24 17:12:38 -07006475 def pretty_print(self, q):
6476 q.text("group_stats_request {")
6477 with q.group():
6478 with q.indent(2):
6479 q.breakable()
6480 q.text("xid = ");
6481 if self.xid != None:
6482 q.text("%#x" % self.xid)
6483 else:
6484 q.text('None')
6485 q.text(","); q.breakable()
6486 q.text("flags = ");
6487 q.text("%#x" % self.flags)
6488 q.text(","); q.breakable()
6489 q.text("group_id = ");
6490 q.text("%#x" % self.group_id)
6491 q.breakable()
6492 q.text('}')
6493
Rich Lane7dcdf022013-12-11 14:45:27 -08006494stats_request.subtypes[6] = group_stats_request
6495
6496class hello(message):
Dan Talaycof6202252013-07-02 01:00:29 -07006497 version = 3
6498 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07006499
6500 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006501 if xid != None:
6502 self.xid = xid
6503 else:
6504 self.xid = None
6505 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006506
6507 def pack(self):
6508 packed = []
6509 packed.append(struct.pack("!B", self.version))
6510 packed.append(struct.pack("!B", self.type))
6511 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6512 packed.append(struct.pack("!L", self.xid))
6513 length = sum([len(x) for x in packed])
6514 packed[2] = struct.pack("!H", length)
6515 return ''.join(packed)
6516
6517 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006518 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006519 obj = hello()
Dan Talaycof6202252013-07-02 01:00:29 -07006520 _version = reader.read("!B")[0]
6521 assert(_version == 3)
6522 _type = reader.read("!B")[0]
6523 assert(_type == 0)
6524 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006525 orig_reader = reader
6526 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006527 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006528 return obj
6529
6530 def __eq__(self, other):
6531 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006532 if self.xid != other.xid: return False
6533 return True
6534
Rich Lanec2ee4b82013-04-24 17:12:38 -07006535 def pretty_print(self, q):
6536 q.text("hello {")
6537 with q.group():
6538 with q.indent(2):
6539 q.breakable()
6540 q.text("xid = ");
6541 if self.xid != None:
6542 q.text("%#x" % self.xid)
6543 else:
6544 q.text('None')
6545 q.breakable()
6546 q.text('}')
6547
Rich Lane7dcdf022013-12-11 14:45:27 -08006548message.subtypes[0] = hello
6549
6550class hello_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07006551 version = 3
6552 type = 1
6553 err_type = 0
6554
6555 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006556 if xid != None:
6557 self.xid = xid
6558 else:
6559 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07006560 if code != None:
6561 self.code = code
6562 else:
6563 self.code = 0
6564 if data != None:
6565 self.data = data
6566 else:
6567 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08006568 return
Rich Lane6f4978c2013-10-20 21:33:52 -07006569
6570 def pack(self):
6571 packed = []
6572 packed.append(struct.pack("!B", self.version))
6573 packed.append(struct.pack("!B", self.type))
6574 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6575 packed.append(struct.pack("!L", self.xid))
6576 packed.append(struct.pack("!H", self.err_type))
6577 packed.append(struct.pack("!H", self.code))
6578 packed.append(self.data)
6579 length = sum([len(x) for x in packed])
6580 packed[2] = struct.pack("!H", length)
6581 return ''.join(packed)
6582
6583 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006584 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07006585 obj = hello_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07006586 _version = reader.read("!B")[0]
6587 assert(_version == 3)
6588 _type = reader.read("!B")[0]
6589 assert(_type == 1)
6590 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006591 orig_reader = reader
6592 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07006593 obj.xid = reader.read("!L")[0]
6594 _err_type = reader.read("!H")[0]
6595 assert(_err_type == 0)
6596 obj.code = reader.read("!H")[0]
6597 obj.data = str(reader.read_all())
6598 return obj
6599
6600 def __eq__(self, other):
6601 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07006602 if self.xid != other.xid: return False
6603 if self.code != other.code: return False
6604 if self.data != other.data: return False
6605 return True
6606
Rich Lane6f4978c2013-10-20 21:33:52 -07006607 def pretty_print(self, q):
6608 q.text("hello_failed_error_msg {")
6609 with q.group():
6610 with q.indent(2):
6611 q.breakable()
6612 q.text("xid = ");
6613 if self.xid != None:
6614 q.text("%#x" % self.xid)
6615 else:
6616 q.text('None')
6617 q.text(","); q.breakable()
6618 q.text("code = ");
6619 q.text("%#x" % self.code)
6620 q.text(","); q.breakable()
6621 q.text("data = ");
6622 q.pp(self.data)
6623 q.breakable()
6624 q.text('}')
6625
Rich Lane7dcdf022013-12-11 14:45:27 -08006626error_msg.subtypes[0] = hello_failed_error_msg
6627
6628class nicira_header(experimenter):
6629 subtypes = {}
6630
Rich Lane95f7fc92014-01-27 17:08:16 -08006631 version = 3
6632 type = 4
6633 experimenter = 8992
6634
6635 def __init__(self, xid=None, subtype=None):
6636 if xid != None:
6637 self.xid = xid
6638 else:
6639 self.xid = None
6640 if subtype != None:
6641 self.subtype = subtype
6642 else:
6643 self.subtype = 0
6644 return
6645
6646 def pack(self):
6647 packed = []
6648 packed.append(struct.pack("!B", self.version))
6649 packed.append(struct.pack("!B", self.type))
6650 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6651 packed.append(struct.pack("!L", self.xid))
6652 packed.append(struct.pack("!L", self.experimenter))
6653 packed.append(struct.pack("!L", self.subtype))
6654 length = sum([len(x) for x in packed])
6655 packed[2] = struct.pack("!H", length)
6656 return ''.join(packed)
6657
Rich Lane7dcdf022013-12-11 14:45:27 -08006658 @staticmethod
6659 def unpack(reader):
6660 subtype, = reader.peek('!L', 12)
Rich Lane95f7fc92014-01-27 17:08:16 -08006661 subclass = nicira_header.subtypes.get(subtype)
6662 if subclass:
6663 return subclass.unpack(reader)
6664
6665 obj = nicira_header()
6666 _version = reader.read("!B")[0]
6667 assert(_version == 3)
6668 _type = reader.read("!B")[0]
6669 assert(_type == 4)
6670 _length = reader.read("!H")[0]
6671 orig_reader = reader
6672 reader = orig_reader.slice(_length - (2 + 2))
6673 obj.xid = reader.read("!L")[0]
6674 _experimenter = reader.read("!L")[0]
6675 assert(_experimenter == 8992)
6676 obj.subtype = reader.read("!L")[0]
6677 return obj
6678
6679 def __eq__(self, other):
6680 if type(self) != type(other): return False
6681 if self.xid != other.xid: return False
6682 if self.subtype != other.subtype: return False
6683 return True
6684
6685 def pretty_print(self, q):
6686 q.text("nicira_header {")
6687 with q.group():
6688 with q.indent(2):
6689 q.breakable()
6690 q.text("xid = ");
6691 if self.xid != None:
6692 q.text("%#x" % self.xid)
6693 else:
6694 q.text('None')
6695 q.breakable()
6696 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08006697
6698experimenter.subtypes[8992] = nicira_header
6699
6700class packet_in(message):
Dan Talaycof6202252013-07-02 01:00:29 -07006701 version = 3
6702 type = 10
Rich Lanec2ee4b82013-04-24 17:12:38 -07006703
6704 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 -08006705 if xid != None:
6706 self.xid = xid
6707 else:
6708 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006709 if buffer_id != None:
6710 self.buffer_id = buffer_id
6711 else:
6712 self.buffer_id = 0
6713 if total_len != None:
6714 self.total_len = total_len
6715 else:
6716 self.total_len = 0
6717 if reason != None:
6718 self.reason = reason
6719 else:
6720 self.reason = 0
6721 if table_id != None:
6722 self.table_id = table_id
6723 else:
6724 self.table_id = 0
6725 if match != None:
6726 self.match = match
6727 else:
6728 self.match = common.match()
6729 if data != None:
6730 self.data = data
6731 else:
Dan Talaycof6202252013-07-02 01:00:29 -07006732 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08006733 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006734
6735 def pack(self):
6736 packed = []
6737 packed.append(struct.pack("!B", self.version))
6738 packed.append(struct.pack("!B", self.type))
6739 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6740 packed.append(struct.pack("!L", self.xid))
6741 packed.append(struct.pack("!L", self.buffer_id))
6742 packed.append(struct.pack("!H", self.total_len))
6743 packed.append(struct.pack("!B", self.reason))
6744 packed.append(struct.pack("!B", self.table_id))
6745 packed.append(self.match.pack())
6746 packed.append('\x00' * 2)
6747 packed.append(self.data)
6748 length = sum([len(x) for x in packed])
6749 packed[2] = struct.pack("!H", length)
6750 return ''.join(packed)
6751
6752 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006753 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006754 obj = packet_in()
Dan Talaycof6202252013-07-02 01:00:29 -07006755 _version = reader.read("!B")[0]
6756 assert(_version == 3)
6757 _type = reader.read("!B")[0]
6758 assert(_type == 10)
6759 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006760 orig_reader = reader
6761 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006762 obj.xid = reader.read("!L")[0]
6763 obj.buffer_id = reader.read("!L")[0]
6764 obj.total_len = reader.read("!H")[0]
6765 obj.reason = reader.read("!B")[0]
6766 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006767 obj.match = common.match.unpack(reader)
6768 reader.skip(2)
6769 obj.data = str(reader.read_all())
6770 return obj
6771
6772 def __eq__(self, other):
6773 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006774 if self.xid != other.xid: return False
6775 if self.buffer_id != other.buffer_id: return False
6776 if self.total_len != other.total_len: return False
6777 if self.reason != other.reason: return False
6778 if self.table_id != other.table_id: return False
6779 if self.match != other.match: return False
6780 if self.data != other.data: return False
6781 return True
6782
Rich Lanec2ee4b82013-04-24 17:12:38 -07006783 def pretty_print(self, q):
6784 q.text("packet_in {")
6785 with q.group():
6786 with q.indent(2):
6787 q.breakable()
6788 q.text("xid = ");
6789 if self.xid != None:
6790 q.text("%#x" % self.xid)
6791 else:
6792 q.text('None')
6793 q.text(","); q.breakable()
6794 q.text("buffer_id = ");
6795 q.text("%#x" % self.buffer_id)
6796 q.text(","); q.breakable()
6797 q.text("total_len = ");
6798 q.text("%#x" % self.total_len)
6799 q.text(","); q.breakable()
6800 q.text("reason = ");
6801 q.text("%#x" % self.reason)
6802 q.text(","); q.breakable()
6803 q.text("table_id = ");
6804 q.text("%#x" % self.table_id)
6805 q.text(","); q.breakable()
6806 q.text("match = ");
6807 q.pp(self.match)
6808 q.text(","); q.breakable()
6809 q.text("data = ");
6810 q.pp(self.data)
6811 q.breakable()
6812 q.text('}')
6813
Rich Lane7dcdf022013-12-11 14:45:27 -08006814message.subtypes[10] = packet_in
6815
6816class packet_out(message):
Dan Talaycof6202252013-07-02 01:00:29 -07006817 version = 3
6818 type = 13
Rich Lanec2ee4b82013-04-24 17:12:38 -07006819
6820 def __init__(self, xid=None, buffer_id=None, in_port=None, actions=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006821 if xid != None:
6822 self.xid = xid
6823 else:
6824 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006825 if buffer_id != None:
6826 self.buffer_id = buffer_id
6827 else:
6828 self.buffer_id = 0
6829 if in_port != None:
6830 self.in_port = in_port
6831 else:
6832 self.in_port = 0
6833 if actions != None:
6834 self.actions = actions
6835 else:
6836 self.actions = []
6837 if data != None:
6838 self.data = data
6839 else:
Dan Talaycof6202252013-07-02 01:00:29 -07006840 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08006841 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006842
6843 def pack(self):
6844 packed = []
6845 packed.append(struct.pack("!B", self.version))
6846 packed.append(struct.pack("!B", self.type))
6847 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6848 packed.append(struct.pack("!L", self.xid))
6849 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07006850 packed.append(util.pack_port_no(self.in_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006851 packed.append(struct.pack("!H", 0)) # placeholder for actions_len at index 6
6852 packed.append('\x00' * 6)
Rich Lane7dcdf022013-12-11 14:45:27 -08006853 packed.append(loxi.generic_util.pack_list(self.actions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006854 packed[6] = struct.pack("!H", len(packed[-1]))
6855 packed.append(self.data)
6856 length = sum([len(x) for x in packed])
6857 packed[2] = struct.pack("!H", length)
6858 return ''.join(packed)
6859
6860 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006861 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006862 obj = packet_out()
Dan Talaycof6202252013-07-02 01:00:29 -07006863 _version = reader.read("!B")[0]
6864 assert(_version == 3)
6865 _type = reader.read("!B")[0]
6866 assert(_type == 13)
6867 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006868 orig_reader = reader
6869 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006870 obj.xid = reader.read("!L")[0]
6871 obj.buffer_id = reader.read("!L")[0]
6872 obj.in_port = util.unpack_port_no(reader)
6873 _actions_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006874 reader.skip(6)
Rich Lane7dcdf022013-12-11 14:45:27 -08006875 obj.actions = loxi.generic_util.unpack_list(reader.slice(_actions_len), action.action.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006876 obj.data = str(reader.read_all())
6877 return obj
6878
6879 def __eq__(self, other):
6880 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006881 if self.xid != other.xid: return False
6882 if self.buffer_id != other.buffer_id: return False
6883 if self.in_port != other.in_port: return False
6884 if self.actions != other.actions: return False
6885 if self.data != other.data: return False
6886 return True
6887
Rich Lanec2ee4b82013-04-24 17:12:38 -07006888 def pretty_print(self, q):
6889 q.text("packet_out {")
6890 with q.group():
6891 with q.indent(2):
6892 q.breakable()
6893 q.text("xid = ");
6894 if self.xid != None:
6895 q.text("%#x" % self.xid)
6896 else:
6897 q.text('None')
6898 q.text(","); q.breakable()
6899 q.text("buffer_id = ");
6900 q.text("%#x" % self.buffer_id)
6901 q.text(","); q.breakable()
6902 q.text("in_port = ");
6903 q.text(util.pretty_port(self.in_port))
6904 q.text(","); q.breakable()
6905 q.text("actions = ");
6906 q.pp(self.actions)
6907 q.text(","); q.breakable()
6908 q.text("data = ");
6909 q.pp(self.data)
6910 q.breakable()
6911 q.text('}')
6912
Rich Lane7dcdf022013-12-11 14:45:27 -08006913message.subtypes[13] = packet_out
6914
6915class port_mod(message):
Dan Talaycof6202252013-07-02 01:00:29 -07006916 version = 3
6917 type = 16
Rich Lanec2ee4b82013-04-24 17:12:38 -07006918
6919 def __init__(self, xid=None, port_no=None, hw_addr=None, config=None, mask=None, advertise=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006920 if xid != None:
6921 self.xid = xid
6922 else:
6923 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006924 if port_no != None:
6925 self.port_no = port_no
6926 else:
6927 self.port_no = 0
6928 if hw_addr != None:
6929 self.hw_addr = hw_addr
6930 else:
6931 self.hw_addr = [0,0,0,0,0,0]
6932 if config != None:
6933 self.config = config
6934 else:
6935 self.config = 0
6936 if mask != None:
6937 self.mask = mask
6938 else:
6939 self.mask = 0
6940 if advertise != None:
6941 self.advertise = advertise
6942 else:
6943 self.advertise = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08006944 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006945
6946 def pack(self):
6947 packed = []
6948 packed.append(struct.pack("!B", self.version))
6949 packed.append(struct.pack("!B", self.type))
6950 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6951 packed.append(struct.pack("!L", self.xid))
Dan Talaycof6202252013-07-02 01:00:29 -07006952 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006953 packed.append('\x00' * 4)
6954 packed.append(struct.pack("!6B", *self.hw_addr))
6955 packed.append('\x00' * 2)
6956 packed.append(struct.pack("!L", self.config))
6957 packed.append(struct.pack("!L", self.mask))
6958 packed.append(struct.pack("!L", self.advertise))
6959 packed.append('\x00' * 4)
6960 length = sum([len(x) for x in packed])
6961 packed[2] = struct.pack("!H", length)
6962 return ''.join(packed)
6963
6964 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006965 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006966 obj = port_mod()
Dan Talaycof6202252013-07-02 01:00:29 -07006967 _version = reader.read("!B")[0]
6968 assert(_version == 3)
6969 _type = reader.read("!B")[0]
6970 assert(_type == 16)
6971 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006972 orig_reader = reader
6973 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006974 obj.xid = reader.read("!L")[0]
6975 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006976 reader.skip(4)
6977 obj.hw_addr = list(reader.read('!6B'))
6978 reader.skip(2)
Dan Talaycof6202252013-07-02 01:00:29 -07006979 obj.config = reader.read("!L")[0]
6980 obj.mask = reader.read("!L")[0]
6981 obj.advertise = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006982 reader.skip(4)
6983 return obj
6984
6985 def __eq__(self, other):
6986 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006987 if self.xid != other.xid: return False
6988 if self.port_no != other.port_no: return False
6989 if self.hw_addr != other.hw_addr: return False
6990 if self.config != other.config: return False
6991 if self.mask != other.mask: return False
6992 if self.advertise != other.advertise: return False
6993 return True
6994
Rich Lanec2ee4b82013-04-24 17:12:38 -07006995 def pretty_print(self, q):
6996 q.text("port_mod {")
6997 with q.group():
6998 with q.indent(2):
6999 q.breakable()
7000 q.text("xid = ");
7001 if self.xid != None:
7002 q.text("%#x" % self.xid)
7003 else:
7004 q.text('None')
7005 q.text(","); q.breakable()
7006 q.text("port_no = ");
7007 q.text(util.pretty_port(self.port_no))
7008 q.text(","); q.breakable()
7009 q.text("hw_addr = ");
7010 q.text(util.pretty_mac(self.hw_addr))
7011 q.text(","); q.breakable()
7012 q.text("config = ");
7013 q.text("%#x" % self.config)
7014 q.text(","); q.breakable()
7015 q.text("mask = ");
7016 q.text("%#x" % self.mask)
7017 q.text(","); q.breakable()
7018 q.text("advertise = ");
7019 q.text("%#x" % self.advertise)
7020 q.breakable()
7021 q.text('}')
7022
Rich Lane7dcdf022013-12-11 14:45:27 -08007023message.subtypes[16] = port_mod
7024
7025class port_mod_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07007026 version = 3
7027 type = 1
7028 err_type = 7
7029
7030 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007031 if xid != None:
7032 self.xid = xid
7033 else:
7034 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07007035 if code != None:
7036 self.code = code
7037 else:
7038 self.code = 0
7039 if data != None:
7040 self.data = data
7041 else:
7042 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08007043 return
Rich Lane6f4978c2013-10-20 21:33:52 -07007044
7045 def pack(self):
7046 packed = []
7047 packed.append(struct.pack("!B", self.version))
7048 packed.append(struct.pack("!B", self.type))
7049 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7050 packed.append(struct.pack("!L", self.xid))
7051 packed.append(struct.pack("!H", self.err_type))
7052 packed.append(struct.pack("!H", self.code))
7053 packed.append(self.data)
7054 length = sum([len(x) for x in packed])
7055 packed[2] = struct.pack("!H", length)
7056 return ''.join(packed)
7057
7058 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007059 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07007060 obj = port_mod_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07007061 _version = reader.read("!B")[0]
7062 assert(_version == 3)
7063 _type = reader.read("!B")[0]
7064 assert(_type == 1)
7065 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007066 orig_reader = reader
7067 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07007068 obj.xid = reader.read("!L")[0]
7069 _err_type = reader.read("!H")[0]
7070 assert(_err_type == 7)
7071 obj.code = reader.read("!H")[0]
7072 obj.data = str(reader.read_all())
7073 return obj
7074
7075 def __eq__(self, other):
7076 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07007077 if self.xid != other.xid: return False
7078 if self.code != other.code: return False
7079 if self.data != other.data: return False
7080 return True
7081
Rich Lane6f4978c2013-10-20 21:33:52 -07007082 def pretty_print(self, q):
7083 q.text("port_mod_failed_error_msg {")
7084 with q.group():
7085 with q.indent(2):
7086 q.breakable()
7087 q.text("xid = ");
7088 if self.xid != None:
7089 q.text("%#x" % self.xid)
7090 else:
7091 q.text('None')
7092 q.text(","); q.breakable()
7093 q.text("code = ");
7094 q.text("%#x" % self.code)
7095 q.text(","); q.breakable()
7096 q.text("data = ");
7097 q.pp(self.data)
7098 q.breakable()
7099 q.text('}')
7100
Rich Lane7dcdf022013-12-11 14:45:27 -08007101error_msg.subtypes[7] = port_mod_failed_error_msg
7102
7103class port_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07007104 version = 3
7105 type = 19
7106 stats_type = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07007107
7108 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007109 if xid != None:
7110 self.xid = xid
7111 else:
7112 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007113 if flags != None:
7114 self.flags = flags
7115 else:
7116 self.flags = 0
7117 if entries != None:
7118 self.entries = entries
7119 else:
7120 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08007121 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007122
7123 def pack(self):
7124 packed = []
7125 packed.append(struct.pack("!B", self.version))
7126 packed.append(struct.pack("!B", self.type))
7127 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7128 packed.append(struct.pack("!L", self.xid))
7129 packed.append(struct.pack("!H", self.stats_type))
7130 packed.append(struct.pack("!H", self.flags))
7131 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08007132 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007133 length = sum([len(x) for x in packed])
7134 packed[2] = struct.pack("!H", length)
7135 return ''.join(packed)
7136
7137 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007138 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007139 obj = port_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07007140 _version = reader.read("!B")[0]
7141 assert(_version == 3)
7142 _type = reader.read("!B")[0]
7143 assert(_type == 19)
7144 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007145 orig_reader = reader
7146 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07007147 obj.xid = reader.read("!L")[0]
7148 _stats_type = reader.read("!H")[0]
7149 assert(_stats_type == 4)
7150 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007151 reader.skip(4)
7152 obj.entries = loxi.generic_util.unpack_list(reader, common.port_stats_entry.unpack)
7153 return obj
7154
7155 def __eq__(self, other):
7156 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007157 if self.xid != other.xid: return False
7158 if self.flags != other.flags: return False
7159 if self.entries != other.entries: return False
7160 return True
7161
Rich Lanec2ee4b82013-04-24 17:12:38 -07007162 def pretty_print(self, q):
7163 q.text("port_stats_reply {")
7164 with q.group():
7165 with q.indent(2):
7166 q.breakable()
7167 q.text("xid = ");
7168 if self.xid != None:
7169 q.text("%#x" % self.xid)
7170 else:
7171 q.text('None')
7172 q.text(","); q.breakable()
7173 q.text("flags = ");
7174 q.text("%#x" % self.flags)
7175 q.text(","); q.breakable()
7176 q.text("entries = ");
7177 q.pp(self.entries)
7178 q.breakable()
7179 q.text('}')
7180
Rich Lane7dcdf022013-12-11 14:45:27 -08007181stats_reply.subtypes[4] = port_stats_reply
7182
7183class port_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07007184 version = 3
7185 type = 18
7186 stats_type = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07007187
7188 def __init__(self, xid=None, flags=None, port_no=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007189 if xid != None:
7190 self.xid = xid
7191 else:
7192 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007193 if flags != None:
7194 self.flags = flags
7195 else:
7196 self.flags = 0
7197 if port_no != None:
7198 self.port_no = port_no
7199 else:
7200 self.port_no = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08007201 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007202
7203 def pack(self):
7204 packed = []
7205 packed.append(struct.pack("!B", self.version))
7206 packed.append(struct.pack("!B", self.type))
7207 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7208 packed.append(struct.pack("!L", self.xid))
7209 packed.append(struct.pack("!H", self.stats_type))
7210 packed.append(struct.pack("!H", self.flags))
7211 packed.append('\x00' * 4)
Dan Talaycof6202252013-07-02 01:00:29 -07007212 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007213 packed.append('\x00' * 4)
7214 length = sum([len(x) for x in packed])
7215 packed[2] = struct.pack("!H", length)
7216 return ''.join(packed)
7217
7218 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007219 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007220 obj = port_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07007221 _version = reader.read("!B")[0]
7222 assert(_version == 3)
7223 _type = reader.read("!B")[0]
7224 assert(_type == 18)
7225 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007226 orig_reader = reader
7227 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07007228 obj.xid = reader.read("!L")[0]
7229 _stats_type = reader.read("!H")[0]
7230 assert(_stats_type == 4)
7231 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007232 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07007233 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07007234 reader.skip(4)
7235 return obj
7236
7237 def __eq__(self, other):
7238 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007239 if self.xid != other.xid: return False
7240 if self.flags != other.flags: return False
7241 if self.port_no != other.port_no: return False
7242 return True
7243
Rich Lanec2ee4b82013-04-24 17:12:38 -07007244 def pretty_print(self, q):
7245 q.text("port_stats_request {")
7246 with q.group():
7247 with q.indent(2):
7248 q.breakable()
7249 q.text("xid = ");
7250 if self.xid != None:
7251 q.text("%#x" % self.xid)
7252 else:
7253 q.text('None')
7254 q.text(","); q.breakable()
7255 q.text("flags = ");
7256 q.text("%#x" % self.flags)
7257 q.text(","); q.breakable()
7258 q.text("port_no = ");
7259 q.text(util.pretty_port(self.port_no))
7260 q.breakable()
7261 q.text('}')
7262
Rich Lane7dcdf022013-12-11 14:45:27 -08007263stats_request.subtypes[4] = port_stats_request
7264
7265class port_status(message):
Dan Talaycof6202252013-07-02 01:00:29 -07007266 version = 3
7267 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -07007268
7269 def __init__(self, xid=None, reason=None, desc=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007270 if xid != None:
7271 self.xid = xid
7272 else:
7273 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007274 if reason != None:
7275 self.reason = reason
7276 else:
7277 self.reason = 0
7278 if desc != None:
7279 self.desc = desc
7280 else:
7281 self.desc = common.port_desc()
Rich Lane7dcdf022013-12-11 14:45:27 -08007282 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007283
7284 def pack(self):
7285 packed = []
7286 packed.append(struct.pack("!B", self.version))
7287 packed.append(struct.pack("!B", self.type))
7288 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7289 packed.append(struct.pack("!L", self.xid))
7290 packed.append(struct.pack("!B", self.reason))
7291 packed.append('\x00' * 7)
7292 packed.append(self.desc.pack())
7293 length = sum([len(x) for x in packed])
7294 packed[2] = struct.pack("!H", length)
7295 return ''.join(packed)
7296
7297 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007298 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007299 obj = port_status()
Dan Talaycof6202252013-07-02 01:00:29 -07007300 _version = reader.read("!B")[0]
7301 assert(_version == 3)
7302 _type = reader.read("!B")[0]
7303 assert(_type == 12)
7304 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007305 orig_reader = reader
7306 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07007307 obj.xid = reader.read("!L")[0]
7308 obj.reason = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007309 reader.skip(7)
7310 obj.desc = common.port_desc.unpack(reader)
7311 return obj
7312
7313 def __eq__(self, other):
7314 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007315 if self.xid != other.xid: return False
7316 if self.reason != other.reason: return False
7317 if self.desc != other.desc: return False
7318 return True
7319
Rich Lanec2ee4b82013-04-24 17:12:38 -07007320 def pretty_print(self, q):
7321 q.text("port_status {")
7322 with q.group():
7323 with q.indent(2):
7324 q.breakable()
7325 q.text("xid = ");
7326 if self.xid != None:
7327 q.text("%#x" % self.xid)
7328 else:
7329 q.text('None')
7330 q.text(","); q.breakable()
7331 q.text("reason = ");
7332 q.text("%#x" % self.reason)
7333 q.text(","); q.breakable()
7334 q.text("desc = ");
7335 q.pp(self.desc)
7336 q.breakable()
7337 q.text('}')
7338
Rich Lane7dcdf022013-12-11 14:45:27 -08007339message.subtypes[12] = port_status
7340
7341class queue_get_config_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -07007342 version = 3
7343 type = 23
Rich Lanec2ee4b82013-04-24 17:12:38 -07007344
7345 def __init__(self, xid=None, port=None, queues=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007346 if xid != None:
7347 self.xid = xid
7348 else:
7349 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007350 if port != None:
7351 self.port = port
7352 else:
7353 self.port = 0
7354 if queues != None:
7355 self.queues = queues
7356 else:
7357 self.queues = []
Rich Lane7dcdf022013-12-11 14:45:27 -08007358 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007359
7360 def pack(self):
7361 packed = []
7362 packed.append(struct.pack("!B", self.version))
7363 packed.append(struct.pack("!B", self.type))
7364 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7365 packed.append(struct.pack("!L", self.xid))
Dan Talaycof6202252013-07-02 01:00:29 -07007366 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007367 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08007368 packed.append(loxi.generic_util.pack_list(self.queues))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007369 length = sum([len(x) for x in packed])
7370 packed[2] = struct.pack("!H", length)
7371 return ''.join(packed)
7372
7373 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007374 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007375 obj = queue_get_config_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07007376 _version = reader.read("!B")[0]
7377 assert(_version == 3)
7378 _type = reader.read("!B")[0]
7379 assert(_type == 23)
7380 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007381 orig_reader = reader
7382 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07007383 obj.xid = reader.read("!L")[0]
7384 obj.port = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07007385 reader.skip(4)
Rich Lane7dcdf022013-12-11 14:45:27 -08007386 obj.queues = loxi.generic_util.unpack_list(reader, common.packet_queue.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07007387 return obj
7388
7389 def __eq__(self, other):
7390 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007391 if self.xid != other.xid: return False
7392 if self.port != other.port: return False
7393 if self.queues != other.queues: return False
7394 return True
7395
Rich Lanec2ee4b82013-04-24 17:12:38 -07007396 def pretty_print(self, q):
7397 q.text("queue_get_config_reply {")
7398 with q.group():
7399 with q.indent(2):
7400 q.breakable()
7401 q.text("xid = ");
7402 if self.xid != None:
7403 q.text("%#x" % self.xid)
7404 else:
7405 q.text('None')
7406 q.text(","); q.breakable()
7407 q.text("port = ");
7408 q.text(util.pretty_port(self.port))
7409 q.text(","); q.breakable()
7410 q.text("queues = ");
7411 q.pp(self.queues)
7412 q.breakable()
7413 q.text('}')
7414
Rich Lane7dcdf022013-12-11 14:45:27 -08007415message.subtypes[23] = queue_get_config_reply
7416
7417class queue_get_config_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -07007418 version = 3
7419 type = 22
Rich Lanec2ee4b82013-04-24 17:12:38 -07007420
7421 def __init__(self, xid=None, port=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007422 if xid != None:
7423 self.xid = xid
7424 else:
7425 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007426 if port != None:
7427 self.port = port
7428 else:
7429 self.port = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08007430 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007431
7432 def pack(self):
7433 packed = []
7434 packed.append(struct.pack("!B", self.version))
7435 packed.append(struct.pack("!B", self.type))
7436 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7437 packed.append(struct.pack("!L", self.xid))
Dan Talaycof6202252013-07-02 01:00:29 -07007438 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007439 packed.append('\x00' * 4)
7440 length = sum([len(x) for x in packed])
7441 packed[2] = struct.pack("!H", length)
7442 return ''.join(packed)
7443
7444 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007445 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007446 obj = queue_get_config_request()
Dan Talaycof6202252013-07-02 01:00:29 -07007447 _version = reader.read("!B")[0]
7448 assert(_version == 3)
7449 _type = reader.read("!B")[0]
7450 assert(_type == 22)
7451 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007452 orig_reader = reader
7453 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07007454 obj.xid = reader.read("!L")[0]
7455 obj.port = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07007456 reader.skip(4)
7457 return obj
7458
7459 def __eq__(self, other):
7460 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007461 if self.xid != other.xid: return False
7462 if self.port != other.port: return False
7463 return True
7464
Rich Lanec2ee4b82013-04-24 17:12:38 -07007465 def pretty_print(self, q):
7466 q.text("queue_get_config_request {")
7467 with q.group():
7468 with q.indent(2):
7469 q.breakable()
7470 q.text("xid = ");
7471 if self.xid != None:
7472 q.text("%#x" % self.xid)
7473 else:
7474 q.text('None')
7475 q.text(","); q.breakable()
7476 q.text("port = ");
7477 q.text(util.pretty_port(self.port))
7478 q.breakable()
7479 q.text('}')
7480
Rich Lane7dcdf022013-12-11 14:45:27 -08007481message.subtypes[22] = queue_get_config_request
7482
7483class queue_op_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07007484 version = 3
7485 type = 1
7486 err_type = 9
7487
7488 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007489 if xid != None:
7490 self.xid = xid
7491 else:
7492 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07007493 if code != None:
7494 self.code = code
7495 else:
7496 self.code = 0
7497 if data != None:
7498 self.data = data
7499 else:
7500 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08007501 return
Rich Lane6f4978c2013-10-20 21:33:52 -07007502
7503 def pack(self):
7504 packed = []
7505 packed.append(struct.pack("!B", self.version))
7506 packed.append(struct.pack("!B", self.type))
7507 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7508 packed.append(struct.pack("!L", self.xid))
7509 packed.append(struct.pack("!H", self.err_type))
7510 packed.append(struct.pack("!H", self.code))
7511 packed.append(self.data)
7512 length = sum([len(x) for x in packed])
7513 packed[2] = struct.pack("!H", length)
7514 return ''.join(packed)
7515
7516 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007517 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07007518 obj = queue_op_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07007519 _version = reader.read("!B")[0]
7520 assert(_version == 3)
7521 _type = reader.read("!B")[0]
7522 assert(_type == 1)
7523 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007524 orig_reader = reader
7525 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07007526 obj.xid = reader.read("!L")[0]
7527 _err_type = reader.read("!H")[0]
7528 assert(_err_type == 9)
7529 obj.code = reader.read("!H")[0]
7530 obj.data = str(reader.read_all())
7531 return obj
7532
7533 def __eq__(self, other):
7534 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07007535 if self.xid != other.xid: return False
7536 if self.code != other.code: return False
7537 if self.data != other.data: return False
7538 return True
7539
Rich Lane6f4978c2013-10-20 21:33:52 -07007540 def pretty_print(self, q):
7541 q.text("queue_op_failed_error_msg {")
7542 with q.group():
7543 with q.indent(2):
7544 q.breakable()
7545 q.text("xid = ");
7546 if self.xid != None:
7547 q.text("%#x" % self.xid)
7548 else:
7549 q.text('None')
7550 q.text(","); q.breakable()
7551 q.text("code = ");
7552 q.text("%#x" % self.code)
7553 q.text(","); q.breakable()
7554 q.text("data = ");
7555 q.pp(self.data)
7556 q.breakable()
7557 q.text('}')
7558
Rich Lane7dcdf022013-12-11 14:45:27 -08007559error_msg.subtypes[9] = queue_op_failed_error_msg
7560
7561class queue_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07007562 version = 3
7563 type = 19
7564 stats_type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07007565
7566 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007567 if xid != None:
7568 self.xid = xid
7569 else:
7570 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007571 if flags != None:
7572 self.flags = flags
7573 else:
7574 self.flags = 0
7575 if entries != None:
7576 self.entries = entries
7577 else:
7578 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08007579 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007580
7581 def pack(self):
7582 packed = []
7583 packed.append(struct.pack("!B", self.version))
7584 packed.append(struct.pack("!B", self.type))
7585 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7586 packed.append(struct.pack("!L", self.xid))
7587 packed.append(struct.pack("!H", self.stats_type))
7588 packed.append(struct.pack("!H", self.flags))
7589 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08007590 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007591 length = sum([len(x) for x in packed])
7592 packed[2] = struct.pack("!H", length)
7593 return ''.join(packed)
7594
7595 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007596 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007597 obj = queue_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07007598 _version = reader.read("!B")[0]
7599 assert(_version == 3)
7600 _type = reader.read("!B")[0]
7601 assert(_type == 19)
7602 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007603 orig_reader = reader
7604 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07007605 obj.xid = reader.read("!L")[0]
7606 _stats_type = reader.read("!H")[0]
7607 assert(_stats_type == 5)
7608 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007609 reader.skip(4)
7610 obj.entries = loxi.generic_util.unpack_list(reader, common.queue_stats_entry.unpack)
7611 return obj
7612
7613 def __eq__(self, other):
7614 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007615 if self.xid != other.xid: return False
7616 if self.flags != other.flags: return False
7617 if self.entries != other.entries: return False
7618 return True
7619
Rich Lanec2ee4b82013-04-24 17:12:38 -07007620 def pretty_print(self, q):
7621 q.text("queue_stats_reply {")
7622 with q.group():
7623 with q.indent(2):
7624 q.breakable()
7625 q.text("xid = ");
7626 if self.xid != None:
7627 q.text("%#x" % self.xid)
7628 else:
7629 q.text('None')
7630 q.text(","); q.breakable()
7631 q.text("flags = ");
7632 q.text("%#x" % self.flags)
7633 q.text(","); q.breakable()
7634 q.text("entries = ");
7635 q.pp(self.entries)
7636 q.breakable()
7637 q.text('}')
7638
Rich Lane7dcdf022013-12-11 14:45:27 -08007639stats_reply.subtypes[5] = queue_stats_reply
7640
7641class queue_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07007642 version = 3
7643 type = 18
7644 stats_type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07007645
7646 def __init__(self, xid=None, flags=None, port_no=None, queue_id=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007647 if xid != None:
7648 self.xid = xid
7649 else:
7650 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007651 if flags != None:
7652 self.flags = flags
7653 else:
7654 self.flags = 0
7655 if port_no != None:
7656 self.port_no = port_no
7657 else:
7658 self.port_no = 0
7659 if queue_id != None:
7660 self.queue_id = queue_id
7661 else:
7662 self.queue_id = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08007663 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007664
7665 def pack(self):
7666 packed = []
7667 packed.append(struct.pack("!B", self.version))
7668 packed.append(struct.pack("!B", self.type))
7669 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7670 packed.append(struct.pack("!L", self.xid))
7671 packed.append(struct.pack("!H", self.stats_type))
7672 packed.append(struct.pack("!H", self.flags))
7673 packed.append('\x00' * 4)
Dan Talaycof6202252013-07-02 01:00:29 -07007674 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007675 packed.append(struct.pack("!L", self.queue_id))
7676 length = sum([len(x) for x in packed])
7677 packed[2] = struct.pack("!H", length)
7678 return ''.join(packed)
7679
7680 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007681 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007682 obj = queue_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07007683 _version = reader.read("!B")[0]
7684 assert(_version == 3)
7685 _type = reader.read("!B")[0]
7686 assert(_type == 18)
7687 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007688 orig_reader = reader
7689 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07007690 obj.xid = reader.read("!L")[0]
7691 _stats_type = reader.read("!H")[0]
7692 assert(_stats_type == 5)
7693 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007694 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07007695 obj.port_no = util.unpack_port_no(reader)
7696 obj.queue_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007697 return obj
7698
7699 def __eq__(self, other):
7700 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007701 if self.xid != other.xid: return False
7702 if self.flags != other.flags: return False
7703 if self.port_no != other.port_no: return False
7704 if self.queue_id != other.queue_id: return False
7705 return True
7706
Rich Lanec2ee4b82013-04-24 17:12:38 -07007707 def pretty_print(self, q):
7708 q.text("queue_stats_request {")
7709 with q.group():
7710 with q.indent(2):
7711 q.breakable()
7712 q.text("xid = ");
7713 if self.xid != None:
7714 q.text("%#x" % self.xid)
7715 else:
7716 q.text('None')
7717 q.text(","); q.breakable()
7718 q.text("flags = ");
7719 q.text("%#x" % self.flags)
7720 q.text(","); q.breakable()
7721 q.text("port_no = ");
7722 q.text(util.pretty_port(self.port_no))
7723 q.text(","); q.breakable()
7724 q.text("queue_id = ");
7725 q.text("%#x" % self.queue_id)
7726 q.breakable()
7727 q.text('}')
7728
Rich Lane7dcdf022013-12-11 14:45:27 -08007729stats_request.subtypes[5] = queue_stats_request
7730
7731class role_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -07007732 version = 3
7733 type = 25
Rich Lanec2ee4b82013-04-24 17:12:38 -07007734
Rich Laned9e3f7b2013-11-04 11:40:43 -08007735 def __init__(self, xid=None, role=None, generation_id=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007736 if xid != None:
7737 self.xid = xid
7738 else:
7739 self.xid = None
Rich Laned9e3f7b2013-11-04 11:40:43 -08007740 if role != None:
7741 self.role = role
Rich Lanec2ee4b82013-04-24 17:12:38 -07007742 else:
Rich Laned9e3f7b2013-11-04 11:40:43 -08007743 self.role = 0
7744 if generation_id != None:
7745 self.generation_id = generation_id
7746 else:
7747 self.generation_id = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08007748 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007749
7750 def pack(self):
7751 packed = []
7752 packed.append(struct.pack("!B", self.version))
7753 packed.append(struct.pack("!B", self.type))
7754 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7755 packed.append(struct.pack("!L", self.xid))
Rich Laned9e3f7b2013-11-04 11:40:43 -08007756 packed.append(struct.pack("!L", self.role))
7757 packed.append('\x00' * 4)
7758 packed.append(struct.pack("!Q", self.generation_id))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007759 length = sum([len(x) for x in packed])
7760 packed[2] = struct.pack("!H", length)
7761 return ''.join(packed)
7762
7763 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007764 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007765 obj = role_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07007766 _version = reader.read("!B")[0]
7767 assert(_version == 3)
7768 _type = reader.read("!B")[0]
7769 assert(_type == 25)
7770 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007771 orig_reader = reader
7772 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07007773 obj.xid = reader.read("!L")[0]
Rich Laned9e3f7b2013-11-04 11:40:43 -08007774 obj.role = reader.read("!L")[0]
7775 reader.skip(4)
7776 obj.generation_id = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007777 return obj
7778
7779 def __eq__(self, other):
7780 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007781 if self.xid != other.xid: return False
Rich Laned9e3f7b2013-11-04 11:40:43 -08007782 if self.role != other.role: return False
7783 if self.generation_id != other.generation_id: return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007784 return True
7785
Rich Lanec2ee4b82013-04-24 17:12:38 -07007786 def pretty_print(self, q):
7787 q.text("role_reply {")
7788 with q.group():
7789 with q.indent(2):
7790 q.breakable()
7791 q.text("xid = ");
7792 if self.xid != None:
7793 q.text("%#x" % self.xid)
7794 else:
7795 q.text('None')
7796 q.text(","); q.breakable()
Rich Laned9e3f7b2013-11-04 11:40:43 -08007797 q.text("role = ");
7798 q.text("%#x" % self.role)
7799 q.text(","); q.breakable()
7800 q.text("generation_id = ");
7801 q.text("%#x" % self.generation_id)
Rich Lanec2ee4b82013-04-24 17:12:38 -07007802 q.breakable()
7803 q.text('}')
7804
Rich Lane7dcdf022013-12-11 14:45:27 -08007805message.subtypes[25] = role_reply
7806
7807class role_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -07007808 version = 3
7809 type = 24
Rich Lanec2ee4b82013-04-24 17:12:38 -07007810
7811 def __init__(self, xid=None, role=None, generation_id=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007812 if xid != None:
7813 self.xid = xid
7814 else:
7815 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007816 if role != None:
7817 self.role = role
7818 else:
7819 self.role = 0
7820 if generation_id != None:
7821 self.generation_id = generation_id
7822 else:
7823 self.generation_id = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08007824 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007825
7826 def pack(self):
7827 packed = []
7828 packed.append(struct.pack("!B", self.version))
7829 packed.append(struct.pack("!B", self.type))
7830 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7831 packed.append(struct.pack("!L", self.xid))
7832 packed.append(struct.pack("!L", self.role))
7833 packed.append('\x00' * 4)
7834 packed.append(struct.pack("!Q", self.generation_id))
7835 length = sum([len(x) for x in packed])
7836 packed[2] = struct.pack("!H", length)
7837 return ''.join(packed)
7838
7839 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007840 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007841 obj = role_request()
Dan Talaycof6202252013-07-02 01:00:29 -07007842 _version = reader.read("!B")[0]
7843 assert(_version == 3)
7844 _type = reader.read("!B")[0]
7845 assert(_type == 24)
7846 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007847 orig_reader = reader
7848 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07007849 obj.xid = reader.read("!L")[0]
7850 obj.role = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007851 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07007852 obj.generation_id = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007853 return obj
7854
7855 def __eq__(self, other):
7856 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007857 if self.xid != other.xid: return False
7858 if self.role != other.role: return False
7859 if self.generation_id != other.generation_id: return False
7860 return True
7861
Rich Lanec2ee4b82013-04-24 17:12:38 -07007862 def pretty_print(self, q):
7863 q.text("role_request {")
7864 with q.group():
7865 with q.indent(2):
7866 q.breakable()
7867 q.text("xid = ");
7868 if self.xid != None:
7869 q.text("%#x" % self.xid)
7870 else:
7871 q.text('None')
7872 q.text(","); q.breakable()
7873 q.text("role = ");
7874 q.text("%#x" % self.role)
7875 q.text(","); q.breakable()
7876 q.text("generation_id = ");
7877 q.text("%#x" % self.generation_id)
7878 q.breakable()
7879 q.text('}')
7880
Rich Lane7dcdf022013-12-11 14:45:27 -08007881message.subtypes[24] = role_request
7882
7883class role_request_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07007884 version = 3
7885 type = 1
7886 err_type = 11
7887
7888 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007889 if xid != None:
7890 self.xid = xid
7891 else:
7892 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07007893 if code != None:
7894 self.code = code
7895 else:
7896 self.code = 0
7897 if data != None:
7898 self.data = data
7899 else:
7900 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08007901 return
Rich Lane6f4978c2013-10-20 21:33:52 -07007902
7903 def pack(self):
7904 packed = []
7905 packed.append(struct.pack("!B", self.version))
7906 packed.append(struct.pack("!B", self.type))
7907 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7908 packed.append(struct.pack("!L", self.xid))
7909 packed.append(struct.pack("!H", self.err_type))
7910 packed.append(struct.pack("!H", self.code))
7911 packed.append(self.data)
7912 length = sum([len(x) for x in packed])
7913 packed[2] = struct.pack("!H", length)
7914 return ''.join(packed)
7915
7916 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007917 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07007918 obj = role_request_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07007919 _version = reader.read("!B")[0]
7920 assert(_version == 3)
7921 _type = reader.read("!B")[0]
7922 assert(_type == 1)
7923 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007924 orig_reader = reader
7925 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07007926 obj.xid = reader.read("!L")[0]
7927 _err_type = reader.read("!H")[0]
7928 assert(_err_type == 11)
7929 obj.code = reader.read("!H")[0]
7930 obj.data = str(reader.read_all())
7931 return obj
7932
7933 def __eq__(self, other):
7934 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07007935 if self.xid != other.xid: return False
7936 if self.code != other.code: return False
7937 if self.data != other.data: return False
7938 return True
7939
Rich Lane6f4978c2013-10-20 21:33:52 -07007940 def pretty_print(self, q):
7941 q.text("role_request_failed_error_msg {")
7942 with q.group():
7943 with q.indent(2):
7944 q.breakable()
7945 q.text("xid = ");
7946 if self.xid != None:
7947 q.text("%#x" % self.xid)
7948 else:
7949 q.text('None')
7950 q.text(","); q.breakable()
7951 q.text("code = ");
7952 q.text("%#x" % self.code)
7953 q.text(","); q.breakable()
7954 q.text("data = ");
7955 q.pp(self.data)
7956 q.breakable()
7957 q.text('}')
7958
Rich Lane7dcdf022013-12-11 14:45:27 -08007959error_msg.subtypes[11] = role_request_failed_error_msg
7960
7961class set_config(message):
Dan Talaycof6202252013-07-02 01:00:29 -07007962 version = 3
7963 type = 9
Rich Lanec2ee4b82013-04-24 17:12:38 -07007964
7965 def __init__(self, xid=None, flags=None, miss_send_len=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007966 if xid != None:
7967 self.xid = xid
7968 else:
7969 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007970 if flags != None:
7971 self.flags = flags
7972 else:
7973 self.flags = 0
7974 if miss_send_len != None:
7975 self.miss_send_len = miss_send_len
7976 else:
7977 self.miss_send_len = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08007978 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007979
7980 def pack(self):
7981 packed = []
7982 packed.append(struct.pack("!B", self.version))
7983 packed.append(struct.pack("!B", self.type))
7984 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7985 packed.append(struct.pack("!L", self.xid))
7986 packed.append(struct.pack("!H", self.flags))
7987 packed.append(struct.pack("!H", self.miss_send_len))
7988 length = sum([len(x) for x in packed])
7989 packed[2] = struct.pack("!H", length)
7990 return ''.join(packed)
7991
7992 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007993 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007994 obj = set_config()
Dan Talaycof6202252013-07-02 01:00:29 -07007995 _version = reader.read("!B")[0]
7996 assert(_version == 3)
7997 _type = reader.read("!B")[0]
7998 assert(_type == 9)
7999 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08008000 orig_reader = reader
8001 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07008002 obj.xid = reader.read("!L")[0]
8003 obj.flags = reader.read("!H")[0]
8004 obj.miss_send_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07008005 return obj
8006
8007 def __eq__(self, other):
8008 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07008009 if self.xid != other.xid: return False
8010 if self.flags != other.flags: return False
8011 if self.miss_send_len != other.miss_send_len: return False
8012 return True
8013
Rich Lanec2ee4b82013-04-24 17:12:38 -07008014 def pretty_print(self, q):
8015 q.text("set_config {")
8016 with q.group():
8017 with q.indent(2):
8018 q.breakable()
8019 q.text("xid = ");
8020 if self.xid != None:
8021 q.text("%#x" % self.xid)
8022 else:
8023 q.text('None')
8024 q.text(","); q.breakable()
8025 q.text("flags = ");
8026 q.text("%#x" % self.flags)
8027 q.text(","); q.breakable()
8028 q.text("miss_send_len = ");
8029 q.text("%#x" % self.miss_send_len)
8030 q.breakable()
8031 q.text('}')
8032
Rich Lane7dcdf022013-12-11 14:45:27 -08008033message.subtypes[9] = set_config
8034
8035class switch_config_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07008036 version = 3
8037 type = 1
8038 err_type = 10
8039
8040 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08008041 if xid != None:
8042 self.xid = xid
8043 else:
8044 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07008045 if code != None:
8046 self.code = code
8047 else:
8048 self.code = 0
8049 if data != None:
8050 self.data = data
8051 else:
8052 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08008053 return
Rich Lane6f4978c2013-10-20 21:33:52 -07008054
8055 def pack(self):
8056 packed = []
8057 packed.append(struct.pack("!B", self.version))
8058 packed.append(struct.pack("!B", self.type))
8059 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
8060 packed.append(struct.pack("!L", self.xid))
8061 packed.append(struct.pack("!H", self.err_type))
8062 packed.append(struct.pack("!H", self.code))
8063 packed.append(self.data)
8064 length = sum([len(x) for x in packed])
8065 packed[2] = struct.pack("!H", length)
8066 return ''.join(packed)
8067
8068 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08008069 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07008070 obj = switch_config_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07008071 _version = reader.read("!B")[0]
8072 assert(_version == 3)
8073 _type = reader.read("!B")[0]
8074 assert(_type == 1)
8075 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08008076 orig_reader = reader
8077 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07008078 obj.xid = reader.read("!L")[0]
8079 _err_type = reader.read("!H")[0]
8080 assert(_err_type == 10)
8081 obj.code = reader.read("!H")[0]
8082 obj.data = str(reader.read_all())
8083 return obj
8084
8085 def __eq__(self, other):
8086 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07008087 if self.xid != other.xid: return False
8088 if self.code != other.code: return False
8089 if self.data != other.data: return False
8090 return True
8091
Rich Lane6f4978c2013-10-20 21:33:52 -07008092 def pretty_print(self, q):
8093 q.text("switch_config_failed_error_msg {")
8094 with q.group():
8095 with q.indent(2):
8096 q.breakable()
8097 q.text("xid = ");
8098 if self.xid != None:
8099 q.text("%#x" % self.xid)
8100 else:
8101 q.text('None')
8102 q.text(","); q.breakable()
8103 q.text("code = ");
8104 q.text("%#x" % self.code)
8105 q.text(","); q.breakable()
8106 q.text("data = ");
8107 q.pp(self.data)
8108 q.breakable()
8109 q.text('}')
8110
Rich Lane7dcdf022013-12-11 14:45:27 -08008111error_msg.subtypes[10] = switch_config_failed_error_msg
8112
8113class table_mod(message):
Dan Talaycof6202252013-07-02 01:00:29 -07008114 version = 3
8115 type = 17
Rich Lanec2ee4b82013-04-24 17:12:38 -07008116
8117 def __init__(self, xid=None, table_id=None, config=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08008118 if xid != None:
8119 self.xid = xid
8120 else:
8121 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07008122 if table_id != None:
8123 self.table_id = table_id
8124 else:
8125 self.table_id = 0
8126 if config != None:
8127 self.config = config
8128 else:
8129 self.config = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08008130 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07008131
8132 def pack(self):
8133 packed = []
8134 packed.append(struct.pack("!B", self.version))
8135 packed.append(struct.pack("!B", self.type))
8136 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
8137 packed.append(struct.pack("!L", self.xid))
8138 packed.append(struct.pack("!B", self.table_id))
8139 packed.append('\x00' * 3)
8140 packed.append(struct.pack("!L", self.config))
8141 length = sum([len(x) for x in packed])
8142 packed[2] = struct.pack("!H", length)
8143 return ''.join(packed)
8144
8145 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08008146 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07008147 obj = table_mod()
Dan Talaycof6202252013-07-02 01:00:29 -07008148 _version = reader.read("!B")[0]
8149 assert(_version == 3)
8150 _type = reader.read("!B")[0]
8151 assert(_type == 17)
8152 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08008153 orig_reader = reader
8154 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07008155 obj.xid = reader.read("!L")[0]
8156 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07008157 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07008158 obj.config = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07008159 return obj
8160
8161 def __eq__(self, other):
8162 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07008163 if self.xid != other.xid: return False
8164 if self.table_id != other.table_id: return False
8165 if self.config != other.config: return False
8166 return True
8167
Rich Lanec2ee4b82013-04-24 17:12:38 -07008168 def pretty_print(self, q):
8169 q.text("table_mod {")
8170 with q.group():
8171 with q.indent(2):
8172 q.breakable()
8173 q.text("xid = ");
8174 if self.xid != None:
8175 q.text("%#x" % self.xid)
8176 else:
8177 q.text('None')
8178 q.text(","); q.breakable()
8179 q.text("table_id = ");
8180 q.text("%#x" % self.table_id)
8181 q.text(","); q.breakable()
8182 q.text("config = ");
8183 q.text("%#x" % self.config)
8184 q.breakable()
8185 q.text('}')
8186
Rich Lane7dcdf022013-12-11 14:45:27 -08008187message.subtypes[17] = table_mod
8188
8189class table_mod_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07008190 version = 3
8191 type = 1
8192 err_type = 8
8193
8194 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08008195 if xid != None:
8196 self.xid = xid
8197 else:
8198 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07008199 if code != None:
8200 self.code = code
8201 else:
8202 self.code = 0
8203 if data != None:
8204 self.data = data
8205 else:
8206 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08008207 return
Rich Lane6f4978c2013-10-20 21:33:52 -07008208
8209 def pack(self):
8210 packed = []
8211 packed.append(struct.pack("!B", self.version))
8212 packed.append(struct.pack("!B", self.type))
8213 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
8214 packed.append(struct.pack("!L", self.xid))
8215 packed.append(struct.pack("!H", self.err_type))
8216 packed.append(struct.pack("!H", self.code))
8217 packed.append(self.data)
8218 length = sum([len(x) for x in packed])
8219 packed[2] = struct.pack("!H", length)
8220 return ''.join(packed)
8221
8222 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08008223 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07008224 obj = table_mod_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07008225 _version = reader.read("!B")[0]
8226 assert(_version == 3)
8227 _type = reader.read("!B")[0]
8228 assert(_type == 1)
8229 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08008230 orig_reader = reader
8231 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07008232 obj.xid = reader.read("!L")[0]
8233 _err_type = reader.read("!H")[0]
8234 assert(_err_type == 8)
8235 obj.code = reader.read("!H")[0]
8236 obj.data = str(reader.read_all())
8237 return obj
8238
8239 def __eq__(self, other):
8240 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07008241 if self.xid != other.xid: return False
8242 if self.code != other.code: return False
8243 if self.data != other.data: return False
8244 return True
8245
Rich Lane6f4978c2013-10-20 21:33:52 -07008246 def pretty_print(self, q):
8247 q.text("table_mod_failed_error_msg {")
8248 with q.group():
8249 with q.indent(2):
8250 q.breakable()
8251 q.text("xid = ");
8252 if self.xid != None:
8253 q.text("%#x" % self.xid)
8254 else:
8255 q.text('None')
8256 q.text(","); q.breakable()
8257 q.text("code = ");
8258 q.text("%#x" % self.code)
8259 q.text(","); q.breakable()
8260 q.text("data = ");
8261 q.pp(self.data)
8262 q.breakable()
8263 q.text('}')
8264
Rich Lane7dcdf022013-12-11 14:45:27 -08008265error_msg.subtypes[8] = table_mod_failed_error_msg
8266
8267class table_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07008268 version = 3
8269 type = 19
8270 stats_type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07008271
8272 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08008273 if xid != None:
8274 self.xid = xid
8275 else:
8276 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07008277 if flags != None:
8278 self.flags = flags
8279 else:
8280 self.flags = 0
8281 if entries != None:
8282 self.entries = entries
8283 else:
8284 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08008285 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07008286
8287 def pack(self):
8288 packed = []
8289 packed.append(struct.pack("!B", self.version))
8290 packed.append(struct.pack("!B", self.type))
8291 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
8292 packed.append(struct.pack("!L", self.xid))
8293 packed.append(struct.pack("!H", self.stats_type))
8294 packed.append(struct.pack("!H", self.flags))
8295 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08008296 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07008297 length = sum([len(x) for x in packed])
8298 packed[2] = struct.pack("!H", length)
8299 return ''.join(packed)
8300
8301 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08008302 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07008303 obj = table_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07008304 _version = reader.read("!B")[0]
8305 assert(_version == 3)
8306 _type = reader.read("!B")[0]
8307 assert(_type == 19)
8308 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08008309 orig_reader = reader
8310 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07008311 obj.xid = reader.read("!L")[0]
8312 _stats_type = reader.read("!H")[0]
8313 assert(_stats_type == 3)
8314 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07008315 reader.skip(4)
8316 obj.entries = loxi.generic_util.unpack_list(reader, common.table_stats_entry.unpack)
8317 return obj
8318
8319 def __eq__(self, other):
8320 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07008321 if self.xid != other.xid: return False
8322 if self.flags != other.flags: return False
8323 if self.entries != other.entries: return False
8324 return True
8325
Rich Lanec2ee4b82013-04-24 17:12:38 -07008326 def pretty_print(self, q):
8327 q.text("table_stats_reply {")
8328 with q.group():
8329 with q.indent(2):
8330 q.breakable()
8331 q.text("xid = ");
8332 if self.xid != None:
8333 q.text("%#x" % self.xid)
8334 else:
8335 q.text('None')
8336 q.text(","); q.breakable()
8337 q.text("flags = ");
8338 q.text("%#x" % self.flags)
8339 q.text(","); q.breakable()
8340 q.text("entries = ");
8341 q.pp(self.entries)
8342 q.breakable()
8343 q.text('}')
8344
Rich Lane7dcdf022013-12-11 14:45:27 -08008345stats_reply.subtypes[3] = table_stats_reply
8346
8347class table_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07008348 version = 3
8349 type = 18
8350 stats_type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07008351
8352 def __init__(self, xid=None, flags=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08008353 if xid != None:
8354 self.xid = xid
8355 else:
8356 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07008357 if flags != None:
8358 self.flags = flags
8359 else:
8360 self.flags = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08008361 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07008362
8363 def pack(self):
8364 packed = []
8365 packed.append(struct.pack("!B", self.version))
8366 packed.append(struct.pack("!B", self.type))
8367 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
8368 packed.append(struct.pack("!L", self.xid))
8369 packed.append(struct.pack("!H", self.stats_type))
8370 packed.append(struct.pack("!H", self.flags))
8371 packed.append('\x00' * 4)
8372 length = sum([len(x) for x in packed])
8373 packed[2] = struct.pack("!H", length)
8374 return ''.join(packed)
8375
8376 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08008377 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07008378 obj = table_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07008379 _version = reader.read("!B")[0]
8380 assert(_version == 3)
8381 _type = reader.read("!B")[0]
8382 assert(_type == 18)
8383 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08008384 orig_reader = reader
8385 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07008386 obj.xid = reader.read("!L")[0]
8387 _stats_type = reader.read("!H")[0]
8388 assert(_stats_type == 3)
8389 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07008390 reader.skip(4)
8391 return obj
8392
8393 def __eq__(self, other):
8394 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07008395 if self.xid != other.xid: return False
8396 if self.flags != other.flags: return False
8397 return True
8398
Rich Lanec2ee4b82013-04-24 17:12:38 -07008399 def pretty_print(self, q):
8400 q.text("table_stats_request {")
8401 with q.group():
8402 with q.indent(2):
8403 q.breakable()
8404 q.text("xid = ");
8405 if self.xid != None:
8406 q.text("%#x" % self.xid)
8407 else:
8408 q.text('None')
8409 q.text(","); q.breakable()
8410 q.text("flags = ");
8411 q.text("%#x" % self.flags)
8412 q.breakable()
8413 q.text('}')
8414
Rich Lane7dcdf022013-12-11 14:45:27 -08008415stats_request.subtypes[3] = table_stats_request
8416
Rich Lanec2ee4b82013-04-24 17:12:38 -07008417
8418def parse_header(buf):
8419 if len(buf) < 8:
8420 raise loxi.ProtocolError("too short to be an OpenFlow message")
8421 return struct.unpack_from("!BBHL", buf)
8422
8423def parse_message(buf):
8424 msg_ver, msg_type, msg_len, msg_xid = parse_header(buf)
Rich Lanefe600f52013-07-09 13:22:32 -07008425 if msg_ver != const.OFP_VERSION and msg_type != const.OFPT_HELLO:
8426 raise loxi.ProtocolError("wrong OpenFlow version (expected %d, got %d)" % (const.OFP_VERSION, msg_ver))
Rich Lanec2ee4b82013-04-24 17:12:38 -07008427 if len(buf) != msg_len:
8428 raise loxi.ProtocolError("incorrect message size")
Rich Lane7dcdf022013-12-11 14:45:27 -08008429 return message.unpack(loxi.generic_util.OFReader(buf))