blob: 72dad2ac4032be51fd45145e78c69406a0863343 [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 Lane7dcdf022013-12-11 14:45:27 -080022 @staticmethod
23 def unpack(reader):
24 subtype, = reader.peek('B', 1)
25 try:
26 subclass = message.subtypes[subtype]
27 except KeyError:
28 raise loxi.ProtocolError("unknown message subtype %#x" % subtype)
29 return subclass.unpack(reader)
30
31
32class stats_reply(message):
33 subtypes = {}
34
35 @staticmethod
36 def unpack(reader):
37 subtype, = reader.peek('!H', 8)
38 try:
39 subclass = stats_reply.subtypes[subtype]
40 except KeyError:
41 raise loxi.ProtocolError("unknown stats_reply message subtype %#x" % subtype)
42 return subclass.unpack(reader)
43
44message.subtypes[19] = stats_reply
45
46class aggregate_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -070047 version = 3
48 type = 19
49 stats_type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -070050
51 def __init__(self, xid=None, flags=None, packet_count=None, byte_count=None, flow_count=None):
Rich Lane7dcdf022013-12-11 14:45:27 -080052 if xid != None:
53 self.xid = xid
54 else:
55 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -070056 if flags != None:
57 self.flags = flags
58 else:
59 self.flags = 0
60 if packet_count != None:
61 self.packet_count = packet_count
62 else:
63 self.packet_count = 0
64 if byte_count != None:
65 self.byte_count = byte_count
66 else:
67 self.byte_count = 0
68 if flow_count != None:
69 self.flow_count = flow_count
70 else:
71 self.flow_count = 0
Rich Lane7dcdf022013-12-11 14:45:27 -080072 return
Rich Lanec2ee4b82013-04-24 17:12:38 -070073
74 def pack(self):
75 packed = []
76 packed.append(struct.pack("!B", self.version))
77 packed.append(struct.pack("!B", self.type))
78 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
79 packed.append(struct.pack("!L", self.xid))
80 packed.append(struct.pack("!H", self.stats_type))
81 packed.append(struct.pack("!H", self.flags))
82 packed.append('\x00' * 4)
83 packed.append(struct.pack("!Q", self.packet_count))
84 packed.append(struct.pack("!Q", self.byte_count))
85 packed.append(struct.pack("!L", self.flow_count))
86 packed.append('\x00' * 4)
87 length = sum([len(x) for x in packed])
88 packed[2] = struct.pack("!H", length)
89 return ''.join(packed)
90
91 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -080092 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -070093 obj = aggregate_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -070094 _version = reader.read("!B")[0]
95 assert(_version == 3)
96 _type = reader.read("!B")[0]
97 assert(_type == 19)
98 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -080099 orig_reader = reader
100 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700101 obj.xid = reader.read("!L")[0]
102 _stats_type = reader.read("!H")[0]
103 assert(_stats_type == 2)
104 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700105 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -0700106 obj.packet_count = reader.read("!Q")[0]
107 obj.byte_count = reader.read("!Q")[0]
108 obj.flow_count = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700109 reader.skip(4)
110 return obj
111
112 def __eq__(self, other):
113 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700114 if self.xid != other.xid: return False
115 if self.flags != other.flags: return False
116 if self.packet_count != other.packet_count: return False
117 if self.byte_count != other.byte_count: return False
118 if self.flow_count != other.flow_count: return False
119 return True
120
Rich Lanec2ee4b82013-04-24 17:12:38 -0700121 def pretty_print(self, q):
122 q.text("aggregate_stats_reply {")
123 with q.group():
124 with q.indent(2):
125 q.breakable()
126 q.text("xid = ");
127 if self.xid != None:
128 q.text("%#x" % self.xid)
129 else:
130 q.text('None')
131 q.text(","); q.breakable()
132 q.text("flags = ");
133 q.text("%#x" % self.flags)
134 q.text(","); q.breakable()
135 q.text("packet_count = ");
136 q.text("%#x" % self.packet_count)
137 q.text(","); q.breakable()
138 q.text("byte_count = ");
139 q.text("%#x" % self.byte_count)
140 q.text(","); q.breakable()
141 q.text("flow_count = ");
142 q.text("%#x" % self.flow_count)
143 q.breakable()
144 q.text('}')
145
Rich Lane7dcdf022013-12-11 14:45:27 -0800146stats_reply.subtypes[2] = aggregate_stats_reply
147
148class stats_request(message):
149 subtypes = {}
150
151 @staticmethod
152 def unpack(reader):
153 subtype, = reader.peek('!H', 8)
154 try:
155 subclass = stats_request.subtypes[subtype]
156 except KeyError:
157 raise loxi.ProtocolError("unknown stats_request message subtype %#x" % subtype)
158 return subclass.unpack(reader)
159
160message.subtypes[18] = stats_request
161
162class aggregate_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -0700163 version = 3
164 type = 18
165 stats_type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -0700166
167 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 -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 table_id != None:
177 self.table_id = table_id
178 else:
179 self.table_id = 0
180 if out_port != None:
181 self.out_port = out_port
182 else:
183 self.out_port = 0
184 if out_group != None:
185 self.out_group = out_group
186 else:
187 self.out_group = 0
188 if cookie != None:
189 self.cookie = cookie
190 else:
191 self.cookie = 0
192 if cookie_mask != None:
193 self.cookie_mask = cookie_mask
194 else:
195 self.cookie_mask = 0
196 if match != None:
197 self.match = match
198 else:
199 self.match = common.match()
Rich Lane7dcdf022013-12-11 14:45:27 -0800200 return
Rich Lanec2ee4b82013-04-24 17:12:38 -0700201
202 def pack(self):
203 packed = []
204 packed.append(struct.pack("!B", self.version))
205 packed.append(struct.pack("!B", self.type))
206 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
207 packed.append(struct.pack("!L", self.xid))
208 packed.append(struct.pack("!H", self.stats_type))
209 packed.append(struct.pack("!H", self.flags))
210 packed.append('\x00' * 4)
211 packed.append(struct.pack("!B", self.table_id))
212 packed.append('\x00' * 3)
Dan Talaycof6202252013-07-02 01:00:29 -0700213 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700214 packed.append(struct.pack("!L", self.out_group))
215 packed.append('\x00' * 4)
216 packed.append(struct.pack("!Q", self.cookie))
217 packed.append(struct.pack("!Q", self.cookie_mask))
218 packed.append(self.match.pack())
219 length = sum([len(x) for x in packed])
220 packed[2] = struct.pack("!H", length)
221 return ''.join(packed)
222
223 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800224 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700225 obj = aggregate_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -0700226 _version = reader.read("!B")[0]
227 assert(_version == 3)
228 _type = reader.read("!B")[0]
229 assert(_type == 18)
230 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800231 orig_reader = reader
232 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700233 obj.xid = reader.read("!L")[0]
234 _stats_type = reader.read("!H")[0]
235 assert(_stats_type == 2)
236 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700237 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -0700238 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700239 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -0700240 obj.out_port = util.unpack_port_no(reader)
241 obj.out_group = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700242 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -0700243 obj.cookie = reader.read("!Q")[0]
244 obj.cookie_mask = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700245 obj.match = common.match.unpack(reader)
246 return obj
247
248 def __eq__(self, other):
249 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700250 if self.xid != other.xid: return False
251 if self.flags != other.flags: return False
252 if self.table_id != other.table_id: return False
253 if self.out_port != other.out_port: return False
254 if self.out_group != other.out_group: return False
255 if self.cookie != other.cookie: return False
256 if self.cookie_mask != other.cookie_mask: return False
257 if self.match != other.match: return False
258 return True
259
Rich Lanec2ee4b82013-04-24 17:12:38 -0700260 def pretty_print(self, q):
261 q.text("aggregate_stats_request {")
262 with q.group():
263 with q.indent(2):
264 q.breakable()
265 q.text("xid = ");
266 if self.xid != None:
267 q.text("%#x" % self.xid)
268 else:
269 q.text('None')
270 q.text(","); q.breakable()
271 q.text("flags = ");
272 q.text("%#x" % self.flags)
273 q.text(","); q.breakable()
274 q.text("table_id = ");
275 q.text("%#x" % self.table_id)
276 q.text(","); q.breakable()
277 q.text("out_port = ");
278 q.text(util.pretty_port(self.out_port))
279 q.text(","); q.breakable()
280 q.text("out_group = ");
281 q.text("%#x" % self.out_group)
282 q.text(","); q.breakable()
283 q.text("cookie = ");
284 q.text("%#x" % self.cookie)
285 q.text(","); q.breakable()
286 q.text("cookie_mask = ");
287 q.text("%#x" % self.cookie_mask)
288 q.text(","); q.breakable()
289 q.text("match = ");
290 q.pp(self.match)
291 q.breakable()
292 q.text('}')
293
Rich Lane7dcdf022013-12-11 14:45:27 -0800294stats_request.subtypes[2] = aggregate_stats_request
295
296class error_msg(message):
297 subtypes = {}
298
299 @staticmethod
300 def unpack(reader):
301 subtype, = reader.peek('!H', 8)
302 try:
303 subclass = error_msg.subtypes[subtype]
304 except KeyError:
305 raise loxi.ProtocolError("unknown error_msg message subtype %#x" % subtype)
306 return subclass.unpack(reader)
307
308message.subtypes[1] = error_msg
309
310class bad_action_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -0700311 version = 3
312 type = 1
313 err_type = 2
314
315 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800316 if xid != None:
317 self.xid = xid
318 else:
319 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -0700320 if code != None:
321 self.code = code
322 else:
323 self.code = 0
324 if data != None:
325 self.data = data
326 else:
327 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -0800328 return
Rich Lane6f4978c2013-10-20 21:33:52 -0700329
330 def pack(self):
331 packed = []
332 packed.append(struct.pack("!B", self.version))
333 packed.append(struct.pack("!B", self.type))
334 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
335 packed.append(struct.pack("!L", self.xid))
336 packed.append(struct.pack("!H", self.err_type))
337 packed.append(struct.pack("!H", self.code))
338 packed.append(self.data)
339 length = sum([len(x) for x in packed])
340 packed[2] = struct.pack("!H", length)
341 return ''.join(packed)
342
343 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800344 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -0700345 obj = bad_action_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -0700346 _version = reader.read("!B")[0]
347 assert(_version == 3)
348 _type = reader.read("!B")[0]
349 assert(_type == 1)
350 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800351 orig_reader = reader
352 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -0700353 obj.xid = reader.read("!L")[0]
354 _err_type = reader.read("!H")[0]
355 assert(_err_type == 2)
356 obj.code = reader.read("!H")[0]
357 obj.data = str(reader.read_all())
358 return obj
359
360 def __eq__(self, other):
361 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -0700362 if self.xid != other.xid: return False
363 if self.code != other.code: return False
364 if self.data != other.data: return False
365 return True
366
Rich Lane6f4978c2013-10-20 21:33:52 -0700367 def pretty_print(self, q):
368 q.text("bad_action_error_msg {")
369 with q.group():
370 with q.indent(2):
371 q.breakable()
372 q.text("xid = ");
373 if self.xid != None:
374 q.text("%#x" % self.xid)
375 else:
376 q.text('None')
377 q.text(","); q.breakable()
378 q.text("code = ");
379 q.text("%#x" % self.code)
380 q.text(","); q.breakable()
381 q.text("data = ");
382 q.pp(self.data)
383 q.breakable()
384 q.text('}')
385
Rich Lane7dcdf022013-12-11 14:45:27 -0800386error_msg.subtypes[2] = bad_action_error_msg
387
388class bad_instruction_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -0700389 version = 3
390 type = 1
391 err_type = 3
392
393 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800394 if xid != None:
395 self.xid = xid
396 else:
397 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -0700398 if code != None:
399 self.code = code
400 else:
401 self.code = 0
402 if data != None:
403 self.data = data
404 else:
405 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -0800406 return
Rich Lane6f4978c2013-10-20 21:33:52 -0700407
408 def pack(self):
409 packed = []
410 packed.append(struct.pack("!B", self.version))
411 packed.append(struct.pack("!B", self.type))
412 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
413 packed.append(struct.pack("!L", self.xid))
414 packed.append(struct.pack("!H", self.err_type))
415 packed.append(struct.pack("!H", self.code))
416 packed.append(self.data)
417 length = sum([len(x) for x in packed])
418 packed[2] = struct.pack("!H", length)
419 return ''.join(packed)
420
421 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800422 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -0700423 obj = bad_instruction_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -0700424 _version = reader.read("!B")[0]
425 assert(_version == 3)
426 _type = reader.read("!B")[0]
427 assert(_type == 1)
428 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800429 orig_reader = reader
430 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -0700431 obj.xid = reader.read("!L")[0]
432 _err_type = reader.read("!H")[0]
433 assert(_err_type == 3)
434 obj.code = reader.read("!H")[0]
435 obj.data = str(reader.read_all())
436 return obj
437
438 def __eq__(self, other):
439 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -0700440 if self.xid != other.xid: return False
441 if self.code != other.code: return False
442 if self.data != other.data: return False
443 return True
444
Rich Lane6f4978c2013-10-20 21:33:52 -0700445 def pretty_print(self, q):
446 q.text("bad_instruction_error_msg {")
447 with q.group():
448 with q.indent(2):
449 q.breakable()
450 q.text("xid = ");
451 if self.xid != None:
452 q.text("%#x" % self.xid)
453 else:
454 q.text('None')
455 q.text(","); q.breakable()
456 q.text("code = ");
457 q.text("%#x" % self.code)
458 q.text(","); q.breakable()
459 q.text("data = ");
460 q.pp(self.data)
461 q.breakable()
462 q.text('}')
463
Rich Lane7dcdf022013-12-11 14:45:27 -0800464error_msg.subtypes[3] = bad_instruction_error_msg
465
466class bad_match_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -0700467 version = 3
468 type = 1
469 err_type = 4
470
471 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800472 if xid != None:
473 self.xid = xid
474 else:
475 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -0700476 if code != None:
477 self.code = code
478 else:
479 self.code = 0
480 if data != None:
481 self.data = data
482 else:
483 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -0800484 return
Rich Lane6f4978c2013-10-20 21:33:52 -0700485
486 def pack(self):
487 packed = []
488 packed.append(struct.pack("!B", self.version))
489 packed.append(struct.pack("!B", self.type))
490 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
491 packed.append(struct.pack("!L", self.xid))
492 packed.append(struct.pack("!H", self.err_type))
493 packed.append(struct.pack("!H", self.code))
494 packed.append(self.data)
495 length = sum([len(x) for x in packed])
496 packed[2] = struct.pack("!H", length)
497 return ''.join(packed)
498
499 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800500 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -0700501 obj = bad_match_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -0700502 _version = reader.read("!B")[0]
503 assert(_version == 3)
504 _type = reader.read("!B")[0]
505 assert(_type == 1)
506 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800507 orig_reader = reader
508 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -0700509 obj.xid = reader.read("!L")[0]
510 _err_type = reader.read("!H")[0]
511 assert(_err_type == 4)
512 obj.code = reader.read("!H")[0]
513 obj.data = str(reader.read_all())
514 return obj
515
516 def __eq__(self, other):
517 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -0700518 if self.xid != other.xid: return False
519 if self.code != other.code: return False
520 if self.data != other.data: return False
521 return True
522
Rich Lane6f4978c2013-10-20 21:33:52 -0700523 def pretty_print(self, q):
524 q.text("bad_match_error_msg {")
525 with q.group():
526 with q.indent(2):
527 q.breakable()
528 q.text("xid = ");
529 if self.xid != None:
530 q.text("%#x" % self.xid)
531 else:
532 q.text('None')
533 q.text(","); q.breakable()
534 q.text("code = ");
535 q.text("%#x" % self.code)
536 q.text(","); q.breakable()
537 q.text("data = ");
538 q.pp(self.data)
539 q.breakable()
540 q.text('}')
541
Rich Lane7dcdf022013-12-11 14:45:27 -0800542error_msg.subtypes[4] = bad_match_error_msg
543
544class bad_request_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -0700545 version = 3
546 type = 1
547 err_type = 1
548
549 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800550 if xid != None:
551 self.xid = xid
552 else:
553 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -0700554 if code != None:
555 self.code = code
556 else:
557 self.code = 0
558 if data != None:
559 self.data = data
560 else:
561 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -0800562 return
Rich Lane6f4978c2013-10-20 21:33:52 -0700563
564 def pack(self):
565 packed = []
566 packed.append(struct.pack("!B", self.version))
567 packed.append(struct.pack("!B", self.type))
568 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
569 packed.append(struct.pack("!L", self.xid))
570 packed.append(struct.pack("!H", self.err_type))
571 packed.append(struct.pack("!H", self.code))
572 packed.append(self.data)
573 length = sum([len(x) for x in packed])
574 packed[2] = struct.pack("!H", length)
575 return ''.join(packed)
576
577 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800578 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -0700579 obj = bad_request_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -0700580 _version = reader.read("!B")[0]
581 assert(_version == 3)
582 _type = reader.read("!B")[0]
583 assert(_type == 1)
584 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800585 orig_reader = reader
586 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -0700587 obj.xid = reader.read("!L")[0]
588 _err_type = reader.read("!H")[0]
589 assert(_err_type == 1)
590 obj.code = reader.read("!H")[0]
591 obj.data = str(reader.read_all())
592 return obj
593
594 def __eq__(self, other):
595 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -0700596 if self.xid != other.xid: return False
597 if self.code != other.code: return False
598 if self.data != other.data: return False
599 return True
600
Rich Lane6f4978c2013-10-20 21:33:52 -0700601 def pretty_print(self, q):
602 q.text("bad_request_error_msg {")
603 with q.group():
604 with q.indent(2):
605 q.breakable()
606 q.text("xid = ");
607 if self.xid != None:
608 q.text("%#x" % self.xid)
609 else:
610 q.text('None')
611 q.text(","); q.breakable()
612 q.text("code = ");
613 q.text("%#x" % self.code)
614 q.text(","); q.breakable()
615 q.text("data = ");
616 q.pp(self.data)
617 q.breakable()
618 q.text('}')
619
Rich Lane7dcdf022013-12-11 14:45:27 -0800620error_msg.subtypes[1] = bad_request_error_msg
621
622class barrier_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -0700623 version = 3
624 type = 21
Rich Lanec2ee4b82013-04-24 17:12:38 -0700625
626 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800627 if xid != None:
628 self.xid = xid
629 else:
630 self.xid = None
631 return
Rich Lanec2ee4b82013-04-24 17:12:38 -0700632
633 def pack(self):
634 packed = []
635 packed.append(struct.pack("!B", self.version))
636 packed.append(struct.pack("!B", self.type))
637 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
638 packed.append(struct.pack("!L", self.xid))
639 length = sum([len(x) for x in packed])
640 packed[2] = struct.pack("!H", length)
641 return ''.join(packed)
642
643 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800644 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700645 obj = barrier_reply()
Dan Talaycof6202252013-07-02 01:00:29 -0700646 _version = reader.read("!B")[0]
647 assert(_version == 3)
648 _type = reader.read("!B")[0]
649 assert(_type == 21)
650 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800651 orig_reader = reader
652 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700653 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700654 return obj
655
656 def __eq__(self, other):
657 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700658 if self.xid != other.xid: return False
659 return True
660
Rich Lanec2ee4b82013-04-24 17:12:38 -0700661 def pretty_print(self, q):
662 q.text("barrier_reply {")
663 with q.group():
664 with q.indent(2):
665 q.breakable()
666 q.text("xid = ");
667 if self.xid != None:
668 q.text("%#x" % self.xid)
669 else:
670 q.text('None')
671 q.breakable()
672 q.text('}')
673
Rich Lane7dcdf022013-12-11 14:45:27 -0800674message.subtypes[21] = barrier_reply
675
676class barrier_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -0700677 version = 3
678 type = 20
Rich Lanec2ee4b82013-04-24 17:12:38 -0700679
680 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800681 if xid != None:
682 self.xid = xid
683 else:
684 self.xid = None
685 return
Rich Lanec2ee4b82013-04-24 17:12:38 -0700686
687 def pack(self):
688 packed = []
689 packed.append(struct.pack("!B", self.version))
690 packed.append(struct.pack("!B", self.type))
691 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
692 packed.append(struct.pack("!L", self.xid))
693 length = sum([len(x) for x in packed])
694 packed[2] = struct.pack("!H", length)
695 return ''.join(packed)
696
697 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800698 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700699 obj = barrier_request()
Dan Talaycof6202252013-07-02 01:00:29 -0700700 _version = reader.read("!B")[0]
701 assert(_version == 3)
702 _type = reader.read("!B")[0]
703 assert(_type == 20)
704 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800705 orig_reader = reader
706 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700707 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700708 return obj
709
710 def __eq__(self, other):
711 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700712 if self.xid != other.xid: return False
713 return True
714
Rich Lanec2ee4b82013-04-24 17:12:38 -0700715 def pretty_print(self, q):
716 q.text("barrier_request {")
717 with q.group():
718 with q.indent(2):
719 q.breakable()
720 q.text("xid = ");
721 if self.xid != None:
722 q.text("%#x" % self.xid)
723 else:
724 q.text('None')
725 q.breakable()
726 q.text('}')
727
Rich Lane7dcdf022013-12-11 14:45:27 -0800728message.subtypes[20] = barrier_request
729
730class experimenter(message):
731 subtypes = {}
732
733 @staticmethod
734 def unpack(reader):
735 subtype, = reader.peek('!L', 8)
736 try:
737 subclass = experimenter.subtypes[subtype]
738 except KeyError:
739 raise loxi.ProtocolError("unknown experimenter message subtype %#x" % subtype)
740 return subclass.unpack(reader)
741
742message.subtypes[4] = experimenter
743
744class bsn_header(experimenter):
745 subtypes = {}
746
747 @staticmethod
748 def unpack(reader):
749 subtype, = reader.peek('!L', 12)
750 try:
751 subclass = bsn_header.subtypes[subtype]
752 except KeyError:
753 raise loxi.ProtocolError("unknown bsn_header experimenter message subtype %#x" % subtype)
754 return subclass.unpack(reader)
755
756experimenter.subtypes[6035143] = bsn_header
757
758class bsn_bw_clear_data_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -0700759 version = 3
760 type = 4
761 experimenter = 6035143
762 subtype = 22
763
764 def __init__(self, xid=None, status=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800765 if xid != None:
766 self.xid = xid
767 else:
768 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -0700769 if status != None:
770 self.status = status
771 else:
772 self.status = 0
Rich Lane7dcdf022013-12-11 14:45:27 -0800773 return
Dan Talaycof6202252013-07-02 01:00:29 -0700774
775 def pack(self):
776 packed = []
777 packed.append(struct.pack("!B", self.version))
778 packed.append(struct.pack("!B", self.type))
779 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
780 packed.append(struct.pack("!L", self.xid))
781 packed.append(struct.pack("!L", self.experimenter))
782 packed.append(struct.pack("!L", self.subtype))
783 packed.append(struct.pack("!L", self.status))
784 length = sum([len(x) for x in packed])
785 packed[2] = struct.pack("!H", length)
786 return ''.join(packed)
787
788 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800789 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -0700790 obj = bsn_bw_clear_data_reply()
Dan Talaycof6202252013-07-02 01:00:29 -0700791 _version = reader.read("!B")[0]
792 assert(_version == 3)
793 _type = reader.read("!B")[0]
794 assert(_type == 4)
795 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800796 orig_reader = reader
797 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700798 obj.xid = reader.read("!L")[0]
799 _experimenter = reader.read("!L")[0]
800 assert(_experimenter == 6035143)
801 _subtype = reader.read("!L")[0]
802 assert(_subtype == 22)
803 obj.status = reader.read("!L")[0]
804 return obj
805
806 def __eq__(self, other):
807 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -0700808 if self.xid != other.xid: return False
809 if self.status != other.status: return False
810 return True
811
Dan Talaycof6202252013-07-02 01:00:29 -0700812 def pretty_print(self, q):
813 q.text("bsn_bw_clear_data_reply {")
814 with q.group():
815 with q.indent(2):
816 q.breakable()
817 q.text("xid = ");
818 if self.xid != None:
819 q.text("%#x" % self.xid)
820 else:
821 q.text('None')
822 q.text(","); q.breakable()
823 q.text("status = ");
824 q.text("%#x" % self.status)
825 q.breakable()
826 q.text('}')
827
Rich Lane7dcdf022013-12-11 14:45:27 -0800828bsn_header.subtypes[22] = bsn_bw_clear_data_reply
829
830class bsn_bw_clear_data_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -0700831 version = 3
832 type = 4
833 experimenter = 6035143
834 subtype = 21
835
836 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800837 if xid != None:
838 self.xid = xid
839 else:
840 self.xid = None
841 return
Dan Talaycof6202252013-07-02 01:00:29 -0700842
843 def pack(self):
844 packed = []
845 packed.append(struct.pack("!B", self.version))
846 packed.append(struct.pack("!B", self.type))
847 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
848 packed.append(struct.pack("!L", self.xid))
849 packed.append(struct.pack("!L", self.experimenter))
850 packed.append(struct.pack("!L", self.subtype))
851 length = sum([len(x) for x in packed])
852 packed[2] = struct.pack("!H", length)
853 return ''.join(packed)
854
855 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800856 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -0700857 obj = bsn_bw_clear_data_request()
Dan Talaycof6202252013-07-02 01:00:29 -0700858 _version = reader.read("!B")[0]
859 assert(_version == 3)
860 _type = reader.read("!B")[0]
861 assert(_type == 4)
862 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800863 orig_reader = reader
864 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700865 obj.xid = reader.read("!L")[0]
866 _experimenter = reader.read("!L")[0]
867 assert(_experimenter == 6035143)
868 _subtype = reader.read("!L")[0]
869 assert(_subtype == 21)
870 return obj
871
872 def __eq__(self, other):
873 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -0700874 if self.xid != other.xid: return False
875 return True
876
Dan Talaycof6202252013-07-02 01:00:29 -0700877 def pretty_print(self, q):
878 q.text("bsn_bw_clear_data_request {")
879 with q.group():
880 with q.indent(2):
881 q.breakable()
882 q.text("xid = ");
883 if self.xid != None:
884 q.text("%#x" % self.xid)
885 else:
886 q.text('None')
887 q.breakable()
888 q.text('}')
889
Rich Lane7dcdf022013-12-11 14:45:27 -0800890bsn_header.subtypes[21] = bsn_bw_clear_data_request
891
892class bsn_bw_enable_get_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -0700893 version = 3
894 type = 4
895 experimenter = 6035143
896 subtype = 20
897
898 def __init__(self, xid=None, enabled=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800899 if xid != None:
900 self.xid = xid
901 else:
902 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -0700903 if enabled != None:
904 self.enabled = enabled
905 else:
906 self.enabled = 0
Rich Lane7dcdf022013-12-11 14:45:27 -0800907 return
Dan Talaycof6202252013-07-02 01:00:29 -0700908
909 def pack(self):
910 packed = []
911 packed.append(struct.pack("!B", self.version))
912 packed.append(struct.pack("!B", self.type))
913 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
914 packed.append(struct.pack("!L", self.xid))
915 packed.append(struct.pack("!L", self.experimenter))
916 packed.append(struct.pack("!L", self.subtype))
917 packed.append(struct.pack("!L", self.enabled))
918 length = sum([len(x) for x in packed])
919 packed[2] = struct.pack("!H", length)
920 return ''.join(packed)
921
922 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800923 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -0700924 obj = bsn_bw_enable_get_reply()
Dan Talaycof6202252013-07-02 01:00:29 -0700925 _version = reader.read("!B")[0]
926 assert(_version == 3)
927 _type = reader.read("!B")[0]
928 assert(_type == 4)
929 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800930 orig_reader = reader
931 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700932 obj.xid = reader.read("!L")[0]
933 _experimenter = reader.read("!L")[0]
934 assert(_experimenter == 6035143)
935 _subtype = reader.read("!L")[0]
936 assert(_subtype == 20)
937 obj.enabled = reader.read("!L")[0]
938 return obj
939
940 def __eq__(self, other):
941 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -0700942 if self.xid != other.xid: return False
943 if self.enabled != other.enabled: return False
944 return True
945
Dan Talaycof6202252013-07-02 01:00:29 -0700946 def pretty_print(self, q):
947 q.text("bsn_bw_enable_get_reply {")
948 with q.group():
949 with q.indent(2):
950 q.breakable()
951 q.text("xid = ");
952 if self.xid != None:
953 q.text("%#x" % self.xid)
954 else:
955 q.text('None')
956 q.text(","); q.breakable()
957 q.text("enabled = ");
958 q.text("%#x" % self.enabled)
959 q.breakable()
960 q.text('}')
961
Rich Lane7dcdf022013-12-11 14:45:27 -0800962bsn_header.subtypes[20] = bsn_bw_enable_get_reply
963
964class bsn_bw_enable_get_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -0700965 version = 3
966 type = 4
967 experimenter = 6035143
968 subtype = 19
969
970 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800971 if xid != None:
972 self.xid = xid
973 else:
974 self.xid = None
975 return
Dan Talaycof6202252013-07-02 01:00:29 -0700976
977 def pack(self):
978 packed = []
979 packed.append(struct.pack("!B", self.version))
980 packed.append(struct.pack("!B", self.type))
981 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
982 packed.append(struct.pack("!L", self.xid))
983 packed.append(struct.pack("!L", self.experimenter))
984 packed.append(struct.pack("!L", self.subtype))
985 length = sum([len(x) for x in packed])
986 packed[2] = struct.pack("!H", length)
987 return ''.join(packed)
988
989 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800990 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -0700991 obj = bsn_bw_enable_get_request()
Dan Talaycof6202252013-07-02 01:00:29 -0700992 _version = reader.read("!B")[0]
993 assert(_version == 3)
994 _type = reader.read("!B")[0]
995 assert(_type == 4)
996 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800997 orig_reader = reader
998 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700999 obj.xid = reader.read("!L")[0]
1000 _experimenter = reader.read("!L")[0]
1001 assert(_experimenter == 6035143)
1002 _subtype = reader.read("!L")[0]
1003 assert(_subtype == 19)
1004 return obj
1005
1006 def __eq__(self, other):
1007 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07001008 if self.xid != other.xid: return False
1009 return True
1010
Dan Talaycof6202252013-07-02 01:00:29 -07001011 def pretty_print(self, q):
1012 q.text("bsn_bw_enable_get_request {")
1013 with q.group():
1014 with q.indent(2):
1015 q.breakable()
1016 q.text("xid = ");
1017 if self.xid != None:
1018 q.text("%#x" % self.xid)
1019 else:
1020 q.text('None')
1021 q.breakable()
1022 q.text('}')
1023
Rich Lane7dcdf022013-12-11 14:45:27 -08001024bsn_header.subtypes[19] = bsn_bw_enable_get_request
1025
1026class bsn_bw_enable_set_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001027 version = 3
1028 type = 4
1029 experimenter = 6035143
1030 subtype = 23
1031
1032 def __init__(self, xid=None, enable=None, status=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001033 if xid != None:
1034 self.xid = xid
1035 else:
1036 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07001037 if enable != None:
1038 self.enable = enable
1039 else:
1040 self.enable = 0
1041 if status != None:
1042 self.status = status
1043 else:
1044 self.status = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001045 return
Dan Talaycof6202252013-07-02 01:00:29 -07001046
1047 def pack(self):
1048 packed = []
1049 packed.append(struct.pack("!B", self.version))
1050 packed.append(struct.pack("!B", self.type))
1051 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1052 packed.append(struct.pack("!L", self.xid))
1053 packed.append(struct.pack("!L", self.experimenter))
1054 packed.append(struct.pack("!L", self.subtype))
1055 packed.append(struct.pack("!L", self.enable))
1056 packed.append(struct.pack("!L", self.status))
1057 length = sum([len(x) for x in packed])
1058 packed[2] = struct.pack("!H", length)
1059 return ''.join(packed)
1060
1061 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001062 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001063 obj = bsn_bw_enable_set_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07001064 _version = reader.read("!B")[0]
1065 assert(_version == 3)
1066 _type = reader.read("!B")[0]
1067 assert(_type == 4)
1068 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001069 orig_reader = reader
1070 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001071 obj.xid = reader.read("!L")[0]
1072 _experimenter = reader.read("!L")[0]
1073 assert(_experimenter == 6035143)
1074 _subtype = reader.read("!L")[0]
1075 assert(_subtype == 23)
1076 obj.enable = reader.read("!L")[0]
1077 obj.status = reader.read("!L")[0]
1078 return obj
1079
1080 def __eq__(self, other):
1081 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07001082 if self.xid != other.xid: return False
1083 if self.enable != other.enable: return False
1084 if self.status != other.status: return False
1085 return True
1086
Dan Talaycof6202252013-07-02 01:00:29 -07001087 def pretty_print(self, q):
1088 q.text("bsn_bw_enable_set_reply {")
1089 with q.group():
1090 with q.indent(2):
1091 q.breakable()
1092 q.text("xid = ");
1093 if self.xid != None:
1094 q.text("%#x" % self.xid)
1095 else:
1096 q.text('None')
1097 q.text(","); q.breakable()
1098 q.text("enable = ");
1099 q.text("%#x" % self.enable)
1100 q.text(","); q.breakable()
1101 q.text("status = ");
1102 q.text("%#x" % self.status)
1103 q.breakable()
1104 q.text('}')
1105
Rich Lane7dcdf022013-12-11 14:45:27 -08001106bsn_header.subtypes[23] = bsn_bw_enable_set_reply
1107
1108class bsn_bw_enable_set_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001109 version = 3
1110 type = 4
1111 experimenter = 6035143
1112 subtype = 18
1113
1114 def __init__(self, xid=None, enable=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001115 if xid != None:
1116 self.xid = xid
1117 else:
1118 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07001119 if enable != None:
1120 self.enable = enable
1121 else:
1122 self.enable = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001123 return
Dan Talaycof6202252013-07-02 01:00:29 -07001124
1125 def pack(self):
1126 packed = []
1127 packed.append(struct.pack("!B", self.version))
1128 packed.append(struct.pack("!B", self.type))
1129 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1130 packed.append(struct.pack("!L", self.xid))
1131 packed.append(struct.pack("!L", self.experimenter))
1132 packed.append(struct.pack("!L", self.subtype))
1133 packed.append(struct.pack("!L", self.enable))
1134 length = sum([len(x) for x in packed])
1135 packed[2] = struct.pack("!H", length)
1136 return ''.join(packed)
1137
1138 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001139 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001140 obj = bsn_bw_enable_set_request()
Dan Talaycof6202252013-07-02 01:00:29 -07001141 _version = reader.read("!B")[0]
1142 assert(_version == 3)
1143 _type = reader.read("!B")[0]
1144 assert(_type == 4)
1145 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001146 orig_reader = reader
1147 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001148 obj.xid = reader.read("!L")[0]
1149 _experimenter = reader.read("!L")[0]
1150 assert(_experimenter == 6035143)
1151 _subtype = reader.read("!L")[0]
1152 assert(_subtype == 18)
1153 obj.enable = reader.read("!L")[0]
1154 return obj
1155
1156 def __eq__(self, other):
1157 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07001158 if self.xid != other.xid: return False
1159 if self.enable != other.enable: return False
1160 return True
1161
Dan Talaycof6202252013-07-02 01:00:29 -07001162 def pretty_print(self, q):
1163 q.text("bsn_bw_enable_set_request {")
1164 with q.group():
1165 with q.indent(2):
1166 q.breakable()
1167 q.text("xid = ");
1168 if self.xid != None:
1169 q.text("%#x" % self.xid)
1170 else:
1171 q.text('None')
1172 q.text(","); q.breakable()
1173 q.text("enable = ");
1174 q.text("%#x" % self.enable)
1175 q.breakable()
1176 q.text('}')
1177
Rich Lane7dcdf022013-12-11 14:45:27 -08001178bsn_header.subtypes[18] = bsn_bw_enable_set_request
1179
1180class bsn_get_interfaces_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001181 version = 3
1182 type = 4
1183 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07001184 subtype = 10
1185
1186 def __init__(self, xid=None, interfaces=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001187 if xid != None:
1188 self.xid = xid
1189 else:
1190 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07001191 if interfaces != None:
1192 self.interfaces = interfaces
1193 else:
1194 self.interfaces = []
Rich Lane7dcdf022013-12-11 14:45:27 -08001195 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07001196
1197 def pack(self):
1198 packed = []
1199 packed.append(struct.pack("!B", self.version))
1200 packed.append(struct.pack("!B", self.type))
1201 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1202 packed.append(struct.pack("!L", self.xid))
1203 packed.append(struct.pack("!L", self.experimenter))
1204 packed.append(struct.pack("!L", self.subtype))
Rich Lane7dcdf022013-12-11 14:45:27 -08001205 packed.append(loxi.generic_util.pack_list(self.interfaces))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001206 length = sum([len(x) for x in packed])
1207 packed[2] = struct.pack("!H", length)
1208 return ''.join(packed)
1209
1210 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001211 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001212 obj = bsn_get_interfaces_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07001213 _version = reader.read("!B")[0]
1214 assert(_version == 3)
1215 _type = reader.read("!B")[0]
1216 assert(_type == 4)
1217 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001218 orig_reader = reader
1219 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001220 obj.xid = reader.read("!L")[0]
1221 _experimenter = reader.read("!L")[0]
1222 assert(_experimenter == 6035143)
1223 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001224 assert(_subtype == 10)
1225 obj.interfaces = loxi.generic_util.unpack_list(reader, common.bsn_interface.unpack)
1226 return obj
1227
1228 def __eq__(self, other):
1229 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001230 if self.xid != other.xid: return False
1231 if self.interfaces != other.interfaces: return False
1232 return True
1233
Rich Lanec2ee4b82013-04-24 17:12:38 -07001234 def pretty_print(self, q):
1235 q.text("bsn_get_interfaces_reply {")
1236 with q.group():
1237 with q.indent(2):
1238 q.breakable()
1239 q.text("xid = ");
1240 if self.xid != None:
1241 q.text("%#x" % self.xid)
1242 else:
1243 q.text('None')
1244 q.text(","); q.breakable()
1245 q.text("interfaces = ");
1246 q.pp(self.interfaces)
1247 q.breakable()
1248 q.text('}')
1249
Rich Lane7dcdf022013-12-11 14:45:27 -08001250bsn_header.subtypes[10] = bsn_get_interfaces_reply
1251
1252class bsn_get_interfaces_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001253 version = 3
1254 type = 4
1255 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07001256 subtype = 9
1257
1258 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001259 if xid != None:
1260 self.xid = xid
1261 else:
1262 self.xid = None
1263 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07001264
1265 def pack(self):
1266 packed = []
1267 packed.append(struct.pack("!B", self.version))
1268 packed.append(struct.pack("!B", self.type))
1269 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1270 packed.append(struct.pack("!L", self.xid))
1271 packed.append(struct.pack("!L", self.experimenter))
1272 packed.append(struct.pack("!L", self.subtype))
1273 length = sum([len(x) for x in packed])
1274 packed[2] = struct.pack("!H", length)
1275 return ''.join(packed)
1276
1277 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001278 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001279 obj = bsn_get_interfaces_request()
Dan Talaycof6202252013-07-02 01:00:29 -07001280 _version = reader.read("!B")[0]
1281 assert(_version == 3)
1282 _type = reader.read("!B")[0]
1283 assert(_type == 4)
1284 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001285 orig_reader = reader
1286 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001287 obj.xid = reader.read("!L")[0]
1288 _experimenter = reader.read("!L")[0]
1289 assert(_experimenter == 6035143)
1290 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001291 assert(_subtype == 9)
1292 return obj
1293
1294 def __eq__(self, other):
1295 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001296 if self.xid != other.xid: return False
1297 return True
1298
Rich Lanec2ee4b82013-04-24 17:12:38 -07001299 def pretty_print(self, q):
1300 q.text("bsn_get_interfaces_request {")
1301 with q.group():
1302 with q.indent(2):
1303 q.breakable()
1304 q.text("xid = ");
1305 if self.xid != None:
1306 q.text("%#x" % self.xid)
1307 else:
1308 q.text('None')
1309 q.breakable()
1310 q.text('}')
1311
Rich Lane7dcdf022013-12-11 14:45:27 -08001312bsn_header.subtypes[9] = bsn_get_interfaces_request
1313
1314class bsn_get_mirroring_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001315 version = 3
1316 type = 4
1317 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07001318 subtype = 5
1319
1320 def __init__(self, xid=None, report_mirror_ports=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001321 if xid != None:
1322 self.xid = xid
1323 else:
1324 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07001325 if report_mirror_ports != None:
1326 self.report_mirror_ports = report_mirror_ports
1327 else:
1328 self.report_mirror_ports = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001329 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07001330
1331 def pack(self):
1332 packed = []
1333 packed.append(struct.pack("!B", self.version))
1334 packed.append(struct.pack("!B", self.type))
1335 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1336 packed.append(struct.pack("!L", self.xid))
1337 packed.append(struct.pack("!L", self.experimenter))
1338 packed.append(struct.pack("!L", self.subtype))
1339 packed.append(struct.pack("!B", self.report_mirror_ports))
1340 packed.append('\x00' * 3)
1341 length = sum([len(x) for x in packed])
1342 packed[2] = struct.pack("!H", length)
1343 return ''.join(packed)
1344
1345 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001346 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001347 obj = bsn_get_mirroring_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07001348 _version = reader.read("!B")[0]
1349 assert(_version == 3)
1350 _type = reader.read("!B")[0]
1351 assert(_type == 4)
1352 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001353 orig_reader = reader
1354 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001355 obj.xid = reader.read("!L")[0]
1356 _experimenter = reader.read("!L")[0]
1357 assert(_experimenter == 6035143)
1358 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001359 assert(_subtype == 5)
Dan Talaycof6202252013-07-02 01:00:29 -07001360 obj.report_mirror_ports = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001361 reader.skip(3)
1362 return obj
1363
1364 def __eq__(self, other):
1365 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001366 if self.xid != other.xid: return False
1367 if self.report_mirror_ports != other.report_mirror_ports: return False
1368 return True
1369
Rich Lanec2ee4b82013-04-24 17:12:38 -07001370 def pretty_print(self, q):
1371 q.text("bsn_get_mirroring_reply {")
1372 with q.group():
1373 with q.indent(2):
1374 q.breakable()
1375 q.text("xid = ");
1376 if self.xid != None:
1377 q.text("%#x" % self.xid)
1378 else:
1379 q.text('None')
1380 q.text(","); q.breakable()
1381 q.text("report_mirror_ports = ");
1382 q.text("%#x" % self.report_mirror_ports)
1383 q.breakable()
1384 q.text('}')
1385
Rich Lane7dcdf022013-12-11 14:45:27 -08001386bsn_header.subtypes[5] = bsn_get_mirroring_reply
1387
1388class bsn_get_mirroring_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001389 version = 3
1390 type = 4
1391 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07001392 subtype = 4
1393
1394 def __init__(self, xid=None, report_mirror_ports=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001395 if xid != None:
1396 self.xid = xid
1397 else:
1398 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07001399 if report_mirror_ports != None:
1400 self.report_mirror_ports = report_mirror_ports
1401 else:
1402 self.report_mirror_ports = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001403 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07001404
1405 def pack(self):
1406 packed = []
1407 packed.append(struct.pack("!B", self.version))
1408 packed.append(struct.pack("!B", self.type))
1409 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1410 packed.append(struct.pack("!L", self.xid))
1411 packed.append(struct.pack("!L", self.experimenter))
1412 packed.append(struct.pack("!L", self.subtype))
1413 packed.append(struct.pack("!B", self.report_mirror_ports))
1414 packed.append('\x00' * 3)
1415 length = sum([len(x) for x in packed])
1416 packed[2] = struct.pack("!H", length)
1417 return ''.join(packed)
1418
1419 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001420 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001421 obj = bsn_get_mirroring_request()
Dan Talaycof6202252013-07-02 01:00:29 -07001422 _version = reader.read("!B")[0]
1423 assert(_version == 3)
1424 _type = reader.read("!B")[0]
1425 assert(_type == 4)
1426 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001427 orig_reader = reader
1428 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001429 obj.xid = reader.read("!L")[0]
1430 _experimenter = reader.read("!L")[0]
1431 assert(_experimenter == 6035143)
1432 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001433 assert(_subtype == 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001434 obj.report_mirror_ports = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001435 reader.skip(3)
1436 return obj
1437
1438 def __eq__(self, other):
1439 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001440 if self.xid != other.xid: return False
1441 if self.report_mirror_ports != other.report_mirror_ports: return False
1442 return True
1443
Rich Lanec2ee4b82013-04-24 17:12:38 -07001444 def pretty_print(self, q):
1445 q.text("bsn_get_mirroring_request {")
1446 with q.group():
1447 with q.indent(2):
1448 q.breakable()
1449 q.text("xid = ");
1450 if self.xid != None:
1451 q.text("%#x" % self.xid)
1452 else:
1453 q.text('None')
1454 q.text(","); q.breakable()
1455 q.text("report_mirror_ports = ");
1456 q.text("%#x" % self.report_mirror_ports)
1457 q.breakable()
1458 q.text('}')
1459
Rich Lane7dcdf022013-12-11 14:45:27 -08001460bsn_header.subtypes[4] = bsn_get_mirroring_request
1461
1462class bsn_pdu_rx_reply(bsn_header):
Rich Lane6f4978c2013-10-20 21:33:52 -07001463 version = 3
1464 type = 4
1465 experimenter = 6035143
1466 subtype = 34
1467
Rich Lane7b0f2012013-11-22 14:15:26 -08001468 def __init__(self, xid=None, status=None, port_no=None, slot_num=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001469 if xid != None:
1470 self.xid = xid
1471 else:
1472 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07001473 if status != None:
1474 self.status = status
1475 else:
1476 self.status = 0
Rich Lane7b0f2012013-11-22 14:15:26 -08001477 if port_no != None:
1478 self.port_no = port_no
1479 else:
1480 self.port_no = 0
1481 if slot_num != None:
1482 self.slot_num = slot_num
1483 else:
1484 self.slot_num = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001485 return
Rich Lane6f4978c2013-10-20 21:33:52 -07001486
1487 def pack(self):
1488 packed = []
1489 packed.append(struct.pack("!B", self.version))
1490 packed.append(struct.pack("!B", self.type))
1491 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1492 packed.append(struct.pack("!L", self.xid))
1493 packed.append(struct.pack("!L", self.experimenter))
1494 packed.append(struct.pack("!L", self.subtype))
1495 packed.append(struct.pack("!L", self.status))
Rich Lane7b0f2012013-11-22 14:15:26 -08001496 packed.append(util.pack_port_no(self.port_no))
1497 packed.append(struct.pack("!B", self.slot_num))
Rich Lane6f4978c2013-10-20 21:33:52 -07001498 length = sum([len(x) for x in packed])
1499 packed[2] = struct.pack("!H", length)
1500 return ''.join(packed)
1501
1502 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001503 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07001504 obj = bsn_pdu_rx_reply()
Rich Lane6f4978c2013-10-20 21:33:52 -07001505 _version = reader.read("!B")[0]
1506 assert(_version == 3)
1507 _type = reader.read("!B")[0]
1508 assert(_type == 4)
1509 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001510 orig_reader = reader
1511 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07001512 obj.xid = reader.read("!L")[0]
1513 _experimenter = reader.read("!L")[0]
1514 assert(_experimenter == 6035143)
1515 _subtype = reader.read("!L")[0]
1516 assert(_subtype == 34)
1517 obj.status = reader.read("!L")[0]
Rich Lane7b0f2012013-11-22 14:15:26 -08001518 obj.port_no = util.unpack_port_no(reader)
1519 obj.slot_num = reader.read("!B")[0]
Rich Lane6f4978c2013-10-20 21:33:52 -07001520 return obj
1521
1522 def __eq__(self, other):
1523 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001524 if self.xid != other.xid: return False
1525 if self.status != other.status: return False
Rich Lane7b0f2012013-11-22 14:15:26 -08001526 if self.port_no != other.port_no: return False
1527 if self.slot_num != other.slot_num: return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001528 return True
1529
Rich Lane6f4978c2013-10-20 21:33:52 -07001530 def pretty_print(self, q):
1531 q.text("bsn_pdu_rx_reply {")
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("status = ");
1542 q.text("%#x" % self.status)
Rich Lane7b0f2012013-11-22 14:15:26 -08001543 q.text(","); q.breakable()
1544 q.text("port_no = ");
1545 q.text(util.pretty_port(self.port_no))
1546 q.text(","); q.breakable()
1547 q.text("slot_num = ");
1548 q.text("%#x" % self.slot_num)
Rich Lane6f4978c2013-10-20 21:33:52 -07001549 q.breakable()
1550 q.text('}')
1551
Rich Lane7dcdf022013-12-11 14:45:27 -08001552bsn_header.subtypes[34] = bsn_pdu_rx_reply
1553
1554class bsn_pdu_rx_request(bsn_header):
Rich Lane6f4978c2013-10-20 21:33:52 -07001555 version = 3
1556 type = 4
1557 experimenter = 6035143
1558 subtype = 33
1559
1560 def __init__(self, xid=None, timeout_ms=None, port_no=None, slot_num=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001561 if xid != None:
1562 self.xid = xid
1563 else:
1564 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07001565 if timeout_ms != None:
1566 self.timeout_ms = timeout_ms
1567 else:
1568 self.timeout_ms = 0
1569 if port_no != None:
1570 self.port_no = port_no
1571 else:
1572 self.port_no = 0
1573 if slot_num != None:
1574 self.slot_num = slot_num
1575 else:
1576 self.slot_num = 0
1577 if data != None:
1578 self.data = data
1579 else:
1580 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08001581 return
Rich Lane6f4978c2013-10-20 21:33:52 -07001582
1583 def pack(self):
1584 packed = []
1585 packed.append(struct.pack("!B", self.version))
1586 packed.append(struct.pack("!B", self.type))
1587 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1588 packed.append(struct.pack("!L", self.xid))
1589 packed.append(struct.pack("!L", self.experimenter))
1590 packed.append(struct.pack("!L", self.subtype))
1591 packed.append(struct.pack("!L", self.timeout_ms))
1592 packed.append(util.pack_port_no(self.port_no))
1593 packed.append(struct.pack("!B", self.slot_num))
1594 packed.append('\x00' * 3)
1595 packed.append(self.data)
1596 length = sum([len(x) for x in packed])
1597 packed[2] = struct.pack("!H", length)
1598 return ''.join(packed)
1599
1600 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001601 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07001602 obj = bsn_pdu_rx_request()
Rich Lane6f4978c2013-10-20 21:33:52 -07001603 _version = reader.read("!B")[0]
1604 assert(_version == 3)
1605 _type = reader.read("!B")[0]
1606 assert(_type == 4)
1607 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001608 orig_reader = reader
1609 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07001610 obj.xid = reader.read("!L")[0]
1611 _experimenter = reader.read("!L")[0]
1612 assert(_experimenter == 6035143)
1613 _subtype = reader.read("!L")[0]
1614 assert(_subtype == 33)
1615 obj.timeout_ms = reader.read("!L")[0]
1616 obj.port_no = util.unpack_port_no(reader)
1617 obj.slot_num = reader.read("!B")[0]
1618 reader.skip(3)
1619 obj.data = str(reader.read_all())
1620 return obj
1621
1622 def __eq__(self, other):
1623 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001624 if self.xid != other.xid: return False
1625 if self.timeout_ms != other.timeout_ms: return False
1626 if self.port_no != other.port_no: return False
1627 if self.slot_num != other.slot_num: return False
1628 if self.data != other.data: return False
1629 return True
1630
Rich Lane6f4978c2013-10-20 21:33:52 -07001631 def pretty_print(self, q):
1632 q.text("bsn_pdu_rx_request {")
1633 with q.group():
1634 with q.indent(2):
1635 q.breakable()
1636 q.text("xid = ");
1637 if self.xid != None:
1638 q.text("%#x" % self.xid)
1639 else:
1640 q.text('None')
1641 q.text(","); q.breakable()
1642 q.text("timeout_ms = ");
1643 q.text("%#x" % self.timeout_ms)
1644 q.text(","); q.breakable()
1645 q.text("port_no = ");
1646 q.text(util.pretty_port(self.port_no))
1647 q.text(","); q.breakable()
1648 q.text("slot_num = ");
1649 q.text("%#x" % self.slot_num)
1650 q.text(","); q.breakable()
1651 q.text("data = ");
1652 q.pp(self.data)
1653 q.breakable()
1654 q.text('}')
1655
Rich Lane7dcdf022013-12-11 14:45:27 -08001656bsn_header.subtypes[33] = bsn_pdu_rx_request
1657
1658class bsn_pdu_rx_timeout(bsn_header):
Rich Lane6f4978c2013-10-20 21:33:52 -07001659 version = 3
1660 type = 4
1661 experimenter = 6035143
1662 subtype = 35
1663
1664 def __init__(self, xid=None, port_no=None, slot_num=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001665 if xid != None:
1666 self.xid = xid
1667 else:
1668 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07001669 if port_no != None:
1670 self.port_no = port_no
1671 else:
1672 self.port_no = 0
1673 if slot_num != None:
1674 self.slot_num = slot_num
1675 else:
1676 self.slot_num = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001677 return
Rich Lane6f4978c2013-10-20 21:33:52 -07001678
1679 def pack(self):
1680 packed = []
1681 packed.append(struct.pack("!B", self.version))
1682 packed.append(struct.pack("!B", self.type))
1683 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1684 packed.append(struct.pack("!L", self.xid))
1685 packed.append(struct.pack("!L", self.experimenter))
1686 packed.append(struct.pack("!L", self.subtype))
1687 packed.append(util.pack_port_no(self.port_no))
1688 packed.append(struct.pack("!B", self.slot_num))
1689 length = sum([len(x) for x in packed])
1690 packed[2] = struct.pack("!H", length)
1691 return ''.join(packed)
1692
1693 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001694 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07001695 obj = bsn_pdu_rx_timeout()
Rich Lane6f4978c2013-10-20 21:33:52 -07001696 _version = reader.read("!B")[0]
1697 assert(_version == 3)
1698 _type = reader.read("!B")[0]
1699 assert(_type == 4)
1700 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001701 orig_reader = reader
1702 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07001703 obj.xid = reader.read("!L")[0]
1704 _experimenter = reader.read("!L")[0]
1705 assert(_experimenter == 6035143)
1706 _subtype = reader.read("!L")[0]
1707 assert(_subtype == 35)
1708 obj.port_no = util.unpack_port_no(reader)
1709 obj.slot_num = reader.read("!B")[0]
1710 return obj
1711
1712 def __eq__(self, other):
1713 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001714 if self.xid != other.xid: return False
1715 if self.port_no != other.port_no: return False
1716 if self.slot_num != other.slot_num: return False
1717 return True
1718
Rich Lane6f4978c2013-10-20 21:33:52 -07001719 def pretty_print(self, q):
1720 q.text("bsn_pdu_rx_timeout {")
1721 with q.group():
1722 with q.indent(2):
1723 q.breakable()
1724 q.text("xid = ");
1725 if self.xid != None:
1726 q.text("%#x" % self.xid)
1727 else:
1728 q.text('None')
1729 q.text(","); q.breakable()
1730 q.text("port_no = ");
1731 q.text(util.pretty_port(self.port_no))
1732 q.text(","); q.breakable()
1733 q.text("slot_num = ");
1734 q.text("%#x" % self.slot_num)
1735 q.breakable()
1736 q.text('}')
1737
Rich Lane7dcdf022013-12-11 14:45:27 -08001738bsn_header.subtypes[35] = bsn_pdu_rx_timeout
1739
1740class bsn_pdu_tx_reply(bsn_header):
Rich Lane6f4978c2013-10-20 21:33:52 -07001741 version = 3
1742 type = 4
1743 experimenter = 6035143
1744 subtype = 32
1745
Rich Lane7b0f2012013-11-22 14:15:26 -08001746 def __init__(self, xid=None, status=None, port_no=None, slot_num=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001747 if xid != None:
1748 self.xid = xid
1749 else:
1750 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07001751 if status != None:
1752 self.status = status
1753 else:
1754 self.status = 0
Rich Lane7b0f2012013-11-22 14:15:26 -08001755 if port_no != None:
1756 self.port_no = port_no
1757 else:
1758 self.port_no = 0
1759 if slot_num != None:
1760 self.slot_num = slot_num
1761 else:
1762 self.slot_num = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001763 return
Rich Lane6f4978c2013-10-20 21:33:52 -07001764
1765 def pack(self):
1766 packed = []
1767 packed.append(struct.pack("!B", self.version))
1768 packed.append(struct.pack("!B", self.type))
1769 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1770 packed.append(struct.pack("!L", self.xid))
1771 packed.append(struct.pack("!L", self.experimenter))
1772 packed.append(struct.pack("!L", self.subtype))
1773 packed.append(struct.pack("!L", self.status))
Rich Lane7b0f2012013-11-22 14:15:26 -08001774 packed.append(util.pack_port_no(self.port_no))
1775 packed.append(struct.pack("!B", self.slot_num))
Rich Lane6f4978c2013-10-20 21:33:52 -07001776 length = sum([len(x) for x in packed])
1777 packed[2] = struct.pack("!H", length)
1778 return ''.join(packed)
1779
1780 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001781 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07001782 obj = bsn_pdu_tx_reply()
Rich Lane6f4978c2013-10-20 21:33:52 -07001783 _version = reader.read("!B")[0]
1784 assert(_version == 3)
1785 _type = reader.read("!B")[0]
1786 assert(_type == 4)
1787 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001788 orig_reader = reader
1789 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07001790 obj.xid = reader.read("!L")[0]
1791 _experimenter = reader.read("!L")[0]
1792 assert(_experimenter == 6035143)
1793 _subtype = reader.read("!L")[0]
1794 assert(_subtype == 32)
1795 obj.status = reader.read("!L")[0]
Rich Lane7b0f2012013-11-22 14:15:26 -08001796 obj.port_no = util.unpack_port_no(reader)
1797 obj.slot_num = reader.read("!B")[0]
Rich Lane6f4978c2013-10-20 21:33:52 -07001798 return obj
1799
1800 def __eq__(self, other):
1801 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001802 if self.xid != other.xid: return False
1803 if self.status != other.status: return False
Rich Lane7b0f2012013-11-22 14:15:26 -08001804 if self.port_no != other.port_no: return False
1805 if self.slot_num != other.slot_num: return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001806 return True
1807
Rich Lane6f4978c2013-10-20 21:33:52 -07001808 def pretty_print(self, q):
1809 q.text("bsn_pdu_tx_reply {")
1810 with q.group():
1811 with q.indent(2):
1812 q.breakable()
1813 q.text("xid = ");
1814 if self.xid != None:
1815 q.text("%#x" % self.xid)
1816 else:
1817 q.text('None')
1818 q.text(","); q.breakable()
1819 q.text("status = ");
1820 q.text("%#x" % self.status)
Rich Lane7b0f2012013-11-22 14:15:26 -08001821 q.text(","); q.breakable()
1822 q.text("port_no = ");
1823 q.text(util.pretty_port(self.port_no))
1824 q.text(","); q.breakable()
1825 q.text("slot_num = ");
1826 q.text("%#x" % self.slot_num)
Rich Lane6f4978c2013-10-20 21:33:52 -07001827 q.breakable()
1828 q.text('}')
1829
Rich Lane7dcdf022013-12-11 14:45:27 -08001830bsn_header.subtypes[32] = bsn_pdu_tx_reply
1831
1832class bsn_pdu_tx_request(bsn_header):
Rich Lane6f4978c2013-10-20 21:33:52 -07001833 version = 3
1834 type = 4
1835 experimenter = 6035143
1836 subtype = 31
1837
1838 def __init__(self, xid=None, tx_interval_ms=None, port_no=None, slot_num=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001839 if xid != None:
1840 self.xid = xid
1841 else:
1842 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07001843 if tx_interval_ms != None:
1844 self.tx_interval_ms = tx_interval_ms
1845 else:
1846 self.tx_interval_ms = 0
1847 if port_no != None:
1848 self.port_no = port_no
1849 else:
1850 self.port_no = 0
1851 if slot_num != None:
1852 self.slot_num = slot_num
1853 else:
1854 self.slot_num = 0
1855 if data != None:
1856 self.data = data
1857 else:
1858 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08001859 return
Rich Lane6f4978c2013-10-20 21:33:52 -07001860
1861 def pack(self):
1862 packed = []
1863 packed.append(struct.pack("!B", self.version))
1864 packed.append(struct.pack("!B", self.type))
1865 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1866 packed.append(struct.pack("!L", self.xid))
1867 packed.append(struct.pack("!L", self.experimenter))
1868 packed.append(struct.pack("!L", self.subtype))
1869 packed.append(struct.pack("!L", self.tx_interval_ms))
1870 packed.append(util.pack_port_no(self.port_no))
1871 packed.append(struct.pack("!B", self.slot_num))
1872 packed.append('\x00' * 3)
1873 packed.append(self.data)
1874 length = sum([len(x) for x in packed])
1875 packed[2] = struct.pack("!H", length)
1876 return ''.join(packed)
1877
1878 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001879 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07001880 obj = bsn_pdu_tx_request()
Rich Lane6f4978c2013-10-20 21:33:52 -07001881 _version = reader.read("!B")[0]
1882 assert(_version == 3)
1883 _type = reader.read("!B")[0]
1884 assert(_type == 4)
1885 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001886 orig_reader = reader
1887 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07001888 obj.xid = reader.read("!L")[0]
1889 _experimenter = reader.read("!L")[0]
1890 assert(_experimenter == 6035143)
1891 _subtype = reader.read("!L")[0]
1892 assert(_subtype == 31)
1893 obj.tx_interval_ms = reader.read("!L")[0]
1894 obj.port_no = util.unpack_port_no(reader)
1895 obj.slot_num = reader.read("!B")[0]
1896 reader.skip(3)
1897 obj.data = str(reader.read_all())
1898 return obj
1899
1900 def __eq__(self, other):
1901 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001902 if self.xid != other.xid: return False
1903 if self.tx_interval_ms != other.tx_interval_ms: return False
1904 if self.port_no != other.port_no: return False
1905 if self.slot_num != other.slot_num: return False
1906 if self.data != other.data: return False
1907 return True
1908
Rich Lane6f4978c2013-10-20 21:33:52 -07001909 def pretty_print(self, q):
1910 q.text("bsn_pdu_tx_request {")
1911 with q.group():
1912 with q.indent(2):
1913 q.breakable()
1914 q.text("xid = ");
1915 if self.xid != None:
1916 q.text("%#x" % self.xid)
1917 else:
1918 q.text('None')
1919 q.text(","); q.breakable()
1920 q.text("tx_interval_ms = ");
1921 q.text("%#x" % self.tx_interval_ms)
1922 q.text(","); q.breakable()
1923 q.text("port_no = ");
1924 q.text(util.pretty_port(self.port_no))
1925 q.text(","); q.breakable()
1926 q.text("slot_num = ");
1927 q.text("%#x" % self.slot_num)
1928 q.text(","); q.breakable()
1929 q.text("data = ");
1930 q.pp(self.data)
1931 q.breakable()
1932 q.text('}')
1933
Rich Lane7dcdf022013-12-11 14:45:27 -08001934bsn_header.subtypes[31] = bsn_pdu_tx_request
1935
1936class bsn_set_mirroring(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001937 version = 3
1938 type = 4
1939 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07001940 subtype = 3
1941
1942 def __init__(self, xid=None, report_mirror_ports=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001943 if xid != None:
1944 self.xid = xid
1945 else:
1946 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07001947 if report_mirror_ports != None:
1948 self.report_mirror_ports = report_mirror_ports
1949 else:
1950 self.report_mirror_ports = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001951 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07001952
1953 def pack(self):
1954 packed = []
1955 packed.append(struct.pack("!B", self.version))
1956 packed.append(struct.pack("!B", self.type))
1957 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1958 packed.append(struct.pack("!L", self.xid))
1959 packed.append(struct.pack("!L", self.experimenter))
1960 packed.append(struct.pack("!L", self.subtype))
1961 packed.append(struct.pack("!B", self.report_mirror_ports))
1962 packed.append('\x00' * 3)
1963 length = sum([len(x) for x in packed])
1964 packed[2] = struct.pack("!H", length)
1965 return ''.join(packed)
1966
1967 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001968 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001969 obj = bsn_set_mirroring()
Dan Talaycof6202252013-07-02 01:00:29 -07001970 _version = reader.read("!B")[0]
1971 assert(_version == 3)
1972 _type = reader.read("!B")[0]
1973 assert(_type == 4)
1974 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001975 orig_reader = reader
1976 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001977 obj.xid = reader.read("!L")[0]
1978 _experimenter = reader.read("!L")[0]
1979 assert(_experimenter == 6035143)
1980 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001981 assert(_subtype == 3)
Dan Talaycof6202252013-07-02 01:00:29 -07001982 obj.report_mirror_ports = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001983 reader.skip(3)
1984 return obj
1985
1986 def __eq__(self, other):
1987 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001988 if self.xid != other.xid: return False
1989 if self.report_mirror_ports != other.report_mirror_ports: return False
1990 return True
1991
Rich Lanec2ee4b82013-04-24 17:12:38 -07001992 def pretty_print(self, q):
1993 q.text("bsn_set_mirroring {")
1994 with q.group():
1995 with q.indent(2):
1996 q.breakable()
1997 q.text("xid = ");
1998 if self.xid != None:
1999 q.text("%#x" % self.xid)
2000 else:
2001 q.text('None')
2002 q.text(","); q.breakable()
2003 q.text("report_mirror_ports = ");
2004 q.text("%#x" % self.report_mirror_ports)
2005 q.breakable()
2006 q.text('}')
2007
Rich Lane7dcdf022013-12-11 14:45:27 -08002008bsn_header.subtypes[3] = bsn_set_mirroring
2009
2010class bsn_set_pktin_suppression_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07002011 version = 3
2012 type = 4
2013 experimenter = 6035143
2014 subtype = 25
2015
2016 def __init__(self, xid=None, status=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002017 if xid != None:
2018 self.xid = xid
2019 else:
2020 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07002021 if status != None:
2022 self.status = status
2023 else:
2024 self.status = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002025 return
Dan Talaycof6202252013-07-02 01:00:29 -07002026
2027 def pack(self):
2028 packed = []
2029 packed.append(struct.pack("!B", self.version))
2030 packed.append(struct.pack("!B", self.type))
2031 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2032 packed.append(struct.pack("!L", self.xid))
2033 packed.append(struct.pack("!L", self.experimenter))
2034 packed.append(struct.pack("!L", self.subtype))
2035 packed.append(struct.pack("!L", self.status))
2036 length = sum([len(x) for x in packed])
2037 packed[2] = struct.pack("!H", length)
2038 return ''.join(packed)
2039
2040 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002041 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07002042 obj = bsn_set_pktin_suppression_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07002043 _version = reader.read("!B")[0]
2044 assert(_version == 3)
2045 _type = reader.read("!B")[0]
2046 assert(_type == 4)
2047 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002048 orig_reader = reader
2049 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002050 obj.xid = reader.read("!L")[0]
2051 _experimenter = reader.read("!L")[0]
2052 assert(_experimenter == 6035143)
2053 _subtype = reader.read("!L")[0]
2054 assert(_subtype == 25)
2055 obj.status = reader.read("!L")[0]
2056 return obj
2057
2058 def __eq__(self, other):
2059 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07002060 if self.xid != other.xid: return False
2061 if self.status != other.status: return False
2062 return True
2063
Dan Talaycof6202252013-07-02 01:00:29 -07002064 def pretty_print(self, q):
2065 q.text("bsn_set_pktin_suppression_reply {")
2066 with q.group():
2067 with q.indent(2):
2068 q.breakable()
2069 q.text("xid = ");
2070 if self.xid != None:
2071 q.text("%#x" % self.xid)
2072 else:
2073 q.text('None')
2074 q.text(","); q.breakable()
2075 q.text("status = ");
2076 q.text("%#x" % self.status)
2077 q.breakable()
2078 q.text('}')
2079
Rich Lane7dcdf022013-12-11 14:45:27 -08002080bsn_header.subtypes[25] = bsn_set_pktin_suppression_reply
2081
2082class bsn_set_pktin_suppression_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07002083 version = 3
2084 type = 4
2085 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07002086 subtype = 11
2087
2088 def __init__(self, xid=None, enabled=None, idle_timeout=None, hard_timeout=None, priority=None, cookie=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002089 if xid != None:
2090 self.xid = xid
2091 else:
2092 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07002093 if enabled != None:
2094 self.enabled = enabled
2095 else:
2096 self.enabled = 0
2097 if idle_timeout != None:
2098 self.idle_timeout = idle_timeout
2099 else:
2100 self.idle_timeout = 0
2101 if hard_timeout != None:
2102 self.hard_timeout = hard_timeout
2103 else:
2104 self.hard_timeout = 0
2105 if priority != None:
2106 self.priority = priority
2107 else:
2108 self.priority = 0
2109 if cookie != None:
2110 self.cookie = cookie
2111 else:
2112 self.cookie = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002113 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07002114
2115 def pack(self):
2116 packed = []
2117 packed.append(struct.pack("!B", self.version))
2118 packed.append(struct.pack("!B", self.type))
2119 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2120 packed.append(struct.pack("!L", self.xid))
2121 packed.append(struct.pack("!L", self.experimenter))
2122 packed.append(struct.pack("!L", self.subtype))
2123 packed.append(struct.pack("!B", self.enabled))
2124 packed.append('\x00' * 1)
2125 packed.append(struct.pack("!H", self.idle_timeout))
2126 packed.append(struct.pack("!H", self.hard_timeout))
2127 packed.append(struct.pack("!H", self.priority))
2128 packed.append(struct.pack("!Q", self.cookie))
2129 length = sum([len(x) for x in packed])
2130 packed[2] = struct.pack("!H", length)
2131 return ''.join(packed)
2132
2133 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002134 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07002135 obj = bsn_set_pktin_suppression_request()
Dan Talaycof6202252013-07-02 01:00:29 -07002136 _version = reader.read("!B")[0]
2137 assert(_version == 3)
2138 _type = reader.read("!B")[0]
2139 assert(_type == 4)
2140 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002141 orig_reader = reader
2142 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002143 obj.xid = reader.read("!L")[0]
2144 _experimenter = reader.read("!L")[0]
2145 assert(_experimenter == 6035143)
2146 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002147 assert(_subtype == 11)
Dan Talaycof6202252013-07-02 01:00:29 -07002148 obj.enabled = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002149 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -07002150 obj.idle_timeout = reader.read("!H")[0]
2151 obj.hard_timeout = reader.read("!H")[0]
2152 obj.priority = reader.read("!H")[0]
2153 obj.cookie = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002154 return obj
2155
2156 def __eq__(self, other):
2157 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002158 if self.xid != other.xid: return False
2159 if self.enabled != other.enabled: return False
2160 if self.idle_timeout != other.idle_timeout: return False
2161 if self.hard_timeout != other.hard_timeout: return False
2162 if self.priority != other.priority: return False
2163 if self.cookie != other.cookie: return False
2164 return True
2165
Rich Lanec2ee4b82013-04-24 17:12:38 -07002166 def pretty_print(self, q):
Dan Talaycof6202252013-07-02 01:00:29 -07002167 q.text("bsn_set_pktin_suppression_request {")
Rich Lanec2ee4b82013-04-24 17:12:38 -07002168 with q.group():
2169 with q.indent(2):
2170 q.breakable()
2171 q.text("xid = ");
2172 if self.xid != None:
2173 q.text("%#x" % self.xid)
2174 else:
2175 q.text('None')
2176 q.text(","); q.breakable()
2177 q.text("enabled = ");
2178 q.text("%#x" % self.enabled)
2179 q.text(","); q.breakable()
2180 q.text("idle_timeout = ");
2181 q.text("%#x" % self.idle_timeout)
2182 q.text(","); q.breakable()
2183 q.text("hard_timeout = ");
2184 q.text("%#x" % self.hard_timeout)
2185 q.text(","); q.breakable()
2186 q.text("priority = ");
2187 q.text("%#x" % self.priority)
2188 q.text(","); q.breakable()
2189 q.text("cookie = ");
2190 q.text("%#x" % self.cookie)
2191 q.breakable()
2192 q.text('}')
2193
Rich Lane7dcdf022013-12-11 14:45:27 -08002194bsn_header.subtypes[11] = bsn_set_pktin_suppression_request
2195
2196class experimenter_stats_reply(stats_reply):
2197 subtypes = {}
2198
2199 @staticmethod
2200 def unpack(reader):
2201 subtype, = reader.peek('!L', 16)
2202 try:
2203 subclass = experimenter_stats_reply.subtypes[subtype]
2204 except KeyError:
2205 raise loxi.ProtocolError("unknown experimenter_stats_reply stats_reply message subtype %#x" % subtype)
2206 return subclass.unpack(reader)
2207
2208stats_reply.subtypes[65535] = experimenter_stats_reply
2209
2210class bsn_stats_reply(experimenter_stats_reply):
2211 subtypes = {}
2212
2213 @staticmethod
2214 def unpack(reader):
2215 subtype, = reader.peek('!L', 20)
2216 try:
2217 subclass = bsn_stats_reply.subtypes[subtype]
2218 except KeyError:
2219 raise loxi.ProtocolError("unknown bsn_stats_reply experimenter_stats_reply stats_reply message subtype %#x" % subtype)
2220 return subclass.unpack(reader)
2221
2222experimenter_stats_reply.subtypes[6035143] = bsn_stats_reply
2223
2224class experimenter_stats_request(stats_request):
2225 subtypes = {}
2226
2227 @staticmethod
2228 def unpack(reader):
2229 subtype, = reader.peek('!L', 16)
2230 try:
2231 subclass = experimenter_stats_request.subtypes[subtype]
2232 except KeyError:
2233 raise loxi.ProtocolError("unknown experimenter_stats_request stats_request message subtype %#x" % subtype)
2234 return subclass.unpack(reader)
2235
2236stats_request.subtypes[65535] = experimenter_stats_request
2237
2238class bsn_stats_request(experimenter_stats_request):
2239 subtypes = {}
2240
2241 @staticmethod
2242 def unpack(reader):
2243 subtype, = reader.peek('!L', 20)
2244 try:
2245 subclass = bsn_stats_request.subtypes[subtype]
2246 except KeyError:
2247 raise loxi.ProtocolError("unknown bsn_stats_request experimenter_stats_request stats_request message subtype %#x" % subtype)
2248 return subclass.unpack(reader)
2249
2250experimenter_stats_request.subtypes[6035143] = bsn_stats_request
2251
2252class bsn_virtual_port_create_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07002253 version = 3
2254 type = 4
2255 experimenter = 6035143
2256 subtype = 16
2257
2258 def __init__(self, xid=None, status=None, vport_no=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002259 if xid != None:
2260 self.xid = xid
2261 else:
2262 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07002263 if status != None:
2264 self.status = status
2265 else:
2266 self.status = 0
2267 if vport_no != None:
2268 self.vport_no = vport_no
2269 else:
2270 self.vport_no = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002271 return
Dan Talaycof6202252013-07-02 01:00:29 -07002272
2273 def pack(self):
2274 packed = []
2275 packed.append(struct.pack("!B", self.version))
2276 packed.append(struct.pack("!B", self.type))
2277 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2278 packed.append(struct.pack("!L", self.xid))
2279 packed.append(struct.pack("!L", self.experimenter))
2280 packed.append(struct.pack("!L", self.subtype))
2281 packed.append(struct.pack("!L", self.status))
2282 packed.append(struct.pack("!L", self.vport_no))
2283 length = sum([len(x) for x in packed])
2284 packed[2] = struct.pack("!H", length)
2285 return ''.join(packed)
2286
2287 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002288 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07002289 obj = bsn_virtual_port_create_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07002290 _version = reader.read("!B")[0]
2291 assert(_version == 3)
2292 _type = reader.read("!B")[0]
2293 assert(_type == 4)
2294 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002295 orig_reader = reader
2296 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002297 obj.xid = reader.read("!L")[0]
2298 _experimenter = reader.read("!L")[0]
2299 assert(_experimenter == 6035143)
2300 _subtype = reader.read("!L")[0]
2301 assert(_subtype == 16)
2302 obj.status = reader.read("!L")[0]
2303 obj.vport_no = reader.read("!L")[0]
2304 return obj
2305
2306 def __eq__(self, other):
2307 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07002308 if self.xid != other.xid: return False
2309 if self.status != other.status: return False
2310 if self.vport_no != other.vport_no: return False
2311 return True
2312
Dan Talaycof6202252013-07-02 01:00:29 -07002313 def pretty_print(self, q):
2314 q.text("bsn_virtual_port_create_reply {")
2315 with q.group():
2316 with q.indent(2):
2317 q.breakable()
2318 q.text("xid = ");
2319 if self.xid != None:
2320 q.text("%#x" % self.xid)
2321 else:
2322 q.text('None')
2323 q.text(","); q.breakable()
2324 q.text("status = ");
2325 q.text("%#x" % self.status)
2326 q.text(","); q.breakable()
2327 q.text("vport_no = ");
2328 q.text("%#x" % self.vport_no)
2329 q.breakable()
2330 q.text('}')
2331
Rich Lane7dcdf022013-12-11 14:45:27 -08002332bsn_header.subtypes[16] = bsn_virtual_port_create_reply
2333
2334class bsn_virtual_port_create_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07002335 version = 3
2336 type = 4
2337 experimenter = 6035143
2338 subtype = 15
2339
2340 def __init__(self, xid=None, vport=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002341 if xid != None:
2342 self.xid = xid
2343 else:
2344 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07002345 if vport != None:
2346 self.vport = vport
2347 else:
2348 self.vport = common.bsn_vport_q_in_q()
Rich Lane7dcdf022013-12-11 14:45:27 -08002349 return
Dan Talaycof6202252013-07-02 01:00:29 -07002350
2351 def pack(self):
2352 packed = []
2353 packed.append(struct.pack("!B", self.version))
2354 packed.append(struct.pack("!B", self.type))
2355 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2356 packed.append(struct.pack("!L", self.xid))
2357 packed.append(struct.pack("!L", self.experimenter))
2358 packed.append(struct.pack("!L", self.subtype))
2359 packed.append(self.vport.pack())
2360 length = sum([len(x) for x in packed])
2361 packed[2] = struct.pack("!H", length)
2362 return ''.join(packed)
2363
2364 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002365 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07002366 obj = bsn_virtual_port_create_request()
Dan Talaycof6202252013-07-02 01:00:29 -07002367 _version = reader.read("!B")[0]
2368 assert(_version == 3)
2369 _type = reader.read("!B")[0]
2370 assert(_type == 4)
2371 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002372 orig_reader = reader
2373 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002374 obj.xid = reader.read("!L")[0]
2375 _experimenter = reader.read("!L")[0]
2376 assert(_experimenter == 6035143)
2377 _subtype = reader.read("!L")[0]
2378 assert(_subtype == 15)
2379 obj.vport = common.bsn_vport_q_in_q.unpack(reader)
2380 return obj
2381
2382 def __eq__(self, other):
2383 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07002384 if self.xid != other.xid: return False
2385 if self.vport != other.vport: return False
2386 return True
2387
Dan Talaycof6202252013-07-02 01:00:29 -07002388 def pretty_print(self, q):
2389 q.text("bsn_virtual_port_create_request {")
2390 with q.group():
2391 with q.indent(2):
2392 q.breakable()
2393 q.text("xid = ");
2394 if self.xid != None:
2395 q.text("%#x" % self.xid)
2396 else:
2397 q.text('None')
2398 q.text(","); q.breakable()
2399 q.text("vport = ");
2400 q.pp(self.vport)
2401 q.breakable()
2402 q.text('}')
2403
Rich Lane7dcdf022013-12-11 14:45:27 -08002404bsn_header.subtypes[15] = bsn_virtual_port_create_request
2405
2406class bsn_virtual_port_remove_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07002407 version = 3
2408 type = 4
2409 experimenter = 6035143
2410 subtype = 26
2411
2412 def __init__(self, xid=None, status=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002413 if xid != None:
2414 self.xid = xid
2415 else:
2416 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07002417 if status != None:
2418 self.status = status
2419 else:
2420 self.status = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002421 return
Dan Talaycof6202252013-07-02 01:00:29 -07002422
2423 def pack(self):
2424 packed = []
2425 packed.append(struct.pack("!B", self.version))
2426 packed.append(struct.pack("!B", self.type))
2427 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2428 packed.append(struct.pack("!L", self.xid))
2429 packed.append(struct.pack("!L", self.experimenter))
2430 packed.append(struct.pack("!L", self.subtype))
2431 packed.append(struct.pack("!L", self.status))
2432 length = sum([len(x) for x in packed])
2433 packed[2] = struct.pack("!H", length)
2434 return ''.join(packed)
2435
2436 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002437 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07002438 obj = bsn_virtual_port_remove_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07002439 _version = reader.read("!B")[0]
2440 assert(_version == 3)
2441 _type = reader.read("!B")[0]
2442 assert(_type == 4)
2443 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002444 orig_reader = reader
2445 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002446 obj.xid = reader.read("!L")[0]
2447 _experimenter = reader.read("!L")[0]
2448 assert(_experimenter == 6035143)
2449 _subtype = reader.read("!L")[0]
2450 assert(_subtype == 26)
2451 obj.status = reader.read("!L")[0]
2452 return obj
2453
2454 def __eq__(self, other):
2455 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07002456 if self.xid != other.xid: return False
2457 if self.status != other.status: return False
2458 return True
2459
Dan Talaycof6202252013-07-02 01:00:29 -07002460 def pretty_print(self, q):
2461 q.text("bsn_virtual_port_remove_reply {")
2462 with q.group():
2463 with q.indent(2):
2464 q.breakable()
2465 q.text("xid = ");
2466 if self.xid != None:
2467 q.text("%#x" % self.xid)
2468 else:
2469 q.text('None')
2470 q.text(","); q.breakable()
2471 q.text("status = ");
2472 q.text("%#x" % self.status)
2473 q.breakable()
2474 q.text('}')
2475
Rich Lane7dcdf022013-12-11 14:45:27 -08002476bsn_header.subtypes[26] = bsn_virtual_port_remove_reply
2477
2478class bsn_virtual_port_remove_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07002479 version = 3
2480 type = 4
2481 experimenter = 6035143
2482 subtype = 17
2483
2484 def __init__(self, xid=None, vport_no=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002485 if xid != None:
2486 self.xid = xid
2487 else:
2488 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07002489 if vport_no != None:
2490 self.vport_no = vport_no
2491 else:
2492 self.vport_no = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002493 return
Dan Talaycof6202252013-07-02 01:00:29 -07002494
2495 def pack(self):
2496 packed = []
2497 packed.append(struct.pack("!B", self.version))
2498 packed.append(struct.pack("!B", self.type))
2499 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2500 packed.append(struct.pack("!L", self.xid))
2501 packed.append(struct.pack("!L", self.experimenter))
2502 packed.append(struct.pack("!L", self.subtype))
2503 packed.append(struct.pack("!L", self.vport_no))
2504 length = sum([len(x) for x in packed])
2505 packed[2] = struct.pack("!H", length)
2506 return ''.join(packed)
2507
2508 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002509 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07002510 obj = bsn_virtual_port_remove_request()
Dan Talaycof6202252013-07-02 01:00:29 -07002511 _version = reader.read("!B")[0]
2512 assert(_version == 3)
2513 _type = reader.read("!B")[0]
2514 assert(_type == 4)
2515 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002516 orig_reader = reader
2517 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002518 obj.xid = reader.read("!L")[0]
2519 _experimenter = reader.read("!L")[0]
2520 assert(_experimenter == 6035143)
2521 _subtype = reader.read("!L")[0]
2522 assert(_subtype == 17)
2523 obj.vport_no = reader.read("!L")[0]
2524 return obj
2525
2526 def __eq__(self, other):
2527 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07002528 if self.xid != other.xid: return False
2529 if self.vport_no != other.vport_no: return False
2530 return True
2531
Dan Talaycof6202252013-07-02 01:00:29 -07002532 def pretty_print(self, q):
2533 q.text("bsn_virtual_port_remove_request {")
2534 with q.group():
2535 with q.indent(2):
2536 q.breakable()
2537 q.text("xid = ");
2538 if self.xid != None:
2539 q.text("%#x" % self.xid)
2540 else:
2541 q.text('None')
2542 q.text(","); q.breakable()
2543 q.text("vport_no = ");
2544 q.text("%#x" % self.vport_no)
2545 q.breakable()
2546 q.text('}')
2547
Rich Lane7dcdf022013-12-11 14:45:27 -08002548bsn_header.subtypes[17] = bsn_virtual_port_remove_request
2549
2550class desc_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07002551 version = 3
2552 type = 19
2553 stats_type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07002554
2555 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 -08002556 if xid != None:
2557 self.xid = xid
2558 else:
2559 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07002560 if flags != None:
2561 self.flags = flags
2562 else:
2563 self.flags = 0
2564 if mfr_desc != None:
2565 self.mfr_desc = mfr_desc
2566 else:
2567 self.mfr_desc = ""
2568 if hw_desc != None:
2569 self.hw_desc = hw_desc
2570 else:
2571 self.hw_desc = ""
2572 if sw_desc != None:
2573 self.sw_desc = sw_desc
2574 else:
2575 self.sw_desc = ""
2576 if serial_num != None:
2577 self.serial_num = serial_num
2578 else:
2579 self.serial_num = ""
2580 if dp_desc != None:
2581 self.dp_desc = dp_desc
2582 else:
2583 self.dp_desc = ""
Rich Lane7dcdf022013-12-11 14:45:27 -08002584 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07002585
2586 def pack(self):
2587 packed = []
2588 packed.append(struct.pack("!B", self.version))
2589 packed.append(struct.pack("!B", self.type))
2590 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2591 packed.append(struct.pack("!L", self.xid))
2592 packed.append(struct.pack("!H", self.stats_type))
2593 packed.append(struct.pack("!H", self.flags))
2594 packed.append('\x00' * 4)
2595 packed.append(struct.pack("!256s", self.mfr_desc))
2596 packed.append(struct.pack("!256s", self.hw_desc))
2597 packed.append(struct.pack("!256s", self.sw_desc))
2598 packed.append(struct.pack("!32s", self.serial_num))
2599 packed.append(struct.pack("!256s", self.dp_desc))
2600 length = sum([len(x) for x in packed])
2601 packed[2] = struct.pack("!H", length)
2602 return ''.join(packed)
2603
2604 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002605 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002606 obj = desc_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07002607 _version = reader.read("!B")[0]
2608 assert(_version == 3)
2609 _type = reader.read("!B")[0]
2610 assert(_type == 19)
2611 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002612 orig_reader = reader
2613 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002614 obj.xid = reader.read("!L")[0]
2615 _stats_type = reader.read("!H")[0]
2616 assert(_stats_type == 0)
2617 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002618 reader.skip(4)
2619 obj.mfr_desc = reader.read("!256s")[0].rstrip("\x00")
2620 obj.hw_desc = reader.read("!256s")[0].rstrip("\x00")
2621 obj.sw_desc = reader.read("!256s")[0].rstrip("\x00")
2622 obj.serial_num = reader.read("!32s")[0].rstrip("\x00")
2623 obj.dp_desc = reader.read("!256s")[0].rstrip("\x00")
2624 return obj
2625
2626 def __eq__(self, other):
2627 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002628 if self.xid != other.xid: return False
2629 if self.flags != other.flags: return False
2630 if self.mfr_desc != other.mfr_desc: return False
2631 if self.hw_desc != other.hw_desc: return False
2632 if self.sw_desc != other.sw_desc: return False
2633 if self.serial_num != other.serial_num: return False
2634 if self.dp_desc != other.dp_desc: return False
2635 return True
2636
Rich Lanec2ee4b82013-04-24 17:12:38 -07002637 def pretty_print(self, q):
2638 q.text("desc_stats_reply {")
2639 with q.group():
2640 with q.indent(2):
2641 q.breakable()
2642 q.text("xid = ");
2643 if self.xid != None:
2644 q.text("%#x" % self.xid)
2645 else:
2646 q.text('None')
2647 q.text(","); q.breakable()
2648 q.text("flags = ");
2649 q.text("%#x" % self.flags)
2650 q.text(","); q.breakable()
2651 q.text("mfr_desc = ");
2652 q.pp(self.mfr_desc)
2653 q.text(","); q.breakable()
2654 q.text("hw_desc = ");
2655 q.pp(self.hw_desc)
2656 q.text(","); q.breakable()
2657 q.text("sw_desc = ");
2658 q.pp(self.sw_desc)
2659 q.text(","); q.breakable()
2660 q.text("serial_num = ");
2661 q.pp(self.serial_num)
2662 q.text(","); q.breakable()
2663 q.text("dp_desc = ");
2664 q.pp(self.dp_desc)
2665 q.breakable()
2666 q.text('}')
2667
Rich Lane7dcdf022013-12-11 14:45:27 -08002668stats_reply.subtypes[0] = desc_stats_reply
2669
2670class desc_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07002671 version = 3
2672 type = 18
2673 stats_type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07002674
2675 def __init__(self, xid=None, flags=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002676 if xid != None:
2677 self.xid = xid
2678 else:
2679 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07002680 if flags != None:
2681 self.flags = flags
2682 else:
2683 self.flags = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002684 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07002685
2686 def pack(self):
2687 packed = []
2688 packed.append(struct.pack("!B", self.version))
2689 packed.append(struct.pack("!B", self.type))
2690 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2691 packed.append(struct.pack("!L", self.xid))
2692 packed.append(struct.pack("!H", self.stats_type))
2693 packed.append(struct.pack("!H", self.flags))
2694 packed.append('\x00' * 4)
2695 length = sum([len(x) for x in packed])
2696 packed[2] = struct.pack("!H", length)
2697 return ''.join(packed)
2698
2699 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002700 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002701 obj = desc_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07002702 _version = reader.read("!B")[0]
2703 assert(_version == 3)
2704 _type = reader.read("!B")[0]
2705 assert(_type == 18)
2706 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002707 orig_reader = reader
2708 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002709 obj.xid = reader.read("!L")[0]
2710 _stats_type = reader.read("!H")[0]
2711 assert(_stats_type == 0)
2712 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002713 reader.skip(4)
2714 return obj
2715
2716 def __eq__(self, other):
2717 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002718 if self.xid != other.xid: return False
2719 if self.flags != other.flags: return False
2720 return True
2721
Rich Lanec2ee4b82013-04-24 17:12:38 -07002722 def pretty_print(self, q):
2723 q.text("desc_stats_request {")
2724 with q.group():
2725 with q.indent(2):
2726 q.breakable()
2727 q.text("xid = ");
2728 if self.xid != None:
2729 q.text("%#x" % self.xid)
2730 else:
2731 q.text('None')
2732 q.text(","); q.breakable()
2733 q.text("flags = ");
2734 q.text("%#x" % self.flags)
2735 q.breakable()
2736 q.text('}')
2737
Rich Lane7dcdf022013-12-11 14:45:27 -08002738stats_request.subtypes[0] = desc_stats_request
2739
2740class echo_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -07002741 version = 3
2742 type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07002743
2744 def __init__(self, xid=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002745 if xid != None:
2746 self.xid = xid
2747 else:
2748 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07002749 if data != None:
2750 self.data = data
2751 else:
Dan Talaycof6202252013-07-02 01:00:29 -07002752 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08002753 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07002754
2755 def pack(self):
2756 packed = []
2757 packed.append(struct.pack("!B", self.version))
2758 packed.append(struct.pack("!B", self.type))
2759 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2760 packed.append(struct.pack("!L", self.xid))
2761 packed.append(self.data)
2762 length = sum([len(x) for x in packed])
2763 packed[2] = struct.pack("!H", length)
2764 return ''.join(packed)
2765
2766 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002767 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002768 obj = echo_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07002769 _version = reader.read("!B")[0]
2770 assert(_version == 3)
2771 _type = reader.read("!B")[0]
2772 assert(_type == 3)
2773 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002774 orig_reader = reader
2775 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002776 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002777 obj.data = str(reader.read_all())
2778 return obj
2779
2780 def __eq__(self, other):
2781 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002782 if self.xid != other.xid: return False
2783 if self.data != other.data: return False
2784 return True
2785
Rich Lanec2ee4b82013-04-24 17:12:38 -07002786 def pretty_print(self, q):
2787 q.text("echo_reply {")
2788 with q.group():
2789 with q.indent(2):
2790 q.breakable()
2791 q.text("xid = ");
2792 if self.xid != None:
2793 q.text("%#x" % self.xid)
2794 else:
2795 q.text('None')
2796 q.text(","); q.breakable()
2797 q.text("data = ");
2798 q.pp(self.data)
2799 q.breakable()
2800 q.text('}')
2801
Rich Lane7dcdf022013-12-11 14:45:27 -08002802message.subtypes[3] = echo_reply
2803
2804class echo_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -07002805 version = 3
2806 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07002807
2808 def __init__(self, xid=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002809 if xid != None:
2810 self.xid = xid
2811 else:
2812 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07002813 if data != None:
2814 self.data = data
2815 else:
Dan Talaycof6202252013-07-02 01:00:29 -07002816 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08002817 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07002818
2819 def pack(self):
2820 packed = []
2821 packed.append(struct.pack("!B", self.version))
2822 packed.append(struct.pack("!B", self.type))
2823 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2824 packed.append(struct.pack("!L", self.xid))
2825 packed.append(self.data)
2826 length = sum([len(x) for x in packed])
2827 packed[2] = struct.pack("!H", length)
2828 return ''.join(packed)
2829
2830 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002831 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002832 obj = echo_request()
Dan Talaycof6202252013-07-02 01:00:29 -07002833 _version = reader.read("!B")[0]
2834 assert(_version == 3)
2835 _type = reader.read("!B")[0]
2836 assert(_type == 2)
2837 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002838 orig_reader = reader
2839 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002840 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002841 obj.data = str(reader.read_all())
2842 return obj
2843
2844 def __eq__(self, other):
2845 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002846 if self.xid != other.xid: return False
2847 if self.data != other.data: return False
2848 return True
2849
Rich Lanec2ee4b82013-04-24 17:12:38 -07002850 def pretty_print(self, q):
2851 q.text("echo_request {")
2852 with q.group():
2853 with q.indent(2):
2854 q.breakable()
2855 q.text("xid = ");
2856 if self.xid != None:
2857 q.text("%#x" % self.xid)
2858 else:
2859 q.text('None')
2860 q.text(","); q.breakable()
2861 q.text("data = ");
2862 q.pp(self.data)
2863 q.breakable()
2864 q.text('}')
2865
Rich Lane7dcdf022013-12-11 14:45:27 -08002866message.subtypes[2] = echo_request
2867
2868class experimenter_error_msg(error_msg):
Dan Talaycof6202252013-07-02 01:00:29 -07002869 version = 3
2870 type = 1
Rich Lane6f4978c2013-10-20 21:33:52 -07002871 err_type = 65535
Rich Lanec2ee4b82013-04-24 17:12:38 -07002872
Rich Lane6f4978c2013-10-20 21:33:52 -07002873 def __init__(self, xid=None, subtype=None, experimenter=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002874 if xid != None:
2875 self.xid = xid
2876 else:
2877 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07002878 if subtype != None:
2879 self.subtype = subtype
Rich Lanec2ee4b82013-04-24 17:12:38 -07002880 else:
Rich Lane6f4978c2013-10-20 21:33:52 -07002881 self.subtype = 0
2882 if experimenter != None:
2883 self.experimenter = experimenter
Rich Lanec2ee4b82013-04-24 17:12:38 -07002884 else:
Rich Lane6f4978c2013-10-20 21:33:52 -07002885 self.experimenter = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07002886 if data != None:
2887 self.data = data
2888 else:
Dan Talaycof6202252013-07-02 01:00:29 -07002889 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08002890 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07002891
2892 def pack(self):
2893 packed = []
2894 packed.append(struct.pack("!B", self.version))
2895 packed.append(struct.pack("!B", self.type))
2896 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2897 packed.append(struct.pack("!L", self.xid))
2898 packed.append(struct.pack("!H", self.err_type))
Rich Lane6f4978c2013-10-20 21:33:52 -07002899 packed.append(struct.pack("!H", self.subtype))
2900 packed.append(struct.pack("!L", self.experimenter))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002901 packed.append(self.data)
2902 length = sum([len(x) for x in packed])
2903 packed[2] = struct.pack("!H", length)
2904 return ''.join(packed)
2905
2906 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002907 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07002908 obj = experimenter_error_msg()
Dan Talaycof6202252013-07-02 01:00:29 -07002909 _version = reader.read("!B")[0]
2910 assert(_version == 3)
2911 _type = reader.read("!B")[0]
2912 assert(_type == 1)
2913 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002914 orig_reader = reader
2915 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002916 obj.xid = reader.read("!L")[0]
Rich Lane6f4978c2013-10-20 21:33:52 -07002917 _err_type = reader.read("!H")[0]
2918 assert(_err_type == 65535)
2919 obj.subtype = reader.read("!H")[0]
2920 obj.experimenter = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002921 obj.data = str(reader.read_all())
2922 return obj
2923
2924 def __eq__(self, other):
2925 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002926 if self.xid != other.xid: return False
Rich Lane6f4978c2013-10-20 21:33:52 -07002927 if self.subtype != other.subtype: return False
2928 if self.experimenter != other.experimenter: return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002929 if self.data != other.data: return False
2930 return True
2931
Rich Lanec2ee4b82013-04-24 17:12:38 -07002932 def pretty_print(self, q):
Rich Lane6f4978c2013-10-20 21:33:52 -07002933 q.text("experimenter_error_msg {")
Rich Lanec2ee4b82013-04-24 17:12:38 -07002934 with q.group():
2935 with q.indent(2):
2936 q.breakable()
2937 q.text("xid = ");
2938 if self.xid != None:
2939 q.text("%#x" % self.xid)
2940 else:
2941 q.text('None')
2942 q.text(","); q.breakable()
Rich Lane6f4978c2013-10-20 21:33:52 -07002943 q.text("subtype = ");
2944 q.text("%#x" % self.subtype)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002945 q.text(","); q.breakable()
Rich Lane6f4978c2013-10-20 21:33:52 -07002946 q.text("experimenter = ");
2947 q.text("%#x" % self.experimenter)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002948 q.text(","); q.breakable()
2949 q.text("data = ");
2950 q.pp(self.data)
2951 q.breakable()
2952 q.text('}')
2953
Rich Lane7dcdf022013-12-11 14:45:27 -08002954error_msg.subtypes[65535] = experimenter_error_msg
2955
2956class features_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -07002957 version = 3
2958 type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07002959
2960 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 -08002961 if xid != None:
2962 self.xid = xid
2963 else:
2964 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07002965 if datapath_id != None:
2966 self.datapath_id = datapath_id
2967 else:
2968 self.datapath_id = 0
2969 if n_buffers != None:
2970 self.n_buffers = n_buffers
2971 else:
2972 self.n_buffers = 0
2973 if n_tables != None:
2974 self.n_tables = n_tables
2975 else:
2976 self.n_tables = 0
2977 if capabilities != None:
2978 self.capabilities = capabilities
2979 else:
2980 self.capabilities = 0
2981 if reserved != None:
2982 self.reserved = reserved
2983 else:
2984 self.reserved = 0
2985 if ports != None:
2986 self.ports = ports
2987 else:
2988 self.ports = []
Rich Lane7dcdf022013-12-11 14:45:27 -08002989 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07002990
2991 def pack(self):
2992 packed = []
2993 packed.append(struct.pack("!B", self.version))
2994 packed.append(struct.pack("!B", self.type))
2995 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2996 packed.append(struct.pack("!L", self.xid))
2997 packed.append(struct.pack("!Q", self.datapath_id))
2998 packed.append(struct.pack("!L", self.n_buffers))
2999 packed.append(struct.pack("!B", self.n_tables))
3000 packed.append('\x00' * 3)
3001 packed.append(struct.pack("!L", self.capabilities))
3002 packed.append(struct.pack("!L", self.reserved))
Rich Lane7dcdf022013-12-11 14:45:27 -08003003 packed.append(loxi.generic_util.pack_list(self.ports))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003004 length = sum([len(x) for x in packed])
3005 packed[2] = struct.pack("!H", length)
3006 return ''.join(packed)
3007
3008 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003009 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003010 obj = features_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07003011 _version = reader.read("!B")[0]
3012 assert(_version == 3)
3013 _type = reader.read("!B")[0]
3014 assert(_type == 6)
3015 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003016 orig_reader = reader
3017 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003018 obj.xid = reader.read("!L")[0]
3019 obj.datapath_id = reader.read("!Q")[0]
3020 obj.n_buffers = reader.read("!L")[0]
3021 obj.n_tables = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003022 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07003023 obj.capabilities = reader.read("!L")[0]
3024 obj.reserved = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003025 obj.ports = loxi.generic_util.unpack_list(reader, common.port_desc.unpack)
3026 return obj
3027
3028 def __eq__(self, other):
3029 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003030 if self.xid != other.xid: return False
3031 if self.datapath_id != other.datapath_id: return False
3032 if self.n_buffers != other.n_buffers: return False
3033 if self.n_tables != other.n_tables: return False
3034 if self.capabilities != other.capabilities: return False
3035 if self.reserved != other.reserved: return False
3036 if self.ports != other.ports: return False
3037 return True
3038
Rich Lanec2ee4b82013-04-24 17:12:38 -07003039 def pretty_print(self, q):
3040 q.text("features_reply {")
3041 with q.group():
3042 with q.indent(2):
3043 q.breakable()
3044 q.text("xid = ");
3045 if self.xid != None:
3046 q.text("%#x" % self.xid)
3047 else:
3048 q.text('None')
3049 q.text(","); q.breakable()
3050 q.text("datapath_id = ");
3051 q.text("%#x" % self.datapath_id)
3052 q.text(","); q.breakable()
3053 q.text("n_buffers = ");
3054 q.text("%#x" % self.n_buffers)
3055 q.text(","); q.breakable()
3056 q.text("n_tables = ");
3057 q.text("%#x" % self.n_tables)
3058 q.text(","); q.breakable()
3059 q.text("capabilities = ");
3060 q.text("%#x" % self.capabilities)
3061 q.text(","); q.breakable()
3062 q.text("reserved = ");
3063 q.text("%#x" % self.reserved)
3064 q.text(","); q.breakable()
3065 q.text("ports = ");
3066 q.pp(self.ports)
3067 q.breakable()
3068 q.text('}')
3069
Rich Lane7dcdf022013-12-11 14:45:27 -08003070message.subtypes[6] = features_reply
3071
3072class features_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -07003073 version = 3
3074 type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07003075
3076 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003077 if xid != None:
3078 self.xid = xid
3079 else:
3080 self.xid = None
3081 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003082
3083 def pack(self):
3084 packed = []
3085 packed.append(struct.pack("!B", self.version))
3086 packed.append(struct.pack("!B", self.type))
3087 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3088 packed.append(struct.pack("!L", self.xid))
3089 length = sum([len(x) for x in packed])
3090 packed[2] = struct.pack("!H", length)
3091 return ''.join(packed)
3092
3093 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003094 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003095 obj = features_request()
Dan Talaycof6202252013-07-02 01:00:29 -07003096 _version = reader.read("!B")[0]
3097 assert(_version == 3)
3098 _type = reader.read("!B")[0]
3099 assert(_type == 5)
3100 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003101 orig_reader = reader
3102 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003103 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003104 return obj
3105
3106 def __eq__(self, other):
3107 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003108 if self.xid != other.xid: return False
3109 return True
3110
Rich Lanec2ee4b82013-04-24 17:12:38 -07003111 def pretty_print(self, q):
3112 q.text("features_request {")
3113 with q.group():
3114 with q.indent(2):
3115 q.breakable()
3116 q.text("xid = ");
3117 if self.xid != None:
3118 q.text("%#x" % self.xid)
3119 else:
3120 q.text('None')
3121 q.breakable()
3122 q.text('}')
3123
Rich Lane7dcdf022013-12-11 14:45:27 -08003124message.subtypes[5] = features_request
3125
3126class flow_mod(message):
3127 subtypes = {}
3128
3129 @staticmethod
3130 def unpack(reader):
3131 subtype, = reader.peek('B', 25)
3132 try:
3133 subclass = flow_mod.subtypes[subtype]
3134 except KeyError:
3135 raise loxi.ProtocolError("unknown flow_mod message subtype %#x" % subtype)
3136 return subclass.unpack(reader)
3137
3138message.subtypes[14] = flow_mod
3139
3140class flow_add(flow_mod):
Dan Talaycof6202252013-07-02 01:00:29 -07003141 version = 3
3142 type = 14
3143 _command = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07003144
3145 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 -08003146 if xid != None:
3147 self.xid = xid
3148 else:
3149 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003150 if cookie != None:
3151 self.cookie = cookie
3152 else:
3153 self.cookie = 0
3154 if cookie_mask != None:
3155 self.cookie_mask = cookie_mask
3156 else:
3157 self.cookie_mask = 0
3158 if table_id != None:
3159 self.table_id = table_id
3160 else:
3161 self.table_id = 0
3162 if idle_timeout != None:
3163 self.idle_timeout = idle_timeout
3164 else:
3165 self.idle_timeout = 0
3166 if hard_timeout != None:
3167 self.hard_timeout = hard_timeout
3168 else:
3169 self.hard_timeout = 0
3170 if priority != None:
3171 self.priority = priority
3172 else:
3173 self.priority = 0
3174 if buffer_id != None:
3175 self.buffer_id = buffer_id
3176 else:
3177 self.buffer_id = 0
3178 if out_port != None:
3179 self.out_port = out_port
3180 else:
3181 self.out_port = 0
3182 if out_group != None:
3183 self.out_group = out_group
3184 else:
3185 self.out_group = 0
3186 if flags != None:
3187 self.flags = flags
3188 else:
3189 self.flags = 0
3190 if match != None:
3191 self.match = match
3192 else:
3193 self.match = common.match()
3194 if instructions != None:
3195 self.instructions = instructions
3196 else:
3197 self.instructions = []
Rich Lane7dcdf022013-12-11 14:45:27 -08003198 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003199
3200 def pack(self):
3201 packed = []
3202 packed.append(struct.pack("!B", self.version))
3203 packed.append(struct.pack("!B", self.type))
3204 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3205 packed.append(struct.pack("!L", self.xid))
3206 packed.append(struct.pack("!Q", self.cookie))
3207 packed.append(struct.pack("!Q", self.cookie_mask))
3208 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003209 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003210 packed.append(struct.pack("!H", self.idle_timeout))
3211 packed.append(struct.pack("!H", self.hard_timeout))
3212 packed.append(struct.pack("!H", self.priority))
3213 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003214 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003215 packed.append(struct.pack("!L", self.out_group))
3216 packed.append(struct.pack("!H", self.flags))
3217 packed.append('\x00' * 2)
3218 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08003219 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003220 length = sum([len(x) for x in packed])
3221 packed[2] = struct.pack("!H", length)
3222 return ''.join(packed)
3223
3224 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003225 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003226 obj = flow_add()
Dan Talaycof6202252013-07-02 01:00:29 -07003227 _version = reader.read("!B")[0]
3228 assert(_version == 3)
3229 _type = reader.read("!B")[0]
3230 assert(_type == 14)
3231 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003232 orig_reader = reader
3233 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003234 obj.xid = reader.read("!L")[0]
3235 obj.cookie = reader.read("!Q")[0]
3236 obj.cookie_mask = reader.read("!Q")[0]
3237 obj.table_id = reader.read("!B")[0]
3238 __command = util.unpack_fm_cmd(reader)
3239 assert(__command == 0)
3240 obj.idle_timeout = reader.read("!H")[0]
3241 obj.hard_timeout = reader.read("!H")[0]
3242 obj.priority = reader.read("!H")[0]
3243 obj.buffer_id = reader.read("!L")[0]
3244 obj.out_port = util.unpack_port_no(reader)
3245 obj.out_group = reader.read("!L")[0]
3246 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003247 reader.skip(2)
3248 obj.match = common.match.unpack(reader)
Rich Lane7dcdf022013-12-11 14:45:27 -08003249 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003250 return obj
3251
3252 def __eq__(self, other):
3253 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003254 if self.xid != other.xid: return False
3255 if self.cookie != other.cookie: return False
3256 if self.cookie_mask != other.cookie_mask: return False
3257 if self.table_id != other.table_id: return False
3258 if self.idle_timeout != other.idle_timeout: return False
3259 if self.hard_timeout != other.hard_timeout: return False
3260 if self.priority != other.priority: return False
3261 if self.buffer_id != other.buffer_id: return False
3262 if self.out_port != other.out_port: return False
3263 if self.out_group != other.out_group: return False
3264 if self.flags != other.flags: return False
3265 if self.match != other.match: return False
3266 if self.instructions != other.instructions: return False
3267 return True
3268
Rich Lanec2ee4b82013-04-24 17:12:38 -07003269 def pretty_print(self, q):
3270 q.text("flow_add {")
3271 with q.group():
3272 with q.indent(2):
3273 q.breakable()
3274 q.text("xid = ");
3275 if self.xid != None:
3276 q.text("%#x" % self.xid)
3277 else:
3278 q.text('None')
3279 q.text(","); q.breakable()
3280 q.text("cookie = ");
3281 q.text("%#x" % self.cookie)
3282 q.text(","); q.breakable()
3283 q.text("cookie_mask = ");
3284 q.text("%#x" % self.cookie_mask)
3285 q.text(","); q.breakable()
3286 q.text("table_id = ");
3287 q.text("%#x" % self.table_id)
3288 q.text(","); q.breakable()
3289 q.text("idle_timeout = ");
3290 q.text("%#x" % self.idle_timeout)
3291 q.text(","); q.breakable()
3292 q.text("hard_timeout = ");
3293 q.text("%#x" % self.hard_timeout)
3294 q.text(","); q.breakable()
3295 q.text("priority = ");
3296 q.text("%#x" % self.priority)
3297 q.text(","); q.breakable()
3298 q.text("buffer_id = ");
3299 q.text("%#x" % self.buffer_id)
3300 q.text(","); q.breakable()
3301 q.text("out_port = ");
3302 q.text(util.pretty_port(self.out_port))
3303 q.text(","); q.breakable()
3304 q.text("out_group = ");
3305 q.text("%#x" % self.out_group)
3306 q.text(","); q.breakable()
3307 q.text("flags = ");
3308 q.text("%#x" % self.flags)
3309 q.text(","); q.breakable()
3310 q.text("match = ");
3311 q.pp(self.match)
3312 q.text(","); q.breakable()
3313 q.text("instructions = ");
3314 q.pp(self.instructions)
3315 q.breakable()
3316 q.text('}')
3317
Rich Lane7dcdf022013-12-11 14:45:27 -08003318flow_mod.subtypes[0] = flow_add
3319
3320class flow_delete(flow_mod):
Dan Talaycof6202252013-07-02 01:00:29 -07003321 version = 3
3322 type = 14
3323 _command = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07003324
3325 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 -08003326 if xid != None:
3327 self.xid = xid
3328 else:
3329 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003330 if cookie != None:
3331 self.cookie = cookie
3332 else:
3333 self.cookie = 0
3334 if cookie_mask != None:
3335 self.cookie_mask = cookie_mask
3336 else:
3337 self.cookie_mask = 0
3338 if table_id != None:
3339 self.table_id = table_id
3340 else:
3341 self.table_id = 0
3342 if idle_timeout != None:
3343 self.idle_timeout = idle_timeout
3344 else:
3345 self.idle_timeout = 0
3346 if hard_timeout != None:
3347 self.hard_timeout = hard_timeout
3348 else:
3349 self.hard_timeout = 0
3350 if priority != None:
3351 self.priority = priority
3352 else:
3353 self.priority = 0
3354 if buffer_id != None:
3355 self.buffer_id = buffer_id
3356 else:
3357 self.buffer_id = 0
3358 if out_port != None:
3359 self.out_port = out_port
3360 else:
3361 self.out_port = 0
3362 if out_group != None:
3363 self.out_group = out_group
3364 else:
3365 self.out_group = 0
3366 if flags != None:
3367 self.flags = flags
3368 else:
3369 self.flags = 0
3370 if match != None:
3371 self.match = match
3372 else:
3373 self.match = common.match()
3374 if instructions != None:
3375 self.instructions = instructions
3376 else:
3377 self.instructions = []
Rich Lane7dcdf022013-12-11 14:45:27 -08003378 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003379
3380 def pack(self):
3381 packed = []
3382 packed.append(struct.pack("!B", self.version))
3383 packed.append(struct.pack("!B", self.type))
3384 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3385 packed.append(struct.pack("!L", self.xid))
3386 packed.append(struct.pack("!Q", self.cookie))
3387 packed.append(struct.pack("!Q", self.cookie_mask))
3388 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003389 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003390 packed.append(struct.pack("!H", self.idle_timeout))
3391 packed.append(struct.pack("!H", self.hard_timeout))
3392 packed.append(struct.pack("!H", self.priority))
3393 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003394 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003395 packed.append(struct.pack("!L", self.out_group))
3396 packed.append(struct.pack("!H", self.flags))
3397 packed.append('\x00' * 2)
3398 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08003399 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003400 length = sum([len(x) for x in packed])
3401 packed[2] = struct.pack("!H", length)
3402 return ''.join(packed)
3403
3404 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003405 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003406 obj = flow_delete()
Dan Talaycof6202252013-07-02 01:00:29 -07003407 _version = reader.read("!B")[0]
3408 assert(_version == 3)
3409 _type = reader.read("!B")[0]
3410 assert(_type == 14)
3411 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003412 orig_reader = reader
3413 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003414 obj.xid = reader.read("!L")[0]
3415 obj.cookie = reader.read("!Q")[0]
3416 obj.cookie_mask = reader.read("!Q")[0]
3417 obj.table_id = reader.read("!B")[0]
3418 __command = util.unpack_fm_cmd(reader)
3419 assert(__command == 3)
3420 obj.idle_timeout = reader.read("!H")[0]
3421 obj.hard_timeout = reader.read("!H")[0]
3422 obj.priority = reader.read("!H")[0]
3423 obj.buffer_id = reader.read("!L")[0]
3424 obj.out_port = util.unpack_port_no(reader)
3425 obj.out_group = reader.read("!L")[0]
3426 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003427 reader.skip(2)
3428 obj.match = common.match.unpack(reader)
Rich Lane7dcdf022013-12-11 14:45:27 -08003429 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003430 return obj
3431
3432 def __eq__(self, other):
3433 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003434 if self.xid != other.xid: return False
3435 if self.cookie != other.cookie: return False
3436 if self.cookie_mask != other.cookie_mask: return False
3437 if self.table_id != other.table_id: return False
3438 if self.idle_timeout != other.idle_timeout: return False
3439 if self.hard_timeout != other.hard_timeout: return False
3440 if self.priority != other.priority: return False
3441 if self.buffer_id != other.buffer_id: return False
3442 if self.out_port != other.out_port: return False
3443 if self.out_group != other.out_group: return False
3444 if self.flags != other.flags: return False
3445 if self.match != other.match: return False
3446 if self.instructions != other.instructions: return False
3447 return True
3448
Rich Lanec2ee4b82013-04-24 17:12:38 -07003449 def pretty_print(self, q):
3450 q.text("flow_delete {")
3451 with q.group():
3452 with q.indent(2):
3453 q.breakable()
3454 q.text("xid = ");
3455 if self.xid != None:
3456 q.text("%#x" % self.xid)
3457 else:
3458 q.text('None')
3459 q.text(","); q.breakable()
3460 q.text("cookie = ");
3461 q.text("%#x" % self.cookie)
3462 q.text(","); q.breakable()
3463 q.text("cookie_mask = ");
3464 q.text("%#x" % self.cookie_mask)
3465 q.text(","); q.breakable()
3466 q.text("table_id = ");
3467 q.text("%#x" % self.table_id)
3468 q.text(","); q.breakable()
3469 q.text("idle_timeout = ");
3470 q.text("%#x" % self.idle_timeout)
3471 q.text(","); q.breakable()
3472 q.text("hard_timeout = ");
3473 q.text("%#x" % self.hard_timeout)
3474 q.text(","); q.breakable()
3475 q.text("priority = ");
3476 q.text("%#x" % self.priority)
3477 q.text(","); q.breakable()
3478 q.text("buffer_id = ");
3479 q.text("%#x" % self.buffer_id)
3480 q.text(","); q.breakable()
3481 q.text("out_port = ");
3482 q.text(util.pretty_port(self.out_port))
3483 q.text(","); q.breakable()
3484 q.text("out_group = ");
3485 q.text("%#x" % self.out_group)
3486 q.text(","); q.breakable()
3487 q.text("flags = ");
3488 q.text("%#x" % self.flags)
3489 q.text(","); q.breakable()
3490 q.text("match = ");
3491 q.pp(self.match)
3492 q.text(","); q.breakable()
3493 q.text("instructions = ");
3494 q.pp(self.instructions)
3495 q.breakable()
3496 q.text('}')
3497
Rich Lane7dcdf022013-12-11 14:45:27 -08003498flow_mod.subtypes[3] = flow_delete
3499
3500class flow_delete_strict(flow_mod):
Dan Talaycof6202252013-07-02 01:00:29 -07003501 version = 3
3502 type = 14
3503 _command = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07003504
3505 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 -08003506 if xid != None:
3507 self.xid = xid
3508 else:
3509 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003510 if cookie != None:
3511 self.cookie = cookie
3512 else:
3513 self.cookie = 0
3514 if cookie_mask != None:
3515 self.cookie_mask = cookie_mask
3516 else:
3517 self.cookie_mask = 0
3518 if table_id != None:
3519 self.table_id = table_id
3520 else:
3521 self.table_id = 0
3522 if idle_timeout != None:
3523 self.idle_timeout = idle_timeout
3524 else:
3525 self.idle_timeout = 0
3526 if hard_timeout != None:
3527 self.hard_timeout = hard_timeout
3528 else:
3529 self.hard_timeout = 0
3530 if priority != None:
3531 self.priority = priority
3532 else:
3533 self.priority = 0
3534 if buffer_id != None:
3535 self.buffer_id = buffer_id
3536 else:
3537 self.buffer_id = 0
3538 if out_port != None:
3539 self.out_port = out_port
3540 else:
3541 self.out_port = 0
3542 if out_group != None:
3543 self.out_group = out_group
3544 else:
3545 self.out_group = 0
3546 if flags != None:
3547 self.flags = flags
3548 else:
3549 self.flags = 0
3550 if match != None:
3551 self.match = match
3552 else:
3553 self.match = common.match()
3554 if instructions != None:
3555 self.instructions = instructions
3556 else:
3557 self.instructions = []
Rich Lane7dcdf022013-12-11 14:45:27 -08003558 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003559
3560 def pack(self):
3561 packed = []
3562 packed.append(struct.pack("!B", self.version))
3563 packed.append(struct.pack("!B", self.type))
3564 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3565 packed.append(struct.pack("!L", self.xid))
3566 packed.append(struct.pack("!Q", self.cookie))
3567 packed.append(struct.pack("!Q", self.cookie_mask))
3568 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003569 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003570 packed.append(struct.pack("!H", self.idle_timeout))
3571 packed.append(struct.pack("!H", self.hard_timeout))
3572 packed.append(struct.pack("!H", self.priority))
3573 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003574 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003575 packed.append(struct.pack("!L", self.out_group))
3576 packed.append(struct.pack("!H", self.flags))
3577 packed.append('\x00' * 2)
3578 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08003579 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003580 length = sum([len(x) for x in packed])
3581 packed[2] = struct.pack("!H", length)
3582 return ''.join(packed)
3583
3584 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003585 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003586 obj = flow_delete_strict()
Dan Talaycof6202252013-07-02 01:00:29 -07003587 _version = reader.read("!B")[0]
3588 assert(_version == 3)
3589 _type = reader.read("!B")[0]
3590 assert(_type == 14)
3591 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003592 orig_reader = reader
3593 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003594 obj.xid = reader.read("!L")[0]
3595 obj.cookie = reader.read("!Q")[0]
3596 obj.cookie_mask = reader.read("!Q")[0]
3597 obj.table_id = reader.read("!B")[0]
3598 __command = util.unpack_fm_cmd(reader)
3599 assert(__command == 4)
3600 obj.idle_timeout = reader.read("!H")[0]
3601 obj.hard_timeout = reader.read("!H")[0]
3602 obj.priority = reader.read("!H")[0]
3603 obj.buffer_id = reader.read("!L")[0]
3604 obj.out_port = util.unpack_port_no(reader)
3605 obj.out_group = reader.read("!L")[0]
3606 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003607 reader.skip(2)
3608 obj.match = common.match.unpack(reader)
Rich Lane7dcdf022013-12-11 14:45:27 -08003609 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003610 return obj
3611
3612 def __eq__(self, other):
3613 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003614 if self.xid != other.xid: return False
3615 if self.cookie != other.cookie: return False
3616 if self.cookie_mask != other.cookie_mask: return False
3617 if self.table_id != other.table_id: return False
3618 if self.idle_timeout != other.idle_timeout: return False
3619 if self.hard_timeout != other.hard_timeout: return False
3620 if self.priority != other.priority: return False
3621 if self.buffer_id != other.buffer_id: return False
3622 if self.out_port != other.out_port: return False
3623 if self.out_group != other.out_group: return False
3624 if self.flags != other.flags: return False
3625 if self.match != other.match: return False
3626 if self.instructions != other.instructions: return False
3627 return True
3628
Rich Lanec2ee4b82013-04-24 17:12:38 -07003629 def pretty_print(self, q):
3630 q.text("flow_delete_strict {")
3631 with q.group():
3632 with q.indent(2):
3633 q.breakable()
3634 q.text("xid = ");
3635 if self.xid != None:
3636 q.text("%#x" % self.xid)
3637 else:
3638 q.text('None')
3639 q.text(","); q.breakable()
3640 q.text("cookie = ");
3641 q.text("%#x" % self.cookie)
3642 q.text(","); q.breakable()
3643 q.text("cookie_mask = ");
3644 q.text("%#x" % self.cookie_mask)
3645 q.text(","); q.breakable()
3646 q.text("table_id = ");
3647 q.text("%#x" % self.table_id)
3648 q.text(","); q.breakable()
3649 q.text("idle_timeout = ");
3650 q.text("%#x" % self.idle_timeout)
3651 q.text(","); q.breakable()
3652 q.text("hard_timeout = ");
3653 q.text("%#x" % self.hard_timeout)
3654 q.text(","); q.breakable()
3655 q.text("priority = ");
3656 q.text("%#x" % self.priority)
3657 q.text(","); q.breakable()
3658 q.text("buffer_id = ");
3659 q.text("%#x" % self.buffer_id)
3660 q.text(","); q.breakable()
3661 q.text("out_port = ");
3662 q.text(util.pretty_port(self.out_port))
3663 q.text(","); q.breakable()
3664 q.text("out_group = ");
3665 q.text("%#x" % self.out_group)
3666 q.text(","); q.breakable()
3667 q.text("flags = ");
3668 q.text("%#x" % self.flags)
3669 q.text(","); q.breakable()
3670 q.text("match = ");
3671 q.pp(self.match)
3672 q.text(","); q.breakable()
3673 q.text("instructions = ");
3674 q.pp(self.instructions)
3675 q.breakable()
3676 q.text('}')
3677
Rich Lane7dcdf022013-12-11 14:45:27 -08003678flow_mod.subtypes[4] = flow_delete_strict
3679
3680class flow_mod_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07003681 version = 3
3682 type = 1
3683 err_type = 5
3684
3685 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003686 if xid != None:
3687 self.xid = xid
3688 else:
3689 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07003690 if code != None:
3691 self.code = code
3692 else:
3693 self.code = 0
3694 if data != None:
3695 self.data = data
3696 else:
3697 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08003698 return
Rich Lane6f4978c2013-10-20 21:33:52 -07003699
3700 def pack(self):
3701 packed = []
3702 packed.append(struct.pack("!B", self.version))
3703 packed.append(struct.pack("!B", self.type))
3704 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3705 packed.append(struct.pack("!L", self.xid))
3706 packed.append(struct.pack("!H", self.err_type))
3707 packed.append(struct.pack("!H", self.code))
3708 packed.append(self.data)
3709 length = sum([len(x) for x in packed])
3710 packed[2] = struct.pack("!H", length)
3711 return ''.join(packed)
3712
3713 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003714 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07003715 obj = flow_mod_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07003716 _version = reader.read("!B")[0]
3717 assert(_version == 3)
3718 _type = reader.read("!B")[0]
3719 assert(_type == 1)
3720 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003721 orig_reader = reader
3722 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07003723 obj.xid = reader.read("!L")[0]
3724 _err_type = reader.read("!H")[0]
3725 assert(_err_type == 5)
3726 obj.code = reader.read("!H")[0]
3727 obj.data = str(reader.read_all())
3728 return obj
3729
3730 def __eq__(self, other):
3731 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07003732 if self.xid != other.xid: return False
3733 if self.code != other.code: return False
3734 if self.data != other.data: return False
3735 return True
3736
Rich Lane6f4978c2013-10-20 21:33:52 -07003737 def pretty_print(self, q):
3738 q.text("flow_mod_failed_error_msg {")
3739 with q.group():
3740 with q.indent(2):
3741 q.breakable()
3742 q.text("xid = ");
3743 if self.xid != None:
3744 q.text("%#x" % self.xid)
3745 else:
3746 q.text('None')
3747 q.text(","); q.breakable()
3748 q.text("code = ");
3749 q.text("%#x" % self.code)
3750 q.text(","); q.breakable()
3751 q.text("data = ");
3752 q.pp(self.data)
3753 q.breakable()
3754 q.text('}')
3755
Rich Lane7dcdf022013-12-11 14:45:27 -08003756error_msg.subtypes[5] = flow_mod_failed_error_msg
3757
3758class flow_modify(flow_mod):
Dan Talaycof6202252013-07-02 01:00:29 -07003759 version = 3
3760 type = 14
3761 _command = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07003762
3763 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 -08003764 if xid != None:
3765 self.xid = xid
3766 else:
3767 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003768 if cookie != None:
3769 self.cookie = cookie
3770 else:
3771 self.cookie = 0
3772 if cookie_mask != None:
3773 self.cookie_mask = cookie_mask
3774 else:
3775 self.cookie_mask = 0
3776 if table_id != None:
3777 self.table_id = table_id
3778 else:
3779 self.table_id = 0
3780 if idle_timeout != None:
3781 self.idle_timeout = idle_timeout
3782 else:
3783 self.idle_timeout = 0
3784 if hard_timeout != None:
3785 self.hard_timeout = hard_timeout
3786 else:
3787 self.hard_timeout = 0
3788 if priority != None:
3789 self.priority = priority
3790 else:
3791 self.priority = 0
3792 if buffer_id != None:
3793 self.buffer_id = buffer_id
3794 else:
3795 self.buffer_id = 0
3796 if out_port != None:
3797 self.out_port = out_port
3798 else:
3799 self.out_port = 0
3800 if out_group != None:
3801 self.out_group = out_group
3802 else:
3803 self.out_group = 0
3804 if flags != None:
3805 self.flags = flags
3806 else:
3807 self.flags = 0
3808 if match != None:
3809 self.match = match
3810 else:
3811 self.match = common.match()
3812 if instructions != None:
3813 self.instructions = instructions
3814 else:
3815 self.instructions = []
Rich Lane7dcdf022013-12-11 14:45:27 -08003816 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003817
3818 def pack(self):
3819 packed = []
3820 packed.append(struct.pack("!B", self.version))
3821 packed.append(struct.pack("!B", self.type))
3822 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3823 packed.append(struct.pack("!L", self.xid))
3824 packed.append(struct.pack("!Q", self.cookie))
3825 packed.append(struct.pack("!Q", self.cookie_mask))
3826 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003827 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003828 packed.append(struct.pack("!H", self.idle_timeout))
3829 packed.append(struct.pack("!H", self.hard_timeout))
3830 packed.append(struct.pack("!H", self.priority))
3831 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003832 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003833 packed.append(struct.pack("!L", self.out_group))
3834 packed.append(struct.pack("!H", self.flags))
3835 packed.append('\x00' * 2)
3836 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08003837 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003838 length = sum([len(x) for x in packed])
3839 packed[2] = struct.pack("!H", length)
3840 return ''.join(packed)
3841
3842 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003843 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003844 obj = flow_modify()
Dan Talaycof6202252013-07-02 01:00:29 -07003845 _version = reader.read("!B")[0]
3846 assert(_version == 3)
3847 _type = reader.read("!B")[0]
3848 assert(_type == 14)
3849 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003850 orig_reader = reader
3851 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003852 obj.xid = reader.read("!L")[0]
3853 obj.cookie = reader.read("!Q")[0]
3854 obj.cookie_mask = reader.read("!Q")[0]
3855 obj.table_id = reader.read("!B")[0]
3856 __command = util.unpack_fm_cmd(reader)
3857 assert(__command == 1)
3858 obj.idle_timeout = reader.read("!H")[0]
3859 obj.hard_timeout = reader.read("!H")[0]
3860 obj.priority = reader.read("!H")[0]
3861 obj.buffer_id = reader.read("!L")[0]
3862 obj.out_port = util.unpack_port_no(reader)
3863 obj.out_group = reader.read("!L")[0]
3864 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003865 reader.skip(2)
3866 obj.match = common.match.unpack(reader)
Rich Lane7dcdf022013-12-11 14:45:27 -08003867 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003868 return obj
3869
3870 def __eq__(self, other):
3871 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003872 if self.xid != other.xid: return False
3873 if self.cookie != other.cookie: return False
3874 if self.cookie_mask != other.cookie_mask: return False
3875 if self.table_id != other.table_id: return False
3876 if self.idle_timeout != other.idle_timeout: return False
3877 if self.hard_timeout != other.hard_timeout: return False
3878 if self.priority != other.priority: return False
3879 if self.buffer_id != other.buffer_id: return False
3880 if self.out_port != other.out_port: return False
3881 if self.out_group != other.out_group: return False
3882 if self.flags != other.flags: return False
3883 if self.match != other.match: return False
3884 if self.instructions != other.instructions: return False
3885 return True
3886
Rich Lanec2ee4b82013-04-24 17:12:38 -07003887 def pretty_print(self, q):
3888 q.text("flow_modify {")
3889 with q.group():
3890 with q.indent(2):
3891 q.breakable()
3892 q.text("xid = ");
3893 if self.xid != None:
3894 q.text("%#x" % self.xid)
3895 else:
3896 q.text('None')
3897 q.text(","); q.breakable()
3898 q.text("cookie = ");
3899 q.text("%#x" % self.cookie)
3900 q.text(","); q.breakable()
3901 q.text("cookie_mask = ");
3902 q.text("%#x" % self.cookie_mask)
3903 q.text(","); q.breakable()
3904 q.text("table_id = ");
3905 q.text("%#x" % self.table_id)
3906 q.text(","); q.breakable()
3907 q.text("idle_timeout = ");
3908 q.text("%#x" % self.idle_timeout)
3909 q.text(","); q.breakable()
3910 q.text("hard_timeout = ");
3911 q.text("%#x" % self.hard_timeout)
3912 q.text(","); q.breakable()
3913 q.text("priority = ");
3914 q.text("%#x" % self.priority)
3915 q.text(","); q.breakable()
3916 q.text("buffer_id = ");
3917 q.text("%#x" % self.buffer_id)
3918 q.text(","); q.breakable()
3919 q.text("out_port = ");
3920 q.text(util.pretty_port(self.out_port))
3921 q.text(","); q.breakable()
3922 q.text("out_group = ");
3923 q.text("%#x" % self.out_group)
3924 q.text(","); q.breakable()
3925 q.text("flags = ");
3926 q.text("%#x" % self.flags)
3927 q.text(","); q.breakable()
3928 q.text("match = ");
3929 q.pp(self.match)
3930 q.text(","); q.breakable()
3931 q.text("instructions = ");
3932 q.pp(self.instructions)
3933 q.breakable()
3934 q.text('}')
3935
Rich Lane7dcdf022013-12-11 14:45:27 -08003936flow_mod.subtypes[1] = flow_modify
3937
3938class flow_modify_strict(flow_mod):
Dan Talaycof6202252013-07-02 01:00:29 -07003939 version = 3
3940 type = 14
3941 _command = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07003942
3943 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 -08003944 if xid != None:
3945 self.xid = xid
3946 else:
3947 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003948 if cookie != None:
3949 self.cookie = cookie
3950 else:
3951 self.cookie = 0
3952 if cookie_mask != None:
3953 self.cookie_mask = cookie_mask
3954 else:
3955 self.cookie_mask = 0
3956 if table_id != None:
3957 self.table_id = table_id
3958 else:
3959 self.table_id = 0
3960 if idle_timeout != None:
3961 self.idle_timeout = idle_timeout
3962 else:
3963 self.idle_timeout = 0
3964 if hard_timeout != None:
3965 self.hard_timeout = hard_timeout
3966 else:
3967 self.hard_timeout = 0
3968 if priority != None:
3969 self.priority = priority
3970 else:
3971 self.priority = 0
3972 if buffer_id != None:
3973 self.buffer_id = buffer_id
3974 else:
3975 self.buffer_id = 0
3976 if out_port != None:
3977 self.out_port = out_port
3978 else:
3979 self.out_port = 0
3980 if out_group != None:
3981 self.out_group = out_group
3982 else:
3983 self.out_group = 0
3984 if flags != None:
3985 self.flags = flags
3986 else:
3987 self.flags = 0
3988 if match != None:
3989 self.match = match
3990 else:
3991 self.match = common.match()
3992 if instructions != None:
3993 self.instructions = instructions
3994 else:
3995 self.instructions = []
Rich Lane7dcdf022013-12-11 14:45:27 -08003996 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003997
3998 def pack(self):
3999 packed = []
4000 packed.append(struct.pack("!B", self.version))
4001 packed.append(struct.pack("!B", self.type))
4002 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4003 packed.append(struct.pack("!L", self.xid))
4004 packed.append(struct.pack("!Q", self.cookie))
4005 packed.append(struct.pack("!Q", self.cookie_mask))
4006 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004007 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004008 packed.append(struct.pack("!H", self.idle_timeout))
4009 packed.append(struct.pack("!H", self.hard_timeout))
4010 packed.append(struct.pack("!H", self.priority))
4011 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004012 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004013 packed.append(struct.pack("!L", self.out_group))
4014 packed.append(struct.pack("!H", self.flags))
4015 packed.append('\x00' * 2)
4016 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08004017 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004018 length = sum([len(x) for x in packed])
4019 packed[2] = struct.pack("!H", length)
4020 return ''.join(packed)
4021
4022 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004023 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004024 obj = flow_modify_strict()
Dan Talaycof6202252013-07-02 01:00:29 -07004025 _version = reader.read("!B")[0]
4026 assert(_version == 3)
4027 _type = reader.read("!B")[0]
4028 assert(_type == 14)
4029 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004030 orig_reader = reader
4031 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07004032 obj.xid = reader.read("!L")[0]
4033 obj.cookie = reader.read("!Q")[0]
4034 obj.cookie_mask = reader.read("!Q")[0]
4035 obj.table_id = reader.read("!B")[0]
4036 __command = util.unpack_fm_cmd(reader)
4037 assert(__command == 2)
4038 obj.idle_timeout = reader.read("!H")[0]
4039 obj.hard_timeout = reader.read("!H")[0]
4040 obj.priority = reader.read("!H")[0]
4041 obj.buffer_id = reader.read("!L")[0]
4042 obj.out_port = util.unpack_port_no(reader)
4043 obj.out_group = reader.read("!L")[0]
4044 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004045 reader.skip(2)
4046 obj.match = common.match.unpack(reader)
Rich Lane7dcdf022013-12-11 14:45:27 -08004047 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07004048 return obj
4049
4050 def __eq__(self, other):
4051 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004052 if self.xid != other.xid: return False
4053 if self.cookie != other.cookie: return False
4054 if self.cookie_mask != other.cookie_mask: return False
4055 if self.table_id != other.table_id: return False
4056 if self.idle_timeout != other.idle_timeout: return False
4057 if self.hard_timeout != other.hard_timeout: return False
4058 if self.priority != other.priority: return False
4059 if self.buffer_id != other.buffer_id: return False
4060 if self.out_port != other.out_port: return False
4061 if self.out_group != other.out_group: return False
4062 if self.flags != other.flags: return False
4063 if self.match != other.match: return False
4064 if self.instructions != other.instructions: return False
4065 return True
4066
Rich Lanec2ee4b82013-04-24 17:12:38 -07004067 def pretty_print(self, q):
4068 q.text("flow_modify_strict {")
4069 with q.group():
4070 with q.indent(2):
4071 q.breakable()
4072 q.text("xid = ");
4073 if self.xid != None:
4074 q.text("%#x" % self.xid)
4075 else:
4076 q.text('None')
4077 q.text(","); q.breakable()
4078 q.text("cookie = ");
4079 q.text("%#x" % self.cookie)
4080 q.text(","); q.breakable()
4081 q.text("cookie_mask = ");
4082 q.text("%#x" % self.cookie_mask)
4083 q.text(","); q.breakable()
4084 q.text("table_id = ");
4085 q.text("%#x" % self.table_id)
4086 q.text(","); q.breakable()
4087 q.text("idle_timeout = ");
4088 q.text("%#x" % self.idle_timeout)
4089 q.text(","); q.breakable()
4090 q.text("hard_timeout = ");
4091 q.text("%#x" % self.hard_timeout)
4092 q.text(","); q.breakable()
4093 q.text("priority = ");
4094 q.text("%#x" % self.priority)
4095 q.text(","); q.breakable()
4096 q.text("buffer_id = ");
4097 q.text("%#x" % self.buffer_id)
4098 q.text(","); q.breakable()
4099 q.text("out_port = ");
4100 q.text(util.pretty_port(self.out_port))
4101 q.text(","); q.breakable()
4102 q.text("out_group = ");
4103 q.text("%#x" % self.out_group)
4104 q.text(","); q.breakable()
4105 q.text("flags = ");
4106 q.text("%#x" % self.flags)
4107 q.text(","); q.breakable()
4108 q.text("match = ");
4109 q.pp(self.match)
4110 q.text(","); q.breakable()
4111 q.text("instructions = ");
4112 q.pp(self.instructions)
4113 q.breakable()
4114 q.text('}')
4115
Rich Lane7dcdf022013-12-11 14:45:27 -08004116flow_mod.subtypes[2] = flow_modify_strict
4117
4118class flow_removed(message):
Dan Talaycof6202252013-07-02 01:00:29 -07004119 version = 3
4120 type = 11
Rich Lanec2ee4b82013-04-24 17:12:38 -07004121
4122 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 -08004123 if xid != None:
4124 self.xid = xid
4125 else:
4126 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004127 if cookie != None:
4128 self.cookie = cookie
4129 else:
4130 self.cookie = 0
4131 if priority != None:
4132 self.priority = priority
4133 else:
4134 self.priority = 0
4135 if reason != None:
4136 self.reason = reason
4137 else:
4138 self.reason = 0
4139 if table_id != None:
4140 self.table_id = table_id
4141 else:
4142 self.table_id = 0
4143 if duration_sec != None:
4144 self.duration_sec = duration_sec
4145 else:
4146 self.duration_sec = 0
4147 if duration_nsec != None:
4148 self.duration_nsec = duration_nsec
4149 else:
4150 self.duration_nsec = 0
4151 if idle_timeout != None:
4152 self.idle_timeout = idle_timeout
4153 else:
4154 self.idle_timeout = 0
4155 if hard_timeout != None:
4156 self.hard_timeout = hard_timeout
4157 else:
4158 self.hard_timeout = 0
4159 if packet_count != None:
4160 self.packet_count = packet_count
4161 else:
4162 self.packet_count = 0
4163 if byte_count != None:
4164 self.byte_count = byte_count
4165 else:
4166 self.byte_count = 0
4167 if match != None:
4168 self.match = match
4169 else:
4170 self.match = common.match()
Rich Lane7dcdf022013-12-11 14:45:27 -08004171 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004172
4173 def pack(self):
4174 packed = []
4175 packed.append(struct.pack("!B", self.version))
4176 packed.append(struct.pack("!B", self.type))
4177 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4178 packed.append(struct.pack("!L", self.xid))
4179 packed.append(struct.pack("!Q", self.cookie))
4180 packed.append(struct.pack("!H", self.priority))
4181 packed.append(struct.pack("!B", self.reason))
4182 packed.append(struct.pack("!B", self.table_id))
4183 packed.append(struct.pack("!L", self.duration_sec))
4184 packed.append(struct.pack("!L", self.duration_nsec))
4185 packed.append(struct.pack("!H", self.idle_timeout))
4186 packed.append(struct.pack("!H", self.hard_timeout))
4187 packed.append(struct.pack("!Q", self.packet_count))
4188 packed.append(struct.pack("!Q", self.byte_count))
4189 packed.append(self.match.pack())
4190 length = sum([len(x) for x in packed])
4191 packed[2] = struct.pack("!H", length)
4192 return ''.join(packed)
4193
4194 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004195 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004196 obj = flow_removed()
Dan Talaycof6202252013-07-02 01:00:29 -07004197 _version = reader.read("!B")[0]
4198 assert(_version == 3)
4199 _type = reader.read("!B")[0]
4200 assert(_type == 11)
4201 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004202 orig_reader = reader
4203 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07004204 obj.xid = reader.read("!L")[0]
4205 obj.cookie = reader.read("!Q")[0]
4206 obj.priority = reader.read("!H")[0]
4207 obj.reason = reader.read("!B")[0]
4208 obj.table_id = reader.read("!B")[0]
4209 obj.duration_sec = reader.read("!L")[0]
4210 obj.duration_nsec = reader.read("!L")[0]
4211 obj.idle_timeout = reader.read("!H")[0]
4212 obj.hard_timeout = reader.read("!H")[0]
4213 obj.packet_count = reader.read("!Q")[0]
4214 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004215 obj.match = common.match.unpack(reader)
4216 return obj
4217
4218 def __eq__(self, other):
4219 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004220 if self.xid != other.xid: return False
4221 if self.cookie != other.cookie: return False
4222 if self.priority != other.priority: return False
4223 if self.reason != other.reason: return False
4224 if self.table_id != other.table_id: return False
4225 if self.duration_sec != other.duration_sec: return False
4226 if self.duration_nsec != other.duration_nsec: return False
4227 if self.idle_timeout != other.idle_timeout: return False
4228 if self.hard_timeout != other.hard_timeout: return False
4229 if self.packet_count != other.packet_count: return False
4230 if self.byte_count != other.byte_count: return False
4231 if self.match != other.match: return False
4232 return True
4233
Rich Lanec2ee4b82013-04-24 17:12:38 -07004234 def pretty_print(self, q):
4235 q.text("flow_removed {")
4236 with q.group():
4237 with q.indent(2):
4238 q.breakable()
4239 q.text("xid = ");
4240 if self.xid != None:
4241 q.text("%#x" % self.xid)
4242 else:
4243 q.text('None')
4244 q.text(","); q.breakable()
4245 q.text("cookie = ");
4246 q.text("%#x" % self.cookie)
4247 q.text(","); q.breakable()
4248 q.text("priority = ");
4249 q.text("%#x" % self.priority)
4250 q.text(","); q.breakable()
4251 q.text("reason = ");
4252 q.text("%#x" % self.reason)
4253 q.text(","); q.breakable()
4254 q.text("table_id = ");
4255 q.text("%#x" % self.table_id)
4256 q.text(","); q.breakable()
4257 q.text("duration_sec = ");
4258 q.text("%#x" % self.duration_sec)
4259 q.text(","); q.breakable()
4260 q.text("duration_nsec = ");
4261 q.text("%#x" % self.duration_nsec)
4262 q.text(","); q.breakable()
4263 q.text("idle_timeout = ");
4264 q.text("%#x" % self.idle_timeout)
4265 q.text(","); q.breakable()
4266 q.text("hard_timeout = ");
4267 q.text("%#x" % self.hard_timeout)
4268 q.text(","); q.breakable()
4269 q.text("packet_count = ");
4270 q.text("%#x" % self.packet_count)
4271 q.text(","); q.breakable()
4272 q.text("byte_count = ");
4273 q.text("%#x" % self.byte_count)
4274 q.text(","); q.breakable()
4275 q.text("match = ");
4276 q.pp(self.match)
4277 q.breakable()
4278 q.text('}')
4279
Rich Lane7dcdf022013-12-11 14:45:27 -08004280message.subtypes[11] = flow_removed
4281
4282class flow_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07004283 version = 3
4284 type = 19
4285 stats_type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07004286
4287 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08004288 if xid != None:
4289 self.xid = xid
4290 else:
4291 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004292 if flags != None:
4293 self.flags = flags
4294 else:
4295 self.flags = 0
4296 if entries != None:
4297 self.entries = entries
4298 else:
4299 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08004300 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004301
4302 def pack(self):
4303 packed = []
4304 packed.append(struct.pack("!B", self.version))
4305 packed.append(struct.pack("!B", self.type))
4306 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4307 packed.append(struct.pack("!L", self.xid))
4308 packed.append(struct.pack("!H", self.stats_type))
4309 packed.append(struct.pack("!H", self.flags))
4310 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08004311 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004312 length = sum([len(x) for x in packed])
4313 packed[2] = struct.pack("!H", length)
4314 return ''.join(packed)
4315
4316 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004317 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004318 obj = flow_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07004319 _version = reader.read("!B")[0]
4320 assert(_version == 3)
4321 _type = reader.read("!B")[0]
4322 assert(_type == 19)
4323 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004324 orig_reader = reader
4325 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07004326 obj.xid = reader.read("!L")[0]
4327 _stats_type = reader.read("!H")[0]
4328 assert(_stats_type == 1)
4329 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004330 reader.skip(4)
Rich Lane7dcdf022013-12-11 14:45:27 -08004331 obj.entries = loxi.generic_util.unpack_list(reader, common.flow_stats_entry.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07004332 return obj
4333
4334 def __eq__(self, other):
4335 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004336 if self.xid != other.xid: return False
4337 if self.flags != other.flags: return False
4338 if self.entries != other.entries: return False
4339 return True
4340
Rich Lanec2ee4b82013-04-24 17:12:38 -07004341 def pretty_print(self, q):
4342 q.text("flow_stats_reply {")
4343 with q.group():
4344 with q.indent(2):
4345 q.breakable()
4346 q.text("xid = ");
4347 if self.xid != None:
4348 q.text("%#x" % self.xid)
4349 else:
4350 q.text('None')
4351 q.text(","); q.breakable()
4352 q.text("flags = ");
4353 q.text("%#x" % self.flags)
4354 q.text(","); q.breakable()
4355 q.text("entries = ");
4356 q.pp(self.entries)
4357 q.breakable()
4358 q.text('}')
4359
Rich Lane7dcdf022013-12-11 14:45:27 -08004360stats_reply.subtypes[1] = flow_stats_reply
4361
4362class flow_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07004363 version = 3
4364 type = 18
4365 stats_type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07004366
4367 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 -08004368 if xid != None:
4369 self.xid = xid
4370 else:
4371 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004372 if flags != None:
4373 self.flags = flags
4374 else:
4375 self.flags = 0
4376 if table_id != None:
4377 self.table_id = table_id
4378 else:
4379 self.table_id = 0
4380 if out_port != None:
4381 self.out_port = out_port
4382 else:
4383 self.out_port = 0
4384 if out_group != None:
4385 self.out_group = out_group
4386 else:
4387 self.out_group = 0
4388 if cookie != None:
4389 self.cookie = cookie
4390 else:
4391 self.cookie = 0
4392 if cookie_mask != None:
4393 self.cookie_mask = cookie_mask
4394 else:
4395 self.cookie_mask = 0
4396 if match != None:
4397 self.match = match
4398 else:
4399 self.match = common.match()
Rich Lane7dcdf022013-12-11 14:45:27 -08004400 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004401
4402 def pack(self):
4403 packed = []
4404 packed.append(struct.pack("!B", self.version))
4405 packed.append(struct.pack("!B", self.type))
4406 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4407 packed.append(struct.pack("!L", self.xid))
4408 packed.append(struct.pack("!H", self.stats_type))
4409 packed.append(struct.pack("!H", self.flags))
4410 packed.append('\x00' * 4)
4411 packed.append(struct.pack("!B", self.table_id))
4412 packed.append('\x00' * 3)
Dan Talaycof6202252013-07-02 01:00:29 -07004413 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004414 packed.append(struct.pack("!L", self.out_group))
4415 packed.append('\x00' * 4)
4416 packed.append(struct.pack("!Q", self.cookie))
4417 packed.append(struct.pack("!Q", self.cookie_mask))
4418 packed.append(self.match.pack())
4419 length = sum([len(x) for x in packed])
4420 packed[2] = struct.pack("!H", length)
4421 return ''.join(packed)
4422
4423 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004424 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004425 obj = flow_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07004426 _version = reader.read("!B")[0]
4427 assert(_version == 3)
4428 _type = reader.read("!B")[0]
4429 assert(_type == 18)
4430 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004431 orig_reader = reader
4432 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07004433 obj.xid = reader.read("!L")[0]
4434 _stats_type = reader.read("!H")[0]
4435 assert(_stats_type == 1)
4436 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004437 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07004438 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004439 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07004440 obj.out_port = util.unpack_port_no(reader)
4441 obj.out_group = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004442 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07004443 obj.cookie = reader.read("!Q")[0]
4444 obj.cookie_mask = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004445 obj.match = common.match.unpack(reader)
4446 return obj
4447
4448 def __eq__(self, other):
4449 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004450 if self.xid != other.xid: return False
4451 if self.flags != other.flags: return False
4452 if self.table_id != other.table_id: return False
4453 if self.out_port != other.out_port: return False
4454 if self.out_group != other.out_group: return False
4455 if self.cookie != other.cookie: return False
4456 if self.cookie_mask != other.cookie_mask: return False
4457 if self.match != other.match: return False
4458 return True
4459
Rich Lanec2ee4b82013-04-24 17:12:38 -07004460 def pretty_print(self, q):
4461 q.text("flow_stats_request {")
4462 with q.group():
4463 with q.indent(2):
4464 q.breakable()
4465 q.text("xid = ");
4466 if self.xid != None:
4467 q.text("%#x" % self.xid)
4468 else:
4469 q.text('None')
4470 q.text(","); q.breakable()
4471 q.text("flags = ");
4472 q.text("%#x" % self.flags)
4473 q.text(","); q.breakable()
4474 q.text("table_id = ");
4475 q.text("%#x" % self.table_id)
4476 q.text(","); q.breakable()
4477 q.text("out_port = ");
4478 q.text(util.pretty_port(self.out_port))
4479 q.text(","); q.breakable()
4480 q.text("out_group = ");
4481 q.text("%#x" % self.out_group)
4482 q.text(","); q.breakable()
4483 q.text("cookie = ");
4484 q.text("%#x" % self.cookie)
4485 q.text(","); q.breakable()
4486 q.text("cookie_mask = ");
4487 q.text("%#x" % self.cookie_mask)
4488 q.text(","); q.breakable()
4489 q.text("match = ");
4490 q.pp(self.match)
4491 q.breakable()
4492 q.text('}')
4493
Rich Lane7dcdf022013-12-11 14:45:27 -08004494stats_request.subtypes[1] = flow_stats_request
4495
4496class get_config_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -07004497 version = 3
4498 type = 8
Rich Lanec2ee4b82013-04-24 17:12:38 -07004499
4500 def __init__(self, xid=None, flags=None, miss_send_len=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08004501 if xid != None:
4502 self.xid = xid
4503 else:
4504 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004505 if flags != None:
4506 self.flags = flags
4507 else:
4508 self.flags = 0
4509 if miss_send_len != None:
4510 self.miss_send_len = miss_send_len
4511 else:
4512 self.miss_send_len = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08004513 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004514
4515 def pack(self):
4516 packed = []
4517 packed.append(struct.pack("!B", self.version))
4518 packed.append(struct.pack("!B", self.type))
4519 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4520 packed.append(struct.pack("!L", self.xid))
4521 packed.append(struct.pack("!H", self.flags))
4522 packed.append(struct.pack("!H", self.miss_send_len))
4523 length = sum([len(x) for x in packed])
4524 packed[2] = struct.pack("!H", length)
4525 return ''.join(packed)
4526
4527 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004528 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004529 obj = get_config_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07004530 _version = reader.read("!B")[0]
4531 assert(_version == 3)
4532 _type = reader.read("!B")[0]
4533 assert(_type == 8)
4534 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004535 orig_reader = reader
4536 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07004537 obj.xid = reader.read("!L")[0]
4538 obj.flags = reader.read("!H")[0]
4539 obj.miss_send_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004540 return obj
4541
4542 def __eq__(self, other):
4543 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004544 if self.xid != other.xid: return False
4545 if self.flags != other.flags: return False
4546 if self.miss_send_len != other.miss_send_len: return False
4547 return True
4548
Rich Lanec2ee4b82013-04-24 17:12:38 -07004549 def pretty_print(self, q):
4550 q.text("get_config_reply {")
4551 with q.group():
4552 with q.indent(2):
4553 q.breakable()
4554 q.text("xid = ");
4555 if self.xid != None:
4556 q.text("%#x" % self.xid)
4557 else:
4558 q.text('None')
4559 q.text(","); q.breakable()
4560 q.text("flags = ");
4561 q.text("%#x" % self.flags)
4562 q.text(","); q.breakable()
4563 q.text("miss_send_len = ");
4564 q.text("%#x" % self.miss_send_len)
4565 q.breakable()
4566 q.text('}')
4567
Rich Lane7dcdf022013-12-11 14:45:27 -08004568message.subtypes[8] = get_config_reply
4569
4570class get_config_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -07004571 version = 3
4572 type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07004573
4574 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08004575 if xid != None:
4576 self.xid = xid
4577 else:
4578 self.xid = None
4579 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004580
4581 def pack(self):
4582 packed = []
4583 packed.append(struct.pack("!B", self.version))
4584 packed.append(struct.pack("!B", self.type))
4585 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4586 packed.append(struct.pack("!L", self.xid))
4587 length = sum([len(x) for x in packed])
4588 packed[2] = struct.pack("!H", length)
4589 return ''.join(packed)
4590
4591 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004592 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004593 obj = get_config_request()
Dan Talaycof6202252013-07-02 01:00:29 -07004594 _version = reader.read("!B")[0]
4595 assert(_version == 3)
4596 _type = reader.read("!B")[0]
4597 assert(_type == 7)
4598 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004599 orig_reader = reader
4600 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07004601 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004602 return obj
4603
4604 def __eq__(self, other):
4605 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004606 if self.xid != other.xid: return False
4607 return True
4608
Rich Lanec2ee4b82013-04-24 17:12:38 -07004609 def pretty_print(self, q):
4610 q.text("get_config_request {")
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.breakable()
4620 q.text('}')
4621
Rich Lane7dcdf022013-12-11 14:45:27 -08004622message.subtypes[7] = get_config_request
4623
4624class group_mod(message):
4625 subtypes = {}
4626
4627 @staticmethod
4628 def unpack(reader):
4629 subtype, = reader.peek('!H', 8)
4630 try:
4631 subclass = group_mod.subtypes[subtype]
4632 except KeyError:
4633 raise loxi.ProtocolError("unknown group_mod message subtype %#x" % subtype)
4634 return subclass.unpack(reader)
4635
4636message.subtypes[15] = group_mod
4637
4638class group_add(group_mod):
Rich Lane7b0f2012013-11-22 14:15:26 -08004639 version = 3
4640 type = 15
4641 command = 0
4642
4643 def __init__(self, xid=None, group_type=None, group_id=None, buckets=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08004644 if xid != None:
4645 self.xid = xid
4646 else:
4647 self.xid = None
Rich Lane7b0f2012013-11-22 14:15:26 -08004648 if group_type != None:
4649 self.group_type = group_type
4650 else:
4651 self.group_type = 0
4652 if group_id != None:
4653 self.group_id = group_id
4654 else:
4655 self.group_id = 0
4656 if buckets != None:
4657 self.buckets = buckets
4658 else:
4659 self.buckets = []
Rich Lane7dcdf022013-12-11 14:45:27 -08004660 return
Rich Lane7b0f2012013-11-22 14:15:26 -08004661
4662 def pack(self):
4663 packed = []
4664 packed.append(struct.pack("!B", self.version))
4665 packed.append(struct.pack("!B", self.type))
4666 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4667 packed.append(struct.pack("!L", self.xid))
4668 packed.append(struct.pack("!H", self.command))
4669 packed.append(struct.pack("!B", self.group_type))
4670 packed.append('\x00' * 1)
4671 packed.append(struct.pack("!L", self.group_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08004672 packed.append(loxi.generic_util.pack_list(self.buckets))
Rich Lane7b0f2012013-11-22 14:15:26 -08004673 length = sum([len(x) for x in packed])
4674 packed[2] = struct.pack("!H", length)
4675 return ''.join(packed)
4676
4677 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004678 def unpack(reader):
Rich Lane7b0f2012013-11-22 14:15:26 -08004679 obj = group_add()
Rich Lane7b0f2012013-11-22 14:15:26 -08004680 _version = reader.read("!B")[0]
4681 assert(_version == 3)
4682 _type = reader.read("!B")[0]
4683 assert(_type == 15)
4684 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004685 orig_reader = reader
4686 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane7b0f2012013-11-22 14:15:26 -08004687 obj.xid = reader.read("!L")[0]
4688 _command = reader.read("!H")[0]
4689 assert(_command == 0)
4690 obj.group_type = reader.read("!B")[0]
4691 reader.skip(1)
4692 obj.group_id = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004693 obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack)
Rich Lane7b0f2012013-11-22 14:15:26 -08004694 return obj
4695
4696 def __eq__(self, other):
4697 if type(self) != type(other): return False
Rich Lane7b0f2012013-11-22 14:15:26 -08004698 if self.xid != other.xid: return False
4699 if self.group_type != other.group_type: return False
4700 if self.group_id != other.group_id: return False
4701 if self.buckets != other.buckets: return False
4702 return True
4703
Rich Lane7b0f2012013-11-22 14:15:26 -08004704 def pretty_print(self, q):
4705 q.text("group_add {")
4706 with q.group():
4707 with q.indent(2):
4708 q.breakable()
4709 q.text("xid = ");
4710 if self.xid != None:
4711 q.text("%#x" % self.xid)
4712 else:
4713 q.text('None')
4714 q.text(","); q.breakable()
4715 q.text("group_type = ");
4716 q.text("%#x" % self.group_type)
4717 q.text(","); q.breakable()
4718 q.text("group_id = ");
4719 q.text("%#x" % self.group_id)
4720 q.text(","); q.breakable()
4721 q.text("buckets = ");
4722 q.pp(self.buckets)
4723 q.breakable()
4724 q.text('}')
4725
Rich Lane7dcdf022013-12-11 14:45:27 -08004726group_mod.subtypes[0] = group_add
4727
4728class group_delete(group_mod):
Rich Lane7b0f2012013-11-22 14:15:26 -08004729 version = 3
4730 type = 15
4731 command = 2
4732
4733 def __init__(self, xid=None, group_type=None, group_id=None, buckets=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08004734 if xid != None:
4735 self.xid = xid
4736 else:
4737 self.xid = None
Rich Lane7b0f2012013-11-22 14:15:26 -08004738 if group_type != None:
4739 self.group_type = group_type
4740 else:
4741 self.group_type = 0
4742 if group_id != None:
4743 self.group_id = group_id
4744 else:
4745 self.group_id = 0
4746 if buckets != None:
4747 self.buckets = buckets
4748 else:
4749 self.buckets = []
Rich Lane7dcdf022013-12-11 14:45:27 -08004750 return
Rich Lane7b0f2012013-11-22 14:15:26 -08004751
4752 def pack(self):
4753 packed = []
4754 packed.append(struct.pack("!B", self.version))
4755 packed.append(struct.pack("!B", self.type))
4756 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4757 packed.append(struct.pack("!L", self.xid))
4758 packed.append(struct.pack("!H", self.command))
4759 packed.append(struct.pack("!B", self.group_type))
4760 packed.append('\x00' * 1)
4761 packed.append(struct.pack("!L", self.group_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08004762 packed.append(loxi.generic_util.pack_list(self.buckets))
Rich Lane7b0f2012013-11-22 14:15:26 -08004763 length = sum([len(x) for x in packed])
4764 packed[2] = struct.pack("!H", length)
4765 return ''.join(packed)
4766
4767 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004768 def unpack(reader):
Rich Lane7b0f2012013-11-22 14:15:26 -08004769 obj = group_delete()
Rich Lane7b0f2012013-11-22 14:15:26 -08004770 _version = reader.read("!B")[0]
4771 assert(_version == 3)
4772 _type = reader.read("!B")[0]
4773 assert(_type == 15)
4774 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004775 orig_reader = reader
4776 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane7b0f2012013-11-22 14:15:26 -08004777 obj.xid = reader.read("!L")[0]
4778 _command = reader.read("!H")[0]
4779 assert(_command == 2)
4780 obj.group_type = reader.read("!B")[0]
4781 reader.skip(1)
4782 obj.group_id = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004783 obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack)
Rich Lane7b0f2012013-11-22 14:15:26 -08004784 return obj
4785
4786 def __eq__(self, other):
4787 if type(self) != type(other): return False
Rich Lane7b0f2012013-11-22 14:15:26 -08004788 if self.xid != other.xid: return False
4789 if self.group_type != other.group_type: return False
4790 if self.group_id != other.group_id: return False
4791 if self.buckets != other.buckets: return False
4792 return True
4793
Rich Lane7b0f2012013-11-22 14:15:26 -08004794 def pretty_print(self, q):
4795 q.text("group_delete {")
4796 with q.group():
4797 with q.indent(2):
4798 q.breakable()
4799 q.text("xid = ");
4800 if self.xid != None:
4801 q.text("%#x" % self.xid)
4802 else:
4803 q.text('None')
4804 q.text(","); q.breakable()
4805 q.text("group_type = ");
4806 q.text("%#x" % self.group_type)
4807 q.text(","); q.breakable()
4808 q.text("group_id = ");
4809 q.text("%#x" % self.group_id)
4810 q.text(","); q.breakable()
4811 q.text("buckets = ");
4812 q.pp(self.buckets)
4813 q.breakable()
4814 q.text('}')
4815
Rich Lane7dcdf022013-12-11 14:45:27 -08004816group_mod.subtypes[2] = group_delete
4817
4818class group_desc_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07004819 version = 3
4820 type = 19
4821 stats_type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07004822
4823 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08004824 if xid != None:
4825 self.xid = xid
4826 else:
4827 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004828 if flags != None:
4829 self.flags = flags
4830 else:
4831 self.flags = 0
4832 if entries != None:
4833 self.entries = entries
4834 else:
4835 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08004836 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004837
4838 def pack(self):
4839 packed = []
4840 packed.append(struct.pack("!B", self.version))
4841 packed.append(struct.pack("!B", self.type))
4842 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4843 packed.append(struct.pack("!L", self.xid))
4844 packed.append(struct.pack("!H", self.stats_type))
4845 packed.append(struct.pack("!H", self.flags))
4846 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08004847 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004848 length = sum([len(x) for x in packed])
4849 packed[2] = struct.pack("!H", length)
4850 return ''.join(packed)
4851
4852 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004853 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004854 obj = group_desc_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07004855 _version = reader.read("!B")[0]
4856 assert(_version == 3)
4857 _type = reader.read("!B")[0]
4858 assert(_type == 19)
4859 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004860 orig_reader = reader
4861 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07004862 obj.xid = reader.read("!L")[0]
4863 _stats_type = reader.read("!H")[0]
4864 assert(_stats_type == 7)
4865 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004866 reader.skip(4)
Rich Lane7dcdf022013-12-11 14:45:27 -08004867 obj.entries = loxi.generic_util.unpack_list(reader, common.group_desc_stats_entry.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07004868 return obj
4869
4870 def __eq__(self, other):
4871 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004872 if self.xid != other.xid: return False
4873 if self.flags != other.flags: return False
4874 if self.entries != other.entries: return False
4875 return True
4876
Rich Lanec2ee4b82013-04-24 17:12:38 -07004877 def pretty_print(self, q):
4878 q.text("group_desc_stats_reply {")
4879 with q.group():
4880 with q.indent(2):
4881 q.breakable()
4882 q.text("xid = ");
4883 if self.xid != None:
4884 q.text("%#x" % self.xid)
4885 else:
4886 q.text('None')
4887 q.text(","); q.breakable()
4888 q.text("flags = ");
4889 q.text("%#x" % self.flags)
4890 q.text(","); q.breakable()
4891 q.text("entries = ");
4892 q.pp(self.entries)
4893 q.breakable()
4894 q.text('}')
4895
Rich Lane7dcdf022013-12-11 14:45:27 -08004896stats_reply.subtypes[7] = group_desc_stats_reply
4897
4898class group_desc_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07004899 version = 3
4900 type = 18
4901 stats_type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07004902
4903 def __init__(self, xid=None, flags=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08004904 if xid != None:
4905 self.xid = xid
4906 else:
4907 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004908 if flags != None:
4909 self.flags = flags
4910 else:
4911 self.flags = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08004912 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004913
4914 def pack(self):
4915 packed = []
4916 packed.append(struct.pack("!B", self.version))
4917 packed.append(struct.pack("!B", self.type))
4918 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4919 packed.append(struct.pack("!L", self.xid))
4920 packed.append(struct.pack("!H", self.stats_type))
4921 packed.append(struct.pack("!H", self.flags))
4922 packed.append('\x00' * 4)
4923 length = sum([len(x) for x in packed])
4924 packed[2] = struct.pack("!H", length)
4925 return ''.join(packed)
4926
4927 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004928 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004929 obj = group_desc_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07004930 _version = reader.read("!B")[0]
4931 assert(_version == 3)
4932 _type = reader.read("!B")[0]
4933 assert(_type == 18)
4934 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004935 orig_reader = reader
4936 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07004937 obj.xid = reader.read("!L")[0]
4938 _stats_type = reader.read("!H")[0]
4939 assert(_stats_type == 7)
4940 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004941 reader.skip(4)
4942 return obj
4943
4944 def __eq__(self, other):
4945 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004946 if self.xid != other.xid: return False
4947 if self.flags != other.flags: return False
4948 return True
4949
Rich Lanec2ee4b82013-04-24 17:12:38 -07004950 def pretty_print(self, q):
4951 q.text("group_desc_stats_request {")
4952 with q.group():
4953 with q.indent(2):
4954 q.breakable()
4955 q.text("xid = ");
4956 if self.xid != None:
4957 q.text("%#x" % self.xid)
4958 else:
4959 q.text('None')
4960 q.text(","); q.breakable()
4961 q.text("flags = ");
4962 q.text("%#x" % self.flags)
4963 q.breakable()
4964 q.text('}')
4965
Rich Lane7dcdf022013-12-11 14:45:27 -08004966stats_request.subtypes[7] = group_desc_stats_request
4967
4968class group_features_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07004969 version = 3
4970 type = 19
4971 stats_type = 8
Rich Lanec2ee4b82013-04-24 17:12:38 -07004972
4973 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 -08004974 if xid != None:
4975 self.xid = xid
4976 else:
4977 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004978 if flags != None:
4979 self.flags = flags
4980 else:
4981 self.flags = 0
4982 if types != None:
4983 self.types = types
4984 else:
4985 self.types = 0
4986 if capabilities != None:
4987 self.capabilities = capabilities
4988 else:
4989 self.capabilities = 0
4990 if max_groups_all != None:
4991 self.max_groups_all = max_groups_all
4992 else:
4993 self.max_groups_all = 0
4994 if max_groups_select != None:
4995 self.max_groups_select = max_groups_select
4996 else:
4997 self.max_groups_select = 0
4998 if max_groups_indirect != None:
4999 self.max_groups_indirect = max_groups_indirect
5000 else:
5001 self.max_groups_indirect = 0
5002 if max_groups_ff != None:
5003 self.max_groups_ff = max_groups_ff
5004 else:
5005 self.max_groups_ff = 0
5006 if actions_all != None:
5007 self.actions_all = actions_all
5008 else:
5009 self.actions_all = 0
5010 if actions_select != None:
5011 self.actions_select = actions_select
5012 else:
5013 self.actions_select = 0
5014 if actions_indirect != None:
5015 self.actions_indirect = actions_indirect
5016 else:
5017 self.actions_indirect = 0
5018 if actions_ff != None:
5019 self.actions_ff = actions_ff
5020 else:
5021 self.actions_ff = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08005022 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005023
5024 def pack(self):
5025 packed = []
5026 packed.append(struct.pack("!B", self.version))
5027 packed.append(struct.pack("!B", self.type))
5028 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5029 packed.append(struct.pack("!L", self.xid))
5030 packed.append(struct.pack("!H", self.stats_type))
5031 packed.append(struct.pack("!H", self.flags))
5032 packed.append('\x00' * 4)
5033 packed.append(struct.pack("!L", self.types))
5034 packed.append(struct.pack("!L", self.capabilities))
5035 packed.append(struct.pack("!L", self.max_groups_all))
5036 packed.append(struct.pack("!L", self.max_groups_select))
5037 packed.append(struct.pack("!L", self.max_groups_indirect))
5038 packed.append(struct.pack("!L", self.max_groups_ff))
5039 packed.append(struct.pack("!L", self.actions_all))
5040 packed.append(struct.pack("!L", self.actions_select))
5041 packed.append(struct.pack("!L", self.actions_indirect))
5042 packed.append(struct.pack("!L", self.actions_ff))
5043 length = sum([len(x) for x in packed])
5044 packed[2] = struct.pack("!H", length)
5045 return ''.join(packed)
5046
5047 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005048 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005049 obj = group_features_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07005050 _version = reader.read("!B")[0]
5051 assert(_version == 3)
5052 _type = reader.read("!B")[0]
5053 assert(_type == 19)
5054 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005055 orig_reader = reader
5056 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005057 obj.xid = reader.read("!L")[0]
5058 _stats_type = reader.read("!H")[0]
5059 assert(_stats_type == 8)
5060 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005061 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07005062 obj.types = reader.read("!L")[0]
5063 obj.capabilities = reader.read("!L")[0]
5064 obj.max_groups_all = reader.read("!L")[0]
5065 obj.max_groups_select = reader.read("!L")[0]
5066 obj.max_groups_indirect = reader.read("!L")[0]
5067 obj.max_groups_ff = reader.read("!L")[0]
5068 obj.actions_all = reader.read("!L")[0]
5069 obj.actions_select = reader.read("!L")[0]
5070 obj.actions_indirect = reader.read("!L")[0]
5071 obj.actions_ff = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005072 return obj
5073
5074 def __eq__(self, other):
5075 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005076 if self.xid != other.xid: return False
5077 if self.flags != other.flags: return False
5078 if self.types != other.types: return False
5079 if self.capabilities != other.capabilities: return False
5080 if self.max_groups_all != other.max_groups_all: return False
5081 if self.max_groups_select != other.max_groups_select: return False
5082 if self.max_groups_indirect != other.max_groups_indirect: return False
5083 if self.max_groups_ff != other.max_groups_ff: return False
5084 if self.actions_all != other.actions_all: return False
5085 if self.actions_select != other.actions_select: return False
5086 if self.actions_indirect != other.actions_indirect: return False
5087 if self.actions_ff != other.actions_ff: return False
5088 return True
5089
Rich Lanec2ee4b82013-04-24 17:12:38 -07005090 def pretty_print(self, q):
5091 q.text("group_features_stats_reply {")
5092 with q.group():
5093 with q.indent(2):
5094 q.breakable()
5095 q.text("xid = ");
5096 if self.xid != None:
5097 q.text("%#x" % self.xid)
5098 else:
5099 q.text('None')
5100 q.text(","); q.breakable()
5101 q.text("flags = ");
5102 q.text("%#x" % self.flags)
5103 q.text(","); q.breakable()
5104 q.text("types = ");
5105 q.text("%#x" % self.types)
5106 q.text(","); q.breakable()
5107 q.text("capabilities = ");
5108 q.text("%#x" % self.capabilities)
5109 q.text(","); q.breakable()
5110 q.text("max_groups_all = ");
5111 q.text("%#x" % self.max_groups_all)
5112 q.text(","); q.breakable()
5113 q.text("max_groups_select = ");
5114 q.text("%#x" % self.max_groups_select)
5115 q.text(","); q.breakable()
5116 q.text("max_groups_indirect = ");
5117 q.text("%#x" % self.max_groups_indirect)
5118 q.text(","); q.breakable()
5119 q.text("max_groups_ff = ");
5120 q.text("%#x" % self.max_groups_ff)
5121 q.text(","); q.breakable()
5122 q.text("actions_all = ");
5123 q.text("%#x" % self.actions_all)
5124 q.text(","); q.breakable()
5125 q.text("actions_select = ");
5126 q.text("%#x" % self.actions_select)
5127 q.text(","); q.breakable()
5128 q.text("actions_indirect = ");
5129 q.text("%#x" % self.actions_indirect)
5130 q.text(","); q.breakable()
5131 q.text("actions_ff = ");
5132 q.text("%#x" % self.actions_ff)
5133 q.breakable()
5134 q.text('}')
5135
Rich Lane7dcdf022013-12-11 14:45:27 -08005136stats_reply.subtypes[8] = group_features_stats_reply
5137
5138class group_features_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07005139 version = 3
5140 type = 18
5141 stats_type = 8
Rich Lanec2ee4b82013-04-24 17:12:38 -07005142
5143 def __init__(self, xid=None, flags=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005144 if xid != None:
5145 self.xid = xid
5146 else:
5147 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005148 if flags != None:
5149 self.flags = flags
5150 else:
5151 self.flags = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08005152 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005153
5154 def pack(self):
5155 packed = []
5156 packed.append(struct.pack("!B", self.version))
5157 packed.append(struct.pack("!B", self.type))
5158 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5159 packed.append(struct.pack("!L", self.xid))
5160 packed.append(struct.pack("!H", self.stats_type))
5161 packed.append(struct.pack("!H", self.flags))
5162 packed.append('\x00' * 4)
5163 length = sum([len(x) for x in packed])
5164 packed[2] = struct.pack("!H", length)
5165 return ''.join(packed)
5166
5167 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005168 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005169 obj = group_features_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07005170 _version = reader.read("!B")[0]
5171 assert(_version == 3)
5172 _type = reader.read("!B")[0]
5173 assert(_type == 18)
5174 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005175 orig_reader = reader
5176 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005177 obj.xid = reader.read("!L")[0]
5178 _stats_type = reader.read("!H")[0]
5179 assert(_stats_type == 8)
5180 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005181 reader.skip(4)
5182 return obj
5183
5184 def __eq__(self, other):
5185 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005186 if self.xid != other.xid: return False
5187 if self.flags != other.flags: return False
5188 return True
5189
Rich Lanec2ee4b82013-04-24 17:12:38 -07005190 def pretty_print(self, q):
5191 q.text("group_features_stats_request {")
5192 with q.group():
5193 with q.indent(2):
5194 q.breakable()
5195 q.text("xid = ");
5196 if self.xid != None:
5197 q.text("%#x" % self.xid)
5198 else:
5199 q.text('None')
5200 q.text(","); q.breakable()
5201 q.text("flags = ");
5202 q.text("%#x" % self.flags)
5203 q.breakable()
5204 q.text('}')
5205
Rich Lane7dcdf022013-12-11 14:45:27 -08005206stats_request.subtypes[8] = group_features_stats_request
5207
5208class group_mod_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07005209 version = 3
5210 type = 1
5211 err_type = 6
5212
5213 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005214 if xid != None:
5215 self.xid = xid
5216 else:
5217 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07005218 if code != None:
5219 self.code = code
5220 else:
5221 self.code = 0
5222 if data != None:
5223 self.data = data
5224 else:
5225 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08005226 return
Rich Lane6f4978c2013-10-20 21:33:52 -07005227
5228 def pack(self):
5229 packed = []
5230 packed.append(struct.pack("!B", self.version))
5231 packed.append(struct.pack("!B", self.type))
5232 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5233 packed.append(struct.pack("!L", self.xid))
5234 packed.append(struct.pack("!H", self.err_type))
5235 packed.append(struct.pack("!H", self.code))
5236 packed.append(self.data)
5237 length = sum([len(x) for x in packed])
5238 packed[2] = struct.pack("!H", length)
5239 return ''.join(packed)
5240
5241 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005242 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07005243 obj = group_mod_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07005244 _version = reader.read("!B")[0]
5245 assert(_version == 3)
5246 _type = reader.read("!B")[0]
5247 assert(_type == 1)
5248 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005249 orig_reader = reader
5250 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07005251 obj.xid = reader.read("!L")[0]
5252 _err_type = reader.read("!H")[0]
5253 assert(_err_type == 6)
5254 obj.code = reader.read("!H")[0]
5255 obj.data = str(reader.read_all())
5256 return obj
5257
5258 def __eq__(self, other):
5259 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07005260 if self.xid != other.xid: return False
5261 if self.code != other.code: return False
5262 if self.data != other.data: return False
5263 return True
5264
Rich Lane6f4978c2013-10-20 21:33:52 -07005265 def pretty_print(self, q):
5266 q.text("group_mod_failed_error_msg {")
5267 with q.group():
5268 with q.indent(2):
5269 q.breakable()
5270 q.text("xid = ");
5271 if self.xid != None:
5272 q.text("%#x" % self.xid)
5273 else:
5274 q.text('None')
5275 q.text(","); q.breakable()
5276 q.text("code = ");
5277 q.text("%#x" % self.code)
5278 q.text(","); q.breakable()
5279 q.text("data = ");
5280 q.pp(self.data)
5281 q.breakable()
5282 q.text('}')
5283
Rich Lane7dcdf022013-12-11 14:45:27 -08005284error_msg.subtypes[6] = group_mod_failed_error_msg
5285
5286class group_modify(group_mod):
Rich Lane7b0f2012013-11-22 14:15:26 -08005287 version = 3
5288 type = 15
5289 command = 1
5290
5291 def __init__(self, xid=None, group_type=None, group_id=None, buckets=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005292 if xid != None:
5293 self.xid = xid
5294 else:
5295 self.xid = None
Rich Lane7b0f2012013-11-22 14:15:26 -08005296 if group_type != None:
5297 self.group_type = group_type
5298 else:
5299 self.group_type = 0
5300 if group_id != None:
5301 self.group_id = group_id
5302 else:
5303 self.group_id = 0
5304 if buckets != None:
5305 self.buckets = buckets
5306 else:
5307 self.buckets = []
Rich Lane7dcdf022013-12-11 14:45:27 -08005308 return
Rich Lane7b0f2012013-11-22 14:15:26 -08005309
5310 def pack(self):
5311 packed = []
5312 packed.append(struct.pack("!B", self.version))
5313 packed.append(struct.pack("!B", self.type))
5314 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5315 packed.append(struct.pack("!L", self.xid))
5316 packed.append(struct.pack("!H", self.command))
5317 packed.append(struct.pack("!B", self.group_type))
5318 packed.append('\x00' * 1)
5319 packed.append(struct.pack("!L", self.group_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08005320 packed.append(loxi.generic_util.pack_list(self.buckets))
Rich Lane7b0f2012013-11-22 14:15:26 -08005321 length = sum([len(x) for x in packed])
5322 packed[2] = struct.pack("!H", length)
5323 return ''.join(packed)
5324
5325 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005326 def unpack(reader):
Rich Lane7b0f2012013-11-22 14:15:26 -08005327 obj = group_modify()
Rich Lane7b0f2012013-11-22 14:15:26 -08005328 _version = reader.read("!B")[0]
5329 assert(_version == 3)
5330 _type = reader.read("!B")[0]
5331 assert(_type == 15)
5332 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005333 orig_reader = reader
5334 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane7b0f2012013-11-22 14:15:26 -08005335 obj.xid = reader.read("!L")[0]
5336 _command = reader.read("!H")[0]
5337 assert(_command == 1)
5338 obj.group_type = reader.read("!B")[0]
5339 reader.skip(1)
5340 obj.group_id = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005341 obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack)
Rich Lane7b0f2012013-11-22 14:15:26 -08005342 return obj
5343
5344 def __eq__(self, other):
5345 if type(self) != type(other): return False
Rich Lane7b0f2012013-11-22 14:15:26 -08005346 if self.xid != other.xid: return False
5347 if self.group_type != other.group_type: return False
5348 if self.group_id != other.group_id: return False
5349 if self.buckets != other.buckets: return False
5350 return True
5351
Rich Lane7b0f2012013-11-22 14:15:26 -08005352 def pretty_print(self, q):
5353 q.text("group_modify {")
5354 with q.group():
5355 with q.indent(2):
5356 q.breakable()
5357 q.text("xid = ");
5358 if self.xid != None:
5359 q.text("%#x" % self.xid)
5360 else:
5361 q.text('None')
5362 q.text(","); q.breakable()
5363 q.text("group_type = ");
5364 q.text("%#x" % self.group_type)
5365 q.text(","); q.breakable()
5366 q.text("group_id = ");
5367 q.text("%#x" % self.group_id)
5368 q.text(","); q.breakable()
5369 q.text("buckets = ");
5370 q.pp(self.buckets)
5371 q.breakable()
5372 q.text('}')
5373
Rich Lane7dcdf022013-12-11 14:45:27 -08005374group_mod.subtypes[1] = group_modify
5375
5376class group_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07005377 version = 3
5378 type = 19
5379 stats_type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07005380
5381 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005382 if xid != None:
5383 self.xid = xid
5384 else:
5385 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005386 if flags != None:
5387 self.flags = flags
5388 else:
5389 self.flags = 0
5390 if entries != None:
5391 self.entries = entries
5392 else:
5393 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08005394 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005395
5396 def pack(self):
5397 packed = []
5398 packed.append(struct.pack("!B", self.version))
5399 packed.append(struct.pack("!B", self.type))
5400 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5401 packed.append(struct.pack("!L", self.xid))
5402 packed.append(struct.pack("!H", self.stats_type))
5403 packed.append(struct.pack("!H", self.flags))
5404 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08005405 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005406 length = sum([len(x) for x in packed])
5407 packed[2] = struct.pack("!H", length)
5408 return ''.join(packed)
5409
5410 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005411 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005412 obj = group_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07005413 _version = reader.read("!B")[0]
5414 assert(_version == 3)
5415 _type = reader.read("!B")[0]
5416 assert(_type == 19)
5417 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005418 orig_reader = reader
5419 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005420 obj.xid = reader.read("!L")[0]
5421 _stats_type = reader.read("!H")[0]
5422 assert(_stats_type == 6)
5423 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005424 reader.skip(4)
Rich Lane7dcdf022013-12-11 14:45:27 -08005425 obj.entries = loxi.generic_util.unpack_list(reader, common.group_stats_entry.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07005426 return obj
5427
5428 def __eq__(self, other):
5429 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005430 if self.xid != other.xid: return False
5431 if self.flags != other.flags: return False
5432 if self.entries != other.entries: return False
5433 return True
5434
Rich Lanec2ee4b82013-04-24 17:12:38 -07005435 def pretty_print(self, q):
5436 q.text("group_stats_reply {")
5437 with q.group():
5438 with q.indent(2):
5439 q.breakable()
5440 q.text("xid = ");
5441 if self.xid != None:
5442 q.text("%#x" % self.xid)
5443 else:
5444 q.text('None')
5445 q.text(","); q.breakable()
5446 q.text("flags = ");
5447 q.text("%#x" % self.flags)
5448 q.text(","); q.breakable()
5449 q.text("entries = ");
5450 q.pp(self.entries)
5451 q.breakable()
5452 q.text('}')
5453
Rich Lane7dcdf022013-12-11 14:45:27 -08005454stats_reply.subtypes[6] = group_stats_reply
5455
5456class group_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07005457 version = 3
5458 type = 18
5459 stats_type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07005460
5461 def __init__(self, xid=None, flags=None, group_id=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005462 if xid != None:
5463 self.xid = xid
5464 else:
5465 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005466 if flags != None:
5467 self.flags = flags
5468 else:
5469 self.flags = 0
5470 if group_id != None:
5471 self.group_id = group_id
5472 else:
5473 self.group_id = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08005474 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005475
5476 def pack(self):
5477 packed = []
5478 packed.append(struct.pack("!B", self.version))
5479 packed.append(struct.pack("!B", self.type))
5480 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5481 packed.append(struct.pack("!L", self.xid))
5482 packed.append(struct.pack("!H", self.stats_type))
5483 packed.append(struct.pack("!H", self.flags))
5484 packed.append('\x00' * 4)
5485 packed.append(struct.pack("!L", self.group_id))
5486 packed.append('\x00' * 4)
5487 length = sum([len(x) for x in packed])
5488 packed[2] = struct.pack("!H", length)
5489 return ''.join(packed)
5490
5491 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005492 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005493 obj = group_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07005494 _version = reader.read("!B")[0]
5495 assert(_version == 3)
5496 _type = reader.read("!B")[0]
5497 assert(_type == 18)
5498 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005499 orig_reader = reader
5500 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005501 obj.xid = reader.read("!L")[0]
5502 _stats_type = reader.read("!H")[0]
5503 assert(_stats_type == 6)
5504 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005505 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07005506 obj.group_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005507 reader.skip(4)
5508 return obj
5509
5510 def __eq__(self, other):
5511 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005512 if self.xid != other.xid: return False
5513 if self.flags != other.flags: return False
5514 if self.group_id != other.group_id: return False
5515 return True
5516
Rich Lanec2ee4b82013-04-24 17:12:38 -07005517 def pretty_print(self, q):
5518 q.text("group_stats_request {")
5519 with q.group():
5520 with q.indent(2):
5521 q.breakable()
5522 q.text("xid = ");
5523 if self.xid != None:
5524 q.text("%#x" % self.xid)
5525 else:
5526 q.text('None')
5527 q.text(","); q.breakable()
5528 q.text("flags = ");
5529 q.text("%#x" % self.flags)
5530 q.text(","); q.breakable()
5531 q.text("group_id = ");
5532 q.text("%#x" % self.group_id)
5533 q.breakable()
5534 q.text('}')
5535
Rich Lane7dcdf022013-12-11 14:45:27 -08005536stats_request.subtypes[6] = group_stats_request
5537
5538class hello(message):
Dan Talaycof6202252013-07-02 01:00:29 -07005539 version = 3
5540 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07005541
5542 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005543 if xid != None:
5544 self.xid = xid
5545 else:
5546 self.xid = None
5547 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005548
5549 def pack(self):
5550 packed = []
5551 packed.append(struct.pack("!B", self.version))
5552 packed.append(struct.pack("!B", self.type))
5553 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5554 packed.append(struct.pack("!L", self.xid))
5555 length = sum([len(x) for x in packed])
5556 packed[2] = struct.pack("!H", length)
5557 return ''.join(packed)
5558
5559 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005560 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005561 obj = hello()
Dan Talaycof6202252013-07-02 01:00:29 -07005562 _version = reader.read("!B")[0]
5563 assert(_version == 3)
5564 _type = reader.read("!B")[0]
5565 assert(_type == 0)
5566 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005567 orig_reader = reader
5568 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005569 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005570 return obj
5571
5572 def __eq__(self, other):
5573 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005574 if self.xid != other.xid: return False
5575 return True
5576
Rich Lanec2ee4b82013-04-24 17:12:38 -07005577 def pretty_print(self, q):
5578 q.text("hello {")
5579 with q.group():
5580 with q.indent(2):
5581 q.breakable()
5582 q.text("xid = ");
5583 if self.xid != None:
5584 q.text("%#x" % self.xid)
5585 else:
5586 q.text('None')
5587 q.breakable()
5588 q.text('}')
5589
Rich Lane7dcdf022013-12-11 14:45:27 -08005590message.subtypes[0] = hello
5591
5592class hello_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07005593 version = 3
5594 type = 1
5595 err_type = 0
5596
5597 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005598 if xid != None:
5599 self.xid = xid
5600 else:
5601 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07005602 if code != None:
5603 self.code = code
5604 else:
5605 self.code = 0
5606 if data != None:
5607 self.data = data
5608 else:
5609 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08005610 return
Rich Lane6f4978c2013-10-20 21:33:52 -07005611
5612 def pack(self):
5613 packed = []
5614 packed.append(struct.pack("!B", self.version))
5615 packed.append(struct.pack("!B", self.type))
5616 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5617 packed.append(struct.pack("!L", self.xid))
5618 packed.append(struct.pack("!H", self.err_type))
5619 packed.append(struct.pack("!H", self.code))
5620 packed.append(self.data)
5621 length = sum([len(x) for x in packed])
5622 packed[2] = struct.pack("!H", length)
5623 return ''.join(packed)
5624
5625 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005626 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07005627 obj = hello_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07005628 _version = reader.read("!B")[0]
5629 assert(_version == 3)
5630 _type = reader.read("!B")[0]
5631 assert(_type == 1)
5632 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005633 orig_reader = reader
5634 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07005635 obj.xid = reader.read("!L")[0]
5636 _err_type = reader.read("!H")[0]
5637 assert(_err_type == 0)
5638 obj.code = reader.read("!H")[0]
5639 obj.data = str(reader.read_all())
5640 return obj
5641
5642 def __eq__(self, other):
5643 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07005644 if self.xid != other.xid: return False
5645 if self.code != other.code: return False
5646 if self.data != other.data: return False
5647 return True
5648
Rich Lane6f4978c2013-10-20 21:33:52 -07005649 def pretty_print(self, q):
5650 q.text("hello_failed_error_msg {")
5651 with q.group():
5652 with q.indent(2):
5653 q.breakable()
5654 q.text("xid = ");
5655 if self.xid != None:
5656 q.text("%#x" % self.xid)
5657 else:
5658 q.text('None')
5659 q.text(","); q.breakable()
5660 q.text("code = ");
5661 q.text("%#x" % self.code)
5662 q.text(","); q.breakable()
5663 q.text("data = ");
5664 q.pp(self.data)
5665 q.breakable()
5666 q.text('}')
5667
Rich Lane7dcdf022013-12-11 14:45:27 -08005668error_msg.subtypes[0] = hello_failed_error_msg
5669
5670class nicira_header(experimenter):
5671 subtypes = {}
5672
5673 @staticmethod
5674 def unpack(reader):
5675 subtype, = reader.peek('!L', 12)
5676 try:
5677 subclass = nicira_header.subtypes[subtype]
5678 except KeyError:
5679 raise loxi.ProtocolError("unknown nicira_header experimenter message subtype %#x" % subtype)
5680 return subclass.unpack(reader)
5681
5682experimenter.subtypes[8992] = nicira_header
5683
5684class packet_in(message):
Dan Talaycof6202252013-07-02 01:00:29 -07005685 version = 3
5686 type = 10
Rich Lanec2ee4b82013-04-24 17:12:38 -07005687
5688 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 -08005689 if xid != None:
5690 self.xid = xid
5691 else:
5692 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005693 if buffer_id != None:
5694 self.buffer_id = buffer_id
5695 else:
5696 self.buffer_id = 0
5697 if total_len != None:
5698 self.total_len = total_len
5699 else:
5700 self.total_len = 0
5701 if reason != None:
5702 self.reason = reason
5703 else:
5704 self.reason = 0
5705 if table_id != None:
5706 self.table_id = table_id
5707 else:
5708 self.table_id = 0
5709 if match != None:
5710 self.match = match
5711 else:
5712 self.match = common.match()
5713 if data != None:
5714 self.data = data
5715 else:
Dan Talaycof6202252013-07-02 01:00:29 -07005716 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08005717 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005718
5719 def pack(self):
5720 packed = []
5721 packed.append(struct.pack("!B", self.version))
5722 packed.append(struct.pack("!B", self.type))
5723 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5724 packed.append(struct.pack("!L", self.xid))
5725 packed.append(struct.pack("!L", self.buffer_id))
5726 packed.append(struct.pack("!H", self.total_len))
5727 packed.append(struct.pack("!B", self.reason))
5728 packed.append(struct.pack("!B", self.table_id))
5729 packed.append(self.match.pack())
5730 packed.append('\x00' * 2)
5731 packed.append(self.data)
5732 length = sum([len(x) for x in packed])
5733 packed[2] = struct.pack("!H", length)
5734 return ''.join(packed)
5735
5736 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005737 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005738 obj = packet_in()
Dan Talaycof6202252013-07-02 01:00:29 -07005739 _version = reader.read("!B")[0]
5740 assert(_version == 3)
5741 _type = reader.read("!B")[0]
5742 assert(_type == 10)
5743 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005744 orig_reader = reader
5745 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005746 obj.xid = reader.read("!L")[0]
5747 obj.buffer_id = reader.read("!L")[0]
5748 obj.total_len = reader.read("!H")[0]
5749 obj.reason = reader.read("!B")[0]
5750 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005751 obj.match = common.match.unpack(reader)
5752 reader.skip(2)
5753 obj.data = str(reader.read_all())
5754 return obj
5755
5756 def __eq__(self, other):
5757 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005758 if self.xid != other.xid: return False
5759 if self.buffer_id != other.buffer_id: return False
5760 if self.total_len != other.total_len: return False
5761 if self.reason != other.reason: return False
5762 if self.table_id != other.table_id: return False
5763 if self.match != other.match: return False
5764 if self.data != other.data: return False
5765 return True
5766
Rich Lanec2ee4b82013-04-24 17:12:38 -07005767 def pretty_print(self, q):
5768 q.text("packet_in {")
5769 with q.group():
5770 with q.indent(2):
5771 q.breakable()
5772 q.text("xid = ");
5773 if self.xid != None:
5774 q.text("%#x" % self.xid)
5775 else:
5776 q.text('None')
5777 q.text(","); q.breakable()
5778 q.text("buffer_id = ");
5779 q.text("%#x" % self.buffer_id)
5780 q.text(","); q.breakable()
5781 q.text("total_len = ");
5782 q.text("%#x" % self.total_len)
5783 q.text(","); q.breakable()
5784 q.text("reason = ");
5785 q.text("%#x" % self.reason)
5786 q.text(","); q.breakable()
5787 q.text("table_id = ");
5788 q.text("%#x" % self.table_id)
5789 q.text(","); q.breakable()
5790 q.text("match = ");
5791 q.pp(self.match)
5792 q.text(","); q.breakable()
5793 q.text("data = ");
5794 q.pp(self.data)
5795 q.breakable()
5796 q.text('}')
5797
Rich Lane7dcdf022013-12-11 14:45:27 -08005798message.subtypes[10] = packet_in
5799
5800class packet_out(message):
Dan Talaycof6202252013-07-02 01:00:29 -07005801 version = 3
5802 type = 13
Rich Lanec2ee4b82013-04-24 17:12:38 -07005803
5804 def __init__(self, xid=None, buffer_id=None, in_port=None, actions=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005805 if xid != None:
5806 self.xid = xid
5807 else:
5808 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005809 if buffer_id != None:
5810 self.buffer_id = buffer_id
5811 else:
5812 self.buffer_id = 0
5813 if in_port != None:
5814 self.in_port = in_port
5815 else:
5816 self.in_port = 0
5817 if actions != None:
5818 self.actions = actions
5819 else:
5820 self.actions = []
5821 if data != None:
5822 self.data = data
5823 else:
Dan Talaycof6202252013-07-02 01:00:29 -07005824 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08005825 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005826
5827 def pack(self):
5828 packed = []
5829 packed.append(struct.pack("!B", self.version))
5830 packed.append(struct.pack("!B", self.type))
5831 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5832 packed.append(struct.pack("!L", self.xid))
5833 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07005834 packed.append(util.pack_port_no(self.in_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005835 packed.append(struct.pack("!H", 0)) # placeholder for actions_len at index 6
5836 packed.append('\x00' * 6)
Rich Lane7dcdf022013-12-11 14:45:27 -08005837 packed.append(loxi.generic_util.pack_list(self.actions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005838 packed[6] = struct.pack("!H", len(packed[-1]))
5839 packed.append(self.data)
5840 length = sum([len(x) for x in packed])
5841 packed[2] = struct.pack("!H", length)
5842 return ''.join(packed)
5843
5844 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005845 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005846 obj = packet_out()
Dan Talaycof6202252013-07-02 01:00:29 -07005847 _version = reader.read("!B")[0]
5848 assert(_version == 3)
5849 _type = reader.read("!B")[0]
5850 assert(_type == 13)
5851 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005852 orig_reader = reader
5853 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005854 obj.xid = reader.read("!L")[0]
5855 obj.buffer_id = reader.read("!L")[0]
5856 obj.in_port = util.unpack_port_no(reader)
5857 _actions_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005858 reader.skip(6)
Rich Lane7dcdf022013-12-11 14:45:27 -08005859 obj.actions = loxi.generic_util.unpack_list(reader.slice(_actions_len), action.action.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07005860 obj.data = str(reader.read_all())
5861 return obj
5862
5863 def __eq__(self, other):
5864 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005865 if self.xid != other.xid: return False
5866 if self.buffer_id != other.buffer_id: return False
5867 if self.in_port != other.in_port: return False
5868 if self.actions != other.actions: return False
5869 if self.data != other.data: return False
5870 return True
5871
Rich Lanec2ee4b82013-04-24 17:12:38 -07005872 def pretty_print(self, q):
5873 q.text("packet_out {")
5874 with q.group():
5875 with q.indent(2):
5876 q.breakable()
5877 q.text("xid = ");
5878 if self.xid != None:
5879 q.text("%#x" % self.xid)
5880 else:
5881 q.text('None')
5882 q.text(","); q.breakable()
5883 q.text("buffer_id = ");
5884 q.text("%#x" % self.buffer_id)
5885 q.text(","); q.breakable()
5886 q.text("in_port = ");
5887 q.text(util.pretty_port(self.in_port))
5888 q.text(","); q.breakable()
5889 q.text("actions = ");
5890 q.pp(self.actions)
5891 q.text(","); q.breakable()
5892 q.text("data = ");
5893 q.pp(self.data)
5894 q.breakable()
5895 q.text('}')
5896
Rich Lane7dcdf022013-12-11 14:45:27 -08005897message.subtypes[13] = packet_out
5898
5899class port_mod(message):
Dan Talaycof6202252013-07-02 01:00:29 -07005900 version = 3
5901 type = 16
Rich Lanec2ee4b82013-04-24 17:12:38 -07005902
5903 def __init__(self, xid=None, port_no=None, hw_addr=None, config=None, mask=None, advertise=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005904 if xid != None:
5905 self.xid = xid
5906 else:
5907 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005908 if port_no != None:
5909 self.port_no = port_no
5910 else:
5911 self.port_no = 0
5912 if hw_addr != None:
5913 self.hw_addr = hw_addr
5914 else:
5915 self.hw_addr = [0,0,0,0,0,0]
5916 if config != None:
5917 self.config = config
5918 else:
5919 self.config = 0
5920 if mask != None:
5921 self.mask = mask
5922 else:
5923 self.mask = 0
5924 if advertise != None:
5925 self.advertise = advertise
5926 else:
5927 self.advertise = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08005928 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005929
5930 def pack(self):
5931 packed = []
5932 packed.append(struct.pack("!B", self.version))
5933 packed.append(struct.pack("!B", self.type))
5934 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5935 packed.append(struct.pack("!L", self.xid))
Dan Talaycof6202252013-07-02 01:00:29 -07005936 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005937 packed.append('\x00' * 4)
5938 packed.append(struct.pack("!6B", *self.hw_addr))
5939 packed.append('\x00' * 2)
5940 packed.append(struct.pack("!L", self.config))
5941 packed.append(struct.pack("!L", self.mask))
5942 packed.append(struct.pack("!L", self.advertise))
5943 packed.append('\x00' * 4)
5944 length = sum([len(x) for x in packed])
5945 packed[2] = struct.pack("!H", length)
5946 return ''.join(packed)
5947
5948 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005949 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005950 obj = port_mod()
Dan Talaycof6202252013-07-02 01:00:29 -07005951 _version = reader.read("!B")[0]
5952 assert(_version == 3)
5953 _type = reader.read("!B")[0]
5954 assert(_type == 16)
5955 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005956 orig_reader = reader
5957 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005958 obj.xid = reader.read("!L")[0]
5959 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07005960 reader.skip(4)
5961 obj.hw_addr = list(reader.read('!6B'))
5962 reader.skip(2)
Dan Talaycof6202252013-07-02 01:00:29 -07005963 obj.config = reader.read("!L")[0]
5964 obj.mask = reader.read("!L")[0]
5965 obj.advertise = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005966 reader.skip(4)
5967 return obj
5968
5969 def __eq__(self, other):
5970 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005971 if self.xid != other.xid: return False
5972 if self.port_no != other.port_no: return False
5973 if self.hw_addr != other.hw_addr: return False
5974 if self.config != other.config: return False
5975 if self.mask != other.mask: return False
5976 if self.advertise != other.advertise: return False
5977 return True
5978
Rich Lanec2ee4b82013-04-24 17:12:38 -07005979 def pretty_print(self, q):
5980 q.text("port_mod {")
5981 with q.group():
5982 with q.indent(2):
5983 q.breakable()
5984 q.text("xid = ");
5985 if self.xid != None:
5986 q.text("%#x" % self.xid)
5987 else:
5988 q.text('None')
5989 q.text(","); q.breakable()
5990 q.text("port_no = ");
5991 q.text(util.pretty_port(self.port_no))
5992 q.text(","); q.breakable()
5993 q.text("hw_addr = ");
5994 q.text(util.pretty_mac(self.hw_addr))
5995 q.text(","); q.breakable()
5996 q.text("config = ");
5997 q.text("%#x" % self.config)
5998 q.text(","); q.breakable()
5999 q.text("mask = ");
6000 q.text("%#x" % self.mask)
6001 q.text(","); q.breakable()
6002 q.text("advertise = ");
6003 q.text("%#x" % self.advertise)
6004 q.breakable()
6005 q.text('}')
6006
Rich Lane7dcdf022013-12-11 14:45:27 -08006007message.subtypes[16] = port_mod
6008
6009class port_mod_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07006010 version = 3
6011 type = 1
6012 err_type = 7
6013
6014 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006015 if xid != None:
6016 self.xid = xid
6017 else:
6018 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07006019 if code != None:
6020 self.code = code
6021 else:
6022 self.code = 0
6023 if data != None:
6024 self.data = data
6025 else:
6026 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08006027 return
Rich Lane6f4978c2013-10-20 21:33:52 -07006028
6029 def pack(self):
6030 packed = []
6031 packed.append(struct.pack("!B", self.version))
6032 packed.append(struct.pack("!B", self.type))
6033 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6034 packed.append(struct.pack("!L", self.xid))
6035 packed.append(struct.pack("!H", self.err_type))
6036 packed.append(struct.pack("!H", self.code))
6037 packed.append(self.data)
6038 length = sum([len(x) for x in packed])
6039 packed[2] = struct.pack("!H", length)
6040 return ''.join(packed)
6041
6042 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006043 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07006044 obj = port_mod_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07006045 _version = reader.read("!B")[0]
6046 assert(_version == 3)
6047 _type = reader.read("!B")[0]
6048 assert(_type == 1)
6049 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006050 orig_reader = reader
6051 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07006052 obj.xid = reader.read("!L")[0]
6053 _err_type = reader.read("!H")[0]
6054 assert(_err_type == 7)
6055 obj.code = reader.read("!H")[0]
6056 obj.data = str(reader.read_all())
6057 return obj
6058
6059 def __eq__(self, other):
6060 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07006061 if self.xid != other.xid: return False
6062 if self.code != other.code: return False
6063 if self.data != other.data: return False
6064 return True
6065
Rich Lane6f4978c2013-10-20 21:33:52 -07006066 def pretty_print(self, q):
6067 q.text("port_mod_failed_error_msg {")
6068 with q.group():
6069 with q.indent(2):
6070 q.breakable()
6071 q.text("xid = ");
6072 if self.xid != None:
6073 q.text("%#x" % self.xid)
6074 else:
6075 q.text('None')
6076 q.text(","); q.breakable()
6077 q.text("code = ");
6078 q.text("%#x" % self.code)
6079 q.text(","); q.breakable()
6080 q.text("data = ");
6081 q.pp(self.data)
6082 q.breakable()
6083 q.text('}')
6084
Rich Lane7dcdf022013-12-11 14:45:27 -08006085error_msg.subtypes[7] = port_mod_failed_error_msg
6086
6087class port_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07006088 version = 3
6089 type = 19
6090 stats_type = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07006091
6092 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006093 if xid != None:
6094 self.xid = xid
6095 else:
6096 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006097 if flags != None:
6098 self.flags = flags
6099 else:
6100 self.flags = 0
6101 if entries != None:
6102 self.entries = entries
6103 else:
6104 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08006105 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006106
6107 def pack(self):
6108 packed = []
6109 packed.append(struct.pack("!B", self.version))
6110 packed.append(struct.pack("!B", self.type))
6111 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6112 packed.append(struct.pack("!L", self.xid))
6113 packed.append(struct.pack("!H", self.stats_type))
6114 packed.append(struct.pack("!H", self.flags))
6115 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08006116 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006117 length = sum([len(x) for x in packed])
6118 packed[2] = struct.pack("!H", length)
6119 return ''.join(packed)
6120
6121 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006122 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006123 obj = port_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07006124 _version = reader.read("!B")[0]
6125 assert(_version == 3)
6126 _type = reader.read("!B")[0]
6127 assert(_type == 19)
6128 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006129 orig_reader = reader
6130 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006131 obj.xid = reader.read("!L")[0]
6132 _stats_type = reader.read("!H")[0]
6133 assert(_stats_type == 4)
6134 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006135 reader.skip(4)
6136 obj.entries = loxi.generic_util.unpack_list(reader, common.port_stats_entry.unpack)
6137 return obj
6138
6139 def __eq__(self, other):
6140 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006141 if self.xid != other.xid: return False
6142 if self.flags != other.flags: return False
6143 if self.entries != other.entries: return False
6144 return True
6145
Rich Lanec2ee4b82013-04-24 17:12:38 -07006146 def pretty_print(self, q):
6147 q.text("port_stats_reply {")
6148 with q.group():
6149 with q.indent(2):
6150 q.breakable()
6151 q.text("xid = ");
6152 if self.xid != None:
6153 q.text("%#x" % self.xid)
6154 else:
6155 q.text('None')
6156 q.text(","); q.breakable()
6157 q.text("flags = ");
6158 q.text("%#x" % self.flags)
6159 q.text(","); q.breakable()
6160 q.text("entries = ");
6161 q.pp(self.entries)
6162 q.breakable()
6163 q.text('}')
6164
Rich Lane7dcdf022013-12-11 14:45:27 -08006165stats_reply.subtypes[4] = port_stats_reply
6166
6167class port_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07006168 version = 3
6169 type = 18
6170 stats_type = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07006171
6172 def __init__(self, xid=None, flags=None, port_no=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006173 if xid != None:
6174 self.xid = xid
6175 else:
6176 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006177 if flags != None:
6178 self.flags = flags
6179 else:
6180 self.flags = 0
6181 if port_no != None:
6182 self.port_no = port_no
6183 else:
6184 self.port_no = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08006185 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006186
6187 def pack(self):
6188 packed = []
6189 packed.append(struct.pack("!B", self.version))
6190 packed.append(struct.pack("!B", self.type))
6191 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6192 packed.append(struct.pack("!L", self.xid))
6193 packed.append(struct.pack("!H", self.stats_type))
6194 packed.append(struct.pack("!H", self.flags))
6195 packed.append('\x00' * 4)
Dan Talaycof6202252013-07-02 01:00:29 -07006196 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006197 packed.append('\x00' * 4)
6198 length = sum([len(x) for x in packed])
6199 packed[2] = struct.pack("!H", length)
6200 return ''.join(packed)
6201
6202 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006203 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006204 obj = port_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07006205 _version = reader.read("!B")[0]
6206 assert(_version == 3)
6207 _type = reader.read("!B")[0]
6208 assert(_type == 18)
6209 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006210 orig_reader = reader
6211 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006212 obj.xid = reader.read("!L")[0]
6213 _stats_type = reader.read("!H")[0]
6214 assert(_stats_type == 4)
6215 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006216 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07006217 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006218 reader.skip(4)
6219 return obj
6220
6221 def __eq__(self, other):
6222 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006223 if self.xid != other.xid: return False
6224 if self.flags != other.flags: return False
6225 if self.port_no != other.port_no: return False
6226 return True
6227
Rich Lanec2ee4b82013-04-24 17:12:38 -07006228 def pretty_print(self, q):
6229 q.text("port_stats_request {")
6230 with q.group():
6231 with q.indent(2):
6232 q.breakable()
6233 q.text("xid = ");
6234 if self.xid != None:
6235 q.text("%#x" % self.xid)
6236 else:
6237 q.text('None')
6238 q.text(","); q.breakable()
6239 q.text("flags = ");
6240 q.text("%#x" % self.flags)
6241 q.text(","); q.breakable()
6242 q.text("port_no = ");
6243 q.text(util.pretty_port(self.port_no))
6244 q.breakable()
6245 q.text('}')
6246
Rich Lane7dcdf022013-12-11 14:45:27 -08006247stats_request.subtypes[4] = port_stats_request
6248
6249class port_status(message):
Dan Talaycof6202252013-07-02 01:00:29 -07006250 version = 3
6251 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -07006252
6253 def __init__(self, xid=None, reason=None, desc=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006254 if xid != None:
6255 self.xid = xid
6256 else:
6257 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006258 if reason != None:
6259 self.reason = reason
6260 else:
6261 self.reason = 0
6262 if desc != None:
6263 self.desc = desc
6264 else:
6265 self.desc = common.port_desc()
Rich Lane7dcdf022013-12-11 14:45:27 -08006266 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006267
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("!B", self.reason))
6275 packed.append('\x00' * 7)
6276 packed.append(self.desc.pack())
6277 length = sum([len(x) for x in packed])
6278 packed[2] = struct.pack("!H", length)
6279 return ''.join(packed)
6280
6281 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006282 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006283 obj = port_status()
Dan Talaycof6202252013-07-02 01:00:29 -07006284 _version = reader.read("!B")[0]
6285 assert(_version == 3)
6286 _type = reader.read("!B")[0]
6287 assert(_type == 12)
6288 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006289 orig_reader = reader
6290 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006291 obj.xid = reader.read("!L")[0]
6292 obj.reason = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006293 reader.skip(7)
6294 obj.desc = common.port_desc.unpack(reader)
6295 return obj
6296
6297 def __eq__(self, other):
6298 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006299 if self.xid != other.xid: return False
6300 if self.reason != other.reason: return False
6301 if self.desc != other.desc: return False
6302 return True
6303
Rich Lanec2ee4b82013-04-24 17:12:38 -07006304 def pretty_print(self, q):
6305 q.text("port_status {")
6306 with q.group():
6307 with q.indent(2):
6308 q.breakable()
6309 q.text("xid = ");
6310 if self.xid != None:
6311 q.text("%#x" % self.xid)
6312 else:
6313 q.text('None')
6314 q.text(","); q.breakable()
6315 q.text("reason = ");
6316 q.text("%#x" % self.reason)
6317 q.text(","); q.breakable()
6318 q.text("desc = ");
6319 q.pp(self.desc)
6320 q.breakable()
6321 q.text('}')
6322
Rich Lane7dcdf022013-12-11 14:45:27 -08006323message.subtypes[12] = port_status
6324
6325class queue_get_config_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -07006326 version = 3
6327 type = 23
Rich Lanec2ee4b82013-04-24 17:12:38 -07006328
6329 def __init__(self, xid=None, port=None, queues=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006330 if xid != None:
6331 self.xid = xid
6332 else:
6333 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006334 if port != None:
6335 self.port = port
6336 else:
6337 self.port = 0
6338 if queues != None:
6339 self.queues = queues
6340 else:
6341 self.queues = []
Rich Lane7dcdf022013-12-11 14:45:27 -08006342 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006343
6344 def pack(self):
6345 packed = []
6346 packed.append(struct.pack("!B", self.version))
6347 packed.append(struct.pack("!B", self.type))
6348 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6349 packed.append(struct.pack("!L", self.xid))
Dan Talaycof6202252013-07-02 01:00:29 -07006350 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006351 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08006352 packed.append(loxi.generic_util.pack_list(self.queues))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006353 length = sum([len(x) for x in packed])
6354 packed[2] = struct.pack("!H", length)
6355 return ''.join(packed)
6356
6357 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006358 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006359 obj = queue_get_config_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07006360 _version = reader.read("!B")[0]
6361 assert(_version == 3)
6362 _type = reader.read("!B")[0]
6363 assert(_type == 23)
6364 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006365 orig_reader = reader
6366 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006367 obj.xid = reader.read("!L")[0]
6368 obj.port = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006369 reader.skip(4)
Rich Lane7dcdf022013-12-11 14:45:27 -08006370 obj.queues = loxi.generic_util.unpack_list(reader, common.packet_queue.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006371 return obj
6372
6373 def __eq__(self, other):
6374 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006375 if self.xid != other.xid: return False
6376 if self.port != other.port: return False
6377 if self.queues != other.queues: return False
6378 return True
6379
Rich Lanec2ee4b82013-04-24 17:12:38 -07006380 def pretty_print(self, q):
6381 q.text("queue_get_config_reply {")
6382 with q.group():
6383 with q.indent(2):
6384 q.breakable()
6385 q.text("xid = ");
6386 if self.xid != None:
6387 q.text("%#x" % self.xid)
6388 else:
6389 q.text('None')
6390 q.text(","); q.breakable()
6391 q.text("port = ");
6392 q.text(util.pretty_port(self.port))
6393 q.text(","); q.breakable()
6394 q.text("queues = ");
6395 q.pp(self.queues)
6396 q.breakable()
6397 q.text('}')
6398
Rich Lane7dcdf022013-12-11 14:45:27 -08006399message.subtypes[23] = queue_get_config_reply
6400
6401class queue_get_config_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -07006402 version = 3
6403 type = 22
Rich Lanec2ee4b82013-04-24 17:12:38 -07006404
6405 def __init__(self, xid=None, port=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006406 if xid != None:
6407 self.xid = xid
6408 else:
6409 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006410 if port != None:
6411 self.port = port
6412 else:
6413 self.port = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08006414 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006415
6416 def pack(self):
6417 packed = []
6418 packed.append(struct.pack("!B", self.version))
6419 packed.append(struct.pack("!B", self.type))
6420 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6421 packed.append(struct.pack("!L", self.xid))
Dan Talaycof6202252013-07-02 01:00:29 -07006422 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006423 packed.append('\x00' * 4)
6424 length = sum([len(x) for x in packed])
6425 packed[2] = struct.pack("!H", length)
6426 return ''.join(packed)
6427
6428 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006429 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006430 obj = queue_get_config_request()
Dan Talaycof6202252013-07-02 01:00:29 -07006431 _version = reader.read("!B")[0]
6432 assert(_version == 3)
6433 _type = reader.read("!B")[0]
6434 assert(_type == 22)
6435 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006436 orig_reader = reader
6437 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006438 obj.xid = reader.read("!L")[0]
6439 obj.port = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006440 reader.skip(4)
6441 return obj
6442
6443 def __eq__(self, other):
6444 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006445 if self.xid != other.xid: return False
6446 if self.port != other.port: return False
6447 return True
6448
Rich Lanec2ee4b82013-04-24 17:12:38 -07006449 def pretty_print(self, q):
6450 q.text("queue_get_config_request {")
6451 with q.group():
6452 with q.indent(2):
6453 q.breakable()
6454 q.text("xid = ");
6455 if self.xid != None:
6456 q.text("%#x" % self.xid)
6457 else:
6458 q.text('None')
6459 q.text(","); q.breakable()
6460 q.text("port = ");
6461 q.text(util.pretty_port(self.port))
6462 q.breakable()
6463 q.text('}')
6464
Rich Lane7dcdf022013-12-11 14:45:27 -08006465message.subtypes[22] = queue_get_config_request
6466
6467class queue_op_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07006468 version = 3
6469 type = 1
6470 err_type = 9
6471
6472 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006473 if xid != None:
6474 self.xid = xid
6475 else:
6476 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07006477 if code != None:
6478 self.code = code
6479 else:
6480 self.code = 0
6481 if data != None:
6482 self.data = data
6483 else:
6484 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08006485 return
Rich Lane6f4978c2013-10-20 21:33:52 -07006486
6487 def pack(self):
6488 packed = []
6489 packed.append(struct.pack("!B", self.version))
6490 packed.append(struct.pack("!B", self.type))
6491 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6492 packed.append(struct.pack("!L", self.xid))
6493 packed.append(struct.pack("!H", self.err_type))
6494 packed.append(struct.pack("!H", self.code))
6495 packed.append(self.data)
6496 length = sum([len(x) for x in packed])
6497 packed[2] = struct.pack("!H", length)
6498 return ''.join(packed)
6499
6500 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006501 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07006502 obj = queue_op_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07006503 _version = reader.read("!B")[0]
6504 assert(_version == 3)
6505 _type = reader.read("!B")[0]
6506 assert(_type == 1)
6507 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006508 orig_reader = reader
6509 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07006510 obj.xid = reader.read("!L")[0]
6511 _err_type = reader.read("!H")[0]
6512 assert(_err_type == 9)
6513 obj.code = reader.read("!H")[0]
6514 obj.data = str(reader.read_all())
6515 return obj
6516
6517 def __eq__(self, other):
6518 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07006519 if self.xid != other.xid: return False
6520 if self.code != other.code: return False
6521 if self.data != other.data: return False
6522 return True
6523
Rich Lane6f4978c2013-10-20 21:33:52 -07006524 def pretty_print(self, q):
6525 q.text("queue_op_failed_error_msg {")
6526 with q.group():
6527 with q.indent(2):
6528 q.breakable()
6529 q.text("xid = ");
6530 if self.xid != None:
6531 q.text("%#x" % self.xid)
6532 else:
6533 q.text('None')
6534 q.text(","); q.breakable()
6535 q.text("code = ");
6536 q.text("%#x" % self.code)
6537 q.text(","); q.breakable()
6538 q.text("data = ");
6539 q.pp(self.data)
6540 q.breakable()
6541 q.text('}')
6542
Rich Lane7dcdf022013-12-11 14:45:27 -08006543error_msg.subtypes[9] = queue_op_failed_error_msg
6544
6545class queue_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07006546 version = 3
6547 type = 19
6548 stats_type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07006549
6550 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006551 if xid != None:
6552 self.xid = xid
6553 else:
6554 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006555 if flags != None:
6556 self.flags = flags
6557 else:
6558 self.flags = 0
6559 if entries != None:
6560 self.entries = entries
6561 else:
6562 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08006563 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006564
6565 def pack(self):
6566 packed = []
6567 packed.append(struct.pack("!B", self.version))
6568 packed.append(struct.pack("!B", self.type))
6569 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6570 packed.append(struct.pack("!L", self.xid))
6571 packed.append(struct.pack("!H", self.stats_type))
6572 packed.append(struct.pack("!H", self.flags))
6573 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08006574 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006575 length = sum([len(x) for x in packed])
6576 packed[2] = struct.pack("!H", length)
6577 return ''.join(packed)
6578
6579 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006580 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006581 obj = queue_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07006582 _version = reader.read("!B")[0]
6583 assert(_version == 3)
6584 _type = reader.read("!B")[0]
6585 assert(_type == 19)
6586 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006587 orig_reader = reader
6588 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006589 obj.xid = reader.read("!L")[0]
6590 _stats_type = reader.read("!H")[0]
6591 assert(_stats_type == 5)
6592 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006593 reader.skip(4)
6594 obj.entries = loxi.generic_util.unpack_list(reader, common.queue_stats_entry.unpack)
6595 return obj
6596
6597 def __eq__(self, other):
6598 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006599 if self.xid != other.xid: return False
6600 if self.flags != other.flags: return False
6601 if self.entries != other.entries: return False
6602 return True
6603
Rich Lanec2ee4b82013-04-24 17:12:38 -07006604 def pretty_print(self, q):
6605 q.text("queue_stats_reply {")
6606 with q.group():
6607 with q.indent(2):
6608 q.breakable()
6609 q.text("xid = ");
6610 if self.xid != None:
6611 q.text("%#x" % self.xid)
6612 else:
6613 q.text('None')
6614 q.text(","); q.breakable()
6615 q.text("flags = ");
6616 q.text("%#x" % self.flags)
6617 q.text(","); q.breakable()
6618 q.text("entries = ");
6619 q.pp(self.entries)
6620 q.breakable()
6621 q.text('}')
6622
Rich Lane7dcdf022013-12-11 14:45:27 -08006623stats_reply.subtypes[5] = queue_stats_reply
6624
6625class queue_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07006626 version = 3
6627 type = 18
6628 stats_type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07006629
6630 def __init__(self, xid=None, flags=None, port_no=None, queue_id=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006631 if xid != None:
6632 self.xid = xid
6633 else:
6634 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006635 if flags != None:
6636 self.flags = flags
6637 else:
6638 self.flags = 0
6639 if port_no != None:
6640 self.port_no = port_no
6641 else:
6642 self.port_no = 0
6643 if queue_id != None:
6644 self.queue_id = queue_id
6645 else:
6646 self.queue_id = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08006647 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006648
6649 def pack(self):
6650 packed = []
6651 packed.append(struct.pack("!B", self.version))
6652 packed.append(struct.pack("!B", self.type))
6653 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6654 packed.append(struct.pack("!L", self.xid))
6655 packed.append(struct.pack("!H", self.stats_type))
6656 packed.append(struct.pack("!H", self.flags))
6657 packed.append('\x00' * 4)
Dan Talaycof6202252013-07-02 01:00:29 -07006658 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006659 packed.append(struct.pack("!L", self.queue_id))
6660 length = sum([len(x) for x in packed])
6661 packed[2] = struct.pack("!H", length)
6662 return ''.join(packed)
6663
6664 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006665 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006666 obj = queue_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07006667 _version = reader.read("!B")[0]
6668 assert(_version == 3)
6669 _type = reader.read("!B")[0]
6670 assert(_type == 18)
6671 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006672 orig_reader = reader
6673 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006674 obj.xid = reader.read("!L")[0]
6675 _stats_type = reader.read("!H")[0]
6676 assert(_stats_type == 5)
6677 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006678 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07006679 obj.port_no = util.unpack_port_no(reader)
6680 obj.queue_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006681 return obj
6682
6683 def __eq__(self, other):
6684 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006685 if self.xid != other.xid: return False
6686 if self.flags != other.flags: return False
6687 if self.port_no != other.port_no: return False
6688 if self.queue_id != other.queue_id: return False
6689 return True
6690
Rich Lanec2ee4b82013-04-24 17:12:38 -07006691 def pretty_print(self, q):
6692 q.text("queue_stats_request {")
6693 with q.group():
6694 with q.indent(2):
6695 q.breakable()
6696 q.text("xid = ");
6697 if self.xid != None:
6698 q.text("%#x" % self.xid)
6699 else:
6700 q.text('None')
6701 q.text(","); q.breakable()
6702 q.text("flags = ");
6703 q.text("%#x" % self.flags)
6704 q.text(","); q.breakable()
6705 q.text("port_no = ");
6706 q.text(util.pretty_port(self.port_no))
6707 q.text(","); q.breakable()
6708 q.text("queue_id = ");
6709 q.text("%#x" % self.queue_id)
6710 q.breakable()
6711 q.text('}')
6712
Rich Lane7dcdf022013-12-11 14:45:27 -08006713stats_request.subtypes[5] = queue_stats_request
6714
6715class role_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -07006716 version = 3
6717 type = 25
Rich Lanec2ee4b82013-04-24 17:12:38 -07006718
Rich Laned9e3f7b2013-11-04 11:40:43 -08006719 def __init__(self, xid=None, role=None, generation_id=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006720 if xid != None:
6721 self.xid = xid
6722 else:
6723 self.xid = None
Rich Laned9e3f7b2013-11-04 11:40:43 -08006724 if role != None:
6725 self.role = role
Rich Lanec2ee4b82013-04-24 17:12:38 -07006726 else:
Rich Laned9e3f7b2013-11-04 11:40:43 -08006727 self.role = 0
6728 if generation_id != None:
6729 self.generation_id = generation_id
6730 else:
6731 self.generation_id = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08006732 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006733
6734 def pack(self):
6735 packed = []
6736 packed.append(struct.pack("!B", self.version))
6737 packed.append(struct.pack("!B", self.type))
6738 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6739 packed.append(struct.pack("!L", self.xid))
Rich Laned9e3f7b2013-11-04 11:40:43 -08006740 packed.append(struct.pack("!L", self.role))
6741 packed.append('\x00' * 4)
6742 packed.append(struct.pack("!Q", self.generation_id))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006743 length = sum([len(x) for x in packed])
6744 packed[2] = struct.pack("!H", length)
6745 return ''.join(packed)
6746
6747 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006748 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006749 obj = role_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07006750 _version = reader.read("!B")[0]
6751 assert(_version == 3)
6752 _type = reader.read("!B")[0]
6753 assert(_type == 25)
6754 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006755 orig_reader = reader
6756 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006757 obj.xid = reader.read("!L")[0]
Rich Laned9e3f7b2013-11-04 11:40:43 -08006758 obj.role = reader.read("!L")[0]
6759 reader.skip(4)
6760 obj.generation_id = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006761 return obj
6762
6763 def __eq__(self, other):
6764 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006765 if self.xid != other.xid: return False
Rich Laned9e3f7b2013-11-04 11:40:43 -08006766 if self.role != other.role: return False
6767 if self.generation_id != other.generation_id: return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006768 return True
6769
Rich Lanec2ee4b82013-04-24 17:12:38 -07006770 def pretty_print(self, q):
6771 q.text("role_reply {")
6772 with q.group():
6773 with q.indent(2):
6774 q.breakable()
6775 q.text("xid = ");
6776 if self.xid != None:
6777 q.text("%#x" % self.xid)
6778 else:
6779 q.text('None')
6780 q.text(","); q.breakable()
Rich Laned9e3f7b2013-11-04 11:40:43 -08006781 q.text("role = ");
6782 q.text("%#x" % self.role)
6783 q.text(","); q.breakable()
6784 q.text("generation_id = ");
6785 q.text("%#x" % self.generation_id)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006786 q.breakable()
6787 q.text('}')
6788
Rich Lane7dcdf022013-12-11 14:45:27 -08006789message.subtypes[25] = role_reply
6790
6791class role_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -07006792 version = 3
6793 type = 24
Rich Lanec2ee4b82013-04-24 17:12:38 -07006794
6795 def __init__(self, xid=None, role=None, generation_id=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006796 if xid != None:
6797 self.xid = xid
6798 else:
6799 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006800 if role != None:
6801 self.role = role
6802 else:
6803 self.role = 0
6804 if generation_id != None:
6805 self.generation_id = generation_id
6806 else:
6807 self.generation_id = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08006808 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006809
6810 def pack(self):
6811 packed = []
6812 packed.append(struct.pack("!B", self.version))
6813 packed.append(struct.pack("!B", self.type))
6814 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6815 packed.append(struct.pack("!L", self.xid))
6816 packed.append(struct.pack("!L", self.role))
6817 packed.append('\x00' * 4)
6818 packed.append(struct.pack("!Q", self.generation_id))
6819 length = sum([len(x) for x in packed])
6820 packed[2] = struct.pack("!H", length)
6821 return ''.join(packed)
6822
6823 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006824 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006825 obj = role_request()
Dan Talaycof6202252013-07-02 01:00:29 -07006826 _version = reader.read("!B")[0]
6827 assert(_version == 3)
6828 _type = reader.read("!B")[0]
6829 assert(_type == 24)
6830 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006831 orig_reader = reader
6832 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006833 obj.xid = reader.read("!L")[0]
6834 obj.role = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006835 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07006836 obj.generation_id = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006837 return obj
6838
6839 def __eq__(self, other):
6840 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006841 if self.xid != other.xid: return False
6842 if self.role != other.role: return False
6843 if self.generation_id != other.generation_id: return False
6844 return True
6845
Rich Lanec2ee4b82013-04-24 17:12:38 -07006846 def pretty_print(self, q):
6847 q.text("role_request {")
6848 with q.group():
6849 with q.indent(2):
6850 q.breakable()
6851 q.text("xid = ");
6852 if self.xid != None:
6853 q.text("%#x" % self.xid)
6854 else:
6855 q.text('None')
6856 q.text(","); q.breakable()
6857 q.text("role = ");
6858 q.text("%#x" % self.role)
6859 q.text(","); q.breakable()
6860 q.text("generation_id = ");
6861 q.text("%#x" % self.generation_id)
6862 q.breakable()
6863 q.text('}')
6864
Rich Lane7dcdf022013-12-11 14:45:27 -08006865message.subtypes[24] = role_request
6866
6867class role_request_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07006868 version = 3
6869 type = 1
6870 err_type = 11
6871
6872 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006873 if xid != None:
6874 self.xid = xid
6875 else:
6876 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07006877 if code != None:
6878 self.code = code
6879 else:
6880 self.code = 0
6881 if data != None:
6882 self.data = data
6883 else:
6884 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08006885 return
Rich Lane6f4978c2013-10-20 21:33:52 -07006886
6887 def pack(self):
6888 packed = []
6889 packed.append(struct.pack("!B", self.version))
6890 packed.append(struct.pack("!B", self.type))
6891 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6892 packed.append(struct.pack("!L", self.xid))
6893 packed.append(struct.pack("!H", self.err_type))
6894 packed.append(struct.pack("!H", self.code))
6895 packed.append(self.data)
6896 length = sum([len(x) for x in packed])
6897 packed[2] = struct.pack("!H", length)
6898 return ''.join(packed)
6899
6900 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006901 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07006902 obj = role_request_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07006903 _version = reader.read("!B")[0]
6904 assert(_version == 3)
6905 _type = reader.read("!B")[0]
6906 assert(_type == 1)
6907 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006908 orig_reader = reader
6909 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07006910 obj.xid = reader.read("!L")[0]
6911 _err_type = reader.read("!H")[0]
6912 assert(_err_type == 11)
6913 obj.code = reader.read("!H")[0]
6914 obj.data = str(reader.read_all())
6915 return obj
6916
6917 def __eq__(self, other):
6918 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07006919 if self.xid != other.xid: return False
6920 if self.code != other.code: return False
6921 if self.data != other.data: return False
6922 return True
6923
Rich Lane6f4978c2013-10-20 21:33:52 -07006924 def pretty_print(self, q):
6925 q.text("role_request_failed_error_msg {")
6926 with q.group():
6927 with q.indent(2):
6928 q.breakable()
6929 q.text("xid = ");
6930 if self.xid != None:
6931 q.text("%#x" % self.xid)
6932 else:
6933 q.text('None')
6934 q.text(","); q.breakable()
6935 q.text("code = ");
6936 q.text("%#x" % self.code)
6937 q.text(","); q.breakable()
6938 q.text("data = ");
6939 q.pp(self.data)
6940 q.breakable()
6941 q.text('}')
6942
Rich Lane7dcdf022013-12-11 14:45:27 -08006943error_msg.subtypes[11] = role_request_failed_error_msg
6944
6945class set_config(message):
Dan Talaycof6202252013-07-02 01:00:29 -07006946 version = 3
6947 type = 9
Rich Lanec2ee4b82013-04-24 17:12:38 -07006948
6949 def __init__(self, xid=None, flags=None, miss_send_len=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006950 if xid != None:
6951 self.xid = xid
6952 else:
6953 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006954 if flags != None:
6955 self.flags = flags
6956 else:
6957 self.flags = 0
6958 if miss_send_len != None:
6959 self.miss_send_len = miss_send_len
6960 else:
6961 self.miss_send_len = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08006962 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006963
6964 def pack(self):
6965 packed = []
6966 packed.append(struct.pack("!B", self.version))
6967 packed.append(struct.pack("!B", self.type))
6968 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6969 packed.append(struct.pack("!L", self.xid))
6970 packed.append(struct.pack("!H", self.flags))
6971 packed.append(struct.pack("!H", self.miss_send_len))
6972 length = sum([len(x) for x in packed])
6973 packed[2] = struct.pack("!H", length)
6974 return ''.join(packed)
6975
6976 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006977 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006978 obj = set_config()
Dan Talaycof6202252013-07-02 01:00:29 -07006979 _version = reader.read("!B")[0]
6980 assert(_version == 3)
6981 _type = reader.read("!B")[0]
6982 assert(_type == 9)
6983 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006984 orig_reader = reader
6985 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006986 obj.xid = reader.read("!L")[0]
6987 obj.flags = reader.read("!H")[0]
6988 obj.miss_send_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006989 return obj
6990
6991 def __eq__(self, other):
6992 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006993 if self.xid != other.xid: return False
6994 if self.flags != other.flags: return False
6995 if self.miss_send_len != other.miss_send_len: return False
6996 return True
6997
Rich Lanec2ee4b82013-04-24 17:12:38 -07006998 def pretty_print(self, q):
6999 q.text("set_config {")
7000 with q.group():
7001 with q.indent(2):
7002 q.breakable()
7003 q.text("xid = ");
7004 if self.xid != None:
7005 q.text("%#x" % self.xid)
7006 else:
7007 q.text('None')
7008 q.text(","); q.breakable()
7009 q.text("flags = ");
7010 q.text("%#x" % self.flags)
7011 q.text(","); q.breakable()
7012 q.text("miss_send_len = ");
7013 q.text("%#x" % self.miss_send_len)
7014 q.breakable()
7015 q.text('}')
7016
Rich Lane7dcdf022013-12-11 14:45:27 -08007017message.subtypes[9] = set_config
7018
7019class switch_config_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07007020 version = 3
7021 type = 1
7022 err_type = 10
7023
7024 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007025 if xid != None:
7026 self.xid = xid
7027 else:
7028 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07007029 if code != None:
7030 self.code = code
7031 else:
7032 self.code = 0
7033 if data != None:
7034 self.data = data
7035 else:
7036 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08007037 return
Rich Lane6f4978c2013-10-20 21:33:52 -07007038
7039 def pack(self):
7040 packed = []
7041 packed.append(struct.pack("!B", self.version))
7042 packed.append(struct.pack("!B", self.type))
7043 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7044 packed.append(struct.pack("!L", self.xid))
7045 packed.append(struct.pack("!H", self.err_type))
7046 packed.append(struct.pack("!H", self.code))
7047 packed.append(self.data)
7048 length = sum([len(x) for x in packed])
7049 packed[2] = struct.pack("!H", length)
7050 return ''.join(packed)
7051
7052 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007053 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07007054 obj = switch_config_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07007055 _version = reader.read("!B")[0]
7056 assert(_version == 3)
7057 _type = reader.read("!B")[0]
7058 assert(_type == 1)
7059 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007060 orig_reader = reader
7061 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07007062 obj.xid = reader.read("!L")[0]
7063 _err_type = reader.read("!H")[0]
7064 assert(_err_type == 10)
7065 obj.code = reader.read("!H")[0]
7066 obj.data = str(reader.read_all())
7067 return obj
7068
7069 def __eq__(self, other):
7070 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07007071 if self.xid != other.xid: return False
7072 if self.code != other.code: return False
7073 if self.data != other.data: return False
7074 return True
7075
Rich Lane6f4978c2013-10-20 21:33:52 -07007076 def pretty_print(self, q):
7077 q.text("switch_config_failed_error_msg {")
7078 with q.group():
7079 with q.indent(2):
7080 q.breakable()
7081 q.text("xid = ");
7082 if self.xid != None:
7083 q.text("%#x" % self.xid)
7084 else:
7085 q.text('None')
7086 q.text(","); q.breakable()
7087 q.text("code = ");
7088 q.text("%#x" % self.code)
7089 q.text(","); q.breakable()
7090 q.text("data = ");
7091 q.pp(self.data)
7092 q.breakable()
7093 q.text('}')
7094
Rich Lane7dcdf022013-12-11 14:45:27 -08007095error_msg.subtypes[10] = switch_config_failed_error_msg
7096
7097class table_mod(message):
Dan Talaycof6202252013-07-02 01:00:29 -07007098 version = 3
7099 type = 17
Rich Lanec2ee4b82013-04-24 17:12:38 -07007100
7101 def __init__(self, xid=None, table_id=None, config=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007102 if xid != None:
7103 self.xid = xid
7104 else:
7105 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007106 if table_id != None:
7107 self.table_id = table_id
7108 else:
7109 self.table_id = 0
7110 if config != None:
7111 self.config = config
7112 else:
7113 self.config = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08007114 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007115
7116 def pack(self):
7117 packed = []
7118 packed.append(struct.pack("!B", self.version))
7119 packed.append(struct.pack("!B", self.type))
7120 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7121 packed.append(struct.pack("!L", self.xid))
7122 packed.append(struct.pack("!B", self.table_id))
7123 packed.append('\x00' * 3)
7124 packed.append(struct.pack("!L", self.config))
7125 length = sum([len(x) for x in packed])
7126 packed[2] = struct.pack("!H", length)
7127 return ''.join(packed)
7128
7129 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007130 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007131 obj = table_mod()
Dan Talaycof6202252013-07-02 01:00:29 -07007132 _version = reader.read("!B")[0]
7133 assert(_version == 3)
7134 _type = reader.read("!B")[0]
7135 assert(_type == 17)
7136 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007137 orig_reader = reader
7138 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07007139 obj.xid = reader.read("!L")[0]
7140 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007141 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07007142 obj.config = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007143 return obj
7144
7145 def __eq__(self, other):
7146 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007147 if self.xid != other.xid: return False
7148 if self.table_id != other.table_id: return False
7149 if self.config != other.config: return False
7150 return True
7151
Rich Lanec2ee4b82013-04-24 17:12:38 -07007152 def pretty_print(self, q):
7153 q.text("table_mod {")
7154 with q.group():
7155 with q.indent(2):
7156 q.breakable()
7157 q.text("xid = ");
7158 if self.xid != None:
7159 q.text("%#x" % self.xid)
7160 else:
7161 q.text('None')
7162 q.text(","); q.breakable()
7163 q.text("table_id = ");
7164 q.text("%#x" % self.table_id)
7165 q.text(","); q.breakable()
7166 q.text("config = ");
7167 q.text("%#x" % self.config)
7168 q.breakable()
7169 q.text('}')
7170
Rich Lane7dcdf022013-12-11 14:45:27 -08007171message.subtypes[17] = table_mod
7172
7173class table_mod_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07007174 version = 3
7175 type = 1
7176 err_type = 8
7177
7178 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007179 if xid != None:
7180 self.xid = xid
7181 else:
7182 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07007183 if code != None:
7184 self.code = code
7185 else:
7186 self.code = 0
7187 if data != None:
7188 self.data = data
7189 else:
7190 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08007191 return
Rich Lane6f4978c2013-10-20 21:33:52 -07007192
7193 def pack(self):
7194 packed = []
7195 packed.append(struct.pack("!B", self.version))
7196 packed.append(struct.pack("!B", self.type))
7197 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7198 packed.append(struct.pack("!L", self.xid))
7199 packed.append(struct.pack("!H", self.err_type))
7200 packed.append(struct.pack("!H", self.code))
7201 packed.append(self.data)
7202 length = sum([len(x) for x in packed])
7203 packed[2] = struct.pack("!H", length)
7204 return ''.join(packed)
7205
7206 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007207 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07007208 obj = table_mod_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07007209 _version = reader.read("!B")[0]
7210 assert(_version == 3)
7211 _type = reader.read("!B")[0]
7212 assert(_type == 1)
7213 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007214 orig_reader = reader
7215 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07007216 obj.xid = reader.read("!L")[0]
7217 _err_type = reader.read("!H")[0]
7218 assert(_err_type == 8)
7219 obj.code = reader.read("!H")[0]
7220 obj.data = str(reader.read_all())
7221 return obj
7222
7223 def __eq__(self, other):
7224 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07007225 if self.xid != other.xid: return False
7226 if self.code != other.code: return False
7227 if self.data != other.data: return False
7228 return True
7229
Rich Lane6f4978c2013-10-20 21:33:52 -07007230 def pretty_print(self, q):
7231 q.text("table_mod_failed_error_msg {")
7232 with q.group():
7233 with q.indent(2):
7234 q.breakable()
7235 q.text("xid = ");
7236 if self.xid != None:
7237 q.text("%#x" % self.xid)
7238 else:
7239 q.text('None')
7240 q.text(","); q.breakable()
7241 q.text("code = ");
7242 q.text("%#x" % self.code)
7243 q.text(","); q.breakable()
7244 q.text("data = ");
7245 q.pp(self.data)
7246 q.breakable()
7247 q.text('}')
7248
Rich Lane7dcdf022013-12-11 14:45:27 -08007249error_msg.subtypes[8] = table_mod_failed_error_msg
7250
7251class table_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07007252 version = 3
7253 type = 19
7254 stats_type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07007255
7256 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007257 if xid != None:
7258 self.xid = xid
7259 else:
7260 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007261 if flags != None:
7262 self.flags = flags
7263 else:
7264 self.flags = 0
7265 if entries != None:
7266 self.entries = entries
7267 else:
7268 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08007269 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007270
7271 def pack(self):
7272 packed = []
7273 packed.append(struct.pack("!B", self.version))
7274 packed.append(struct.pack("!B", self.type))
7275 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7276 packed.append(struct.pack("!L", self.xid))
7277 packed.append(struct.pack("!H", self.stats_type))
7278 packed.append(struct.pack("!H", self.flags))
7279 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08007280 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007281 length = sum([len(x) for x in packed])
7282 packed[2] = struct.pack("!H", length)
7283 return ''.join(packed)
7284
7285 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007286 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007287 obj = table_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07007288 _version = reader.read("!B")[0]
7289 assert(_version == 3)
7290 _type = reader.read("!B")[0]
7291 assert(_type == 19)
7292 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007293 orig_reader = reader
7294 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07007295 obj.xid = reader.read("!L")[0]
7296 _stats_type = reader.read("!H")[0]
7297 assert(_stats_type == 3)
7298 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007299 reader.skip(4)
7300 obj.entries = loxi.generic_util.unpack_list(reader, common.table_stats_entry.unpack)
7301 return obj
7302
7303 def __eq__(self, other):
7304 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007305 if self.xid != other.xid: return False
7306 if self.flags != other.flags: return False
7307 if self.entries != other.entries: return False
7308 return True
7309
Rich Lanec2ee4b82013-04-24 17:12:38 -07007310 def pretty_print(self, q):
7311 q.text("table_stats_reply {")
7312 with q.group():
7313 with q.indent(2):
7314 q.breakable()
7315 q.text("xid = ");
7316 if self.xid != None:
7317 q.text("%#x" % self.xid)
7318 else:
7319 q.text('None')
7320 q.text(","); q.breakable()
7321 q.text("flags = ");
7322 q.text("%#x" % self.flags)
7323 q.text(","); q.breakable()
7324 q.text("entries = ");
7325 q.pp(self.entries)
7326 q.breakable()
7327 q.text('}')
7328
Rich Lane7dcdf022013-12-11 14:45:27 -08007329stats_reply.subtypes[3] = table_stats_reply
7330
7331class table_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07007332 version = 3
7333 type = 18
7334 stats_type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07007335
7336 def __init__(self, xid=None, flags=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007337 if xid != None:
7338 self.xid = xid
7339 else:
7340 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007341 if flags != None:
7342 self.flags = flags
7343 else:
7344 self.flags = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08007345 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007346
7347 def pack(self):
7348 packed = []
7349 packed.append(struct.pack("!B", self.version))
7350 packed.append(struct.pack("!B", self.type))
7351 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7352 packed.append(struct.pack("!L", self.xid))
7353 packed.append(struct.pack("!H", self.stats_type))
7354 packed.append(struct.pack("!H", self.flags))
7355 packed.append('\x00' * 4)
7356 length = sum([len(x) for x in packed])
7357 packed[2] = struct.pack("!H", length)
7358 return ''.join(packed)
7359
7360 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007361 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007362 obj = table_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07007363 _version = reader.read("!B")[0]
7364 assert(_version == 3)
7365 _type = reader.read("!B")[0]
7366 assert(_type == 18)
7367 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007368 orig_reader = reader
7369 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07007370 obj.xid = reader.read("!L")[0]
7371 _stats_type = reader.read("!H")[0]
7372 assert(_stats_type == 3)
7373 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007374 reader.skip(4)
7375 return obj
7376
7377 def __eq__(self, other):
7378 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007379 if self.xid != other.xid: return False
7380 if self.flags != other.flags: return False
7381 return True
7382
Rich Lanec2ee4b82013-04-24 17:12:38 -07007383 def pretty_print(self, q):
7384 q.text("table_stats_request {")
7385 with q.group():
7386 with q.indent(2):
7387 q.breakable()
7388 q.text("xid = ");
7389 if self.xid != None:
7390 q.text("%#x" % self.xid)
7391 else:
7392 q.text('None')
7393 q.text(","); q.breakable()
7394 q.text("flags = ");
7395 q.text("%#x" % self.flags)
7396 q.breakable()
7397 q.text('}')
7398
Rich Lane7dcdf022013-12-11 14:45:27 -08007399stats_request.subtypes[3] = table_stats_request
7400
Rich Lanec2ee4b82013-04-24 17:12:38 -07007401
7402def parse_header(buf):
7403 if len(buf) < 8:
7404 raise loxi.ProtocolError("too short to be an OpenFlow message")
7405 return struct.unpack_from("!BBHL", buf)
7406
7407def parse_message(buf):
7408 msg_ver, msg_type, msg_len, msg_xid = parse_header(buf)
Rich Lanefe600f52013-07-09 13:22:32 -07007409 if msg_ver != const.OFP_VERSION and msg_type != const.OFPT_HELLO:
7410 raise loxi.ProtocolError("wrong OpenFlow version (expected %d, got %d)" % (const.OFP_VERSION, msg_ver))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007411 if len(buf) != msg_len:
7412 raise loxi.ProtocolError("incorrect message size")
Rich Lane7dcdf022013-12-11 14:45:27 -08007413 return message.unpack(loxi.generic_util.OFReader(buf))