blob: 7e2b1116138526effbec990d960aaa0c11e53d9c [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
Rich Lanec2ee4b82013-04-24 17:12:38 -070015import util
16import loxi.generic_util
17
Rich Lane7dcdf022013-12-11 14:45:27 -080018class message(loxi.OFObject):
19 subtypes = {}
Rich Lanec2ee4b82013-04-24 17:12:38 -070020
Rich Lane7dcdf022013-12-11 14:45:27 -080021 @staticmethod
22 def unpack(reader):
23 subtype, = reader.peek('B', 1)
24 try:
25 subclass = message.subtypes[subtype]
26 except KeyError:
27 raise loxi.ProtocolError("unknown message subtype %#x" % subtype)
28 return subclass.unpack(reader)
29
30
31class stats_reply(message):
32 subtypes = {}
33
34 @staticmethod
35 def unpack(reader):
36 subtype, = reader.peek('!H', 8)
37 try:
38 subclass = stats_reply.subtypes[subtype]
39 except KeyError:
40 raise loxi.ProtocolError("unknown stats_reply message subtype %#x" % subtype)
41 return subclass.unpack(reader)
42
43message.subtypes[19] = stats_reply
44
45class aggregate_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -070046 version = 2
47 type = 19
48 stats_type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -070049
50 def __init__(self, xid=None, flags=None, packet_count=None, byte_count=None, flow_count=None):
Rich Lane7dcdf022013-12-11 14:45:27 -080051 if xid != None:
52 self.xid = xid
53 else:
54 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -070055 if flags != None:
56 self.flags = flags
57 else:
58 self.flags = 0
59 if packet_count != None:
60 self.packet_count = packet_count
61 else:
62 self.packet_count = 0
63 if byte_count != None:
64 self.byte_count = byte_count
65 else:
66 self.byte_count = 0
67 if flow_count != None:
68 self.flow_count = flow_count
69 else:
70 self.flow_count = 0
Rich Lane7dcdf022013-12-11 14:45:27 -080071 return
Rich Lanec2ee4b82013-04-24 17:12:38 -070072
73 def pack(self):
74 packed = []
75 packed.append(struct.pack("!B", self.version))
76 packed.append(struct.pack("!B", self.type))
77 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
78 packed.append(struct.pack("!L", self.xid))
79 packed.append(struct.pack("!H", self.stats_type))
80 packed.append(struct.pack("!H", self.flags))
81 packed.append('\x00' * 4)
82 packed.append(struct.pack("!Q", self.packet_count))
83 packed.append(struct.pack("!Q", self.byte_count))
84 packed.append(struct.pack("!L", self.flow_count))
85 packed.append('\x00' * 4)
86 length = sum([len(x) for x in packed])
87 packed[2] = struct.pack("!H", length)
88 return ''.join(packed)
89
90 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -080091 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -070092 obj = aggregate_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -070093 _version = reader.read("!B")[0]
94 assert(_version == 2)
95 _type = reader.read("!B")[0]
96 assert(_type == 19)
97 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -080098 orig_reader = reader
99 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700100 obj.xid = reader.read("!L")[0]
101 _stats_type = reader.read("!H")[0]
102 assert(_stats_type == 2)
103 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700104 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -0700105 obj.packet_count = reader.read("!Q")[0]
106 obj.byte_count = reader.read("!Q")[0]
107 obj.flow_count = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700108 reader.skip(4)
109 return obj
110
111 def __eq__(self, other):
112 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700113 if self.xid != other.xid: return False
114 if self.flags != other.flags: return False
115 if self.packet_count != other.packet_count: return False
116 if self.byte_count != other.byte_count: return False
117 if self.flow_count != other.flow_count: return False
118 return True
119
Rich Lanec2ee4b82013-04-24 17:12:38 -0700120 def pretty_print(self, q):
121 q.text("aggregate_stats_reply {")
122 with q.group():
123 with q.indent(2):
124 q.breakable()
125 q.text("xid = ");
126 if self.xid != None:
127 q.text("%#x" % self.xid)
128 else:
129 q.text('None')
130 q.text(","); q.breakable()
131 q.text("flags = ");
132 q.text("%#x" % self.flags)
133 q.text(","); q.breakable()
134 q.text("packet_count = ");
135 q.text("%#x" % self.packet_count)
136 q.text(","); q.breakable()
137 q.text("byte_count = ");
138 q.text("%#x" % self.byte_count)
139 q.text(","); q.breakable()
140 q.text("flow_count = ");
141 q.text("%#x" % self.flow_count)
142 q.breakable()
143 q.text('}')
144
Rich Lane7dcdf022013-12-11 14:45:27 -0800145stats_reply.subtypes[2] = aggregate_stats_reply
146
147class stats_request(message):
148 subtypes = {}
149
150 @staticmethod
151 def unpack(reader):
152 subtype, = reader.peek('!H', 8)
153 try:
154 subclass = stats_request.subtypes[subtype]
155 except KeyError:
156 raise loxi.ProtocolError("unknown stats_request message subtype %#x" % subtype)
157 return subclass.unpack(reader)
158
159message.subtypes[18] = stats_request
160
161class aggregate_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -0700162 version = 2
163 type = 18
164 stats_type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -0700165
166 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 -0800167 if xid != None:
168 self.xid = xid
169 else:
170 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -0700171 if flags != None:
172 self.flags = flags
173 else:
174 self.flags = 0
175 if table_id != None:
176 self.table_id = table_id
177 else:
178 self.table_id = 0
179 if out_port != None:
180 self.out_port = out_port
181 else:
182 self.out_port = 0
183 if out_group != None:
184 self.out_group = out_group
185 else:
186 self.out_group = 0
187 if cookie != None:
188 self.cookie = cookie
189 else:
190 self.cookie = 0
191 if cookie_mask != None:
192 self.cookie_mask = cookie_mask
193 else:
194 self.cookie_mask = 0
195 if match != None:
196 self.match = match
197 else:
198 self.match = common.match()
Rich Lane7dcdf022013-12-11 14:45:27 -0800199 return
Rich Lanec2ee4b82013-04-24 17:12:38 -0700200
201 def pack(self):
202 packed = []
203 packed.append(struct.pack("!B", self.version))
204 packed.append(struct.pack("!B", self.type))
205 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
206 packed.append(struct.pack("!L", self.xid))
207 packed.append(struct.pack("!H", self.stats_type))
208 packed.append(struct.pack("!H", self.flags))
209 packed.append('\x00' * 4)
210 packed.append(struct.pack("!B", self.table_id))
211 packed.append('\x00' * 3)
Dan Talaycof6202252013-07-02 01:00:29 -0700212 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700213 packed.append(struct.pack("!L", self.out_group))
214 packed.append('\x00' * 4)
215 packed.append(struct.pack("!Q", self.cookie))
216 packed.append(struct.pack("!Q", self.cookie_mask))
217 packed.append(self.match.pack())
218 length = sum([len(x) for x in packed])
219 packed[2] = struct.pack("!H", length)
220 return ''.join(packed)
221
222 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800223 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700224 obj = aggregate_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -0700225 _version = reader.read("!B")[0]
226 assert(_version == 2)
227 _type = reader.read("!B")[0]
228 assert(_type == 18)
229 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800230 orig_reader = reader
231 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700232 obj.xid = reader.read("!L")[0]
233 _stats_type = reader.read("!H")[0]
234 assert(_stats_type == 2)
235 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700236 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -0700237 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700238 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -0700239 obj.out_port = util.unpack_port_no(reader)
240 obj.out_group = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700241 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -0700242 obj.cookie = reader.read("!Q")[0]
243 obj.cookie_mask = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700244 obj.match = common.match.unpack(reader)
245 return obj
246
247 def __eq__(self, other):
248 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700249 if self.xid != other.xid: return False
250 if self.flags != other.flags: return False
251 if self.table_id != other.table_id: return False
252 if self.out_port != other.out_port: return False
253 if self.out_group != other.out_group: return False
254 if self.cookie != other.cookie: return False
255 if self.cookie_mask != other.cookie_mask: return False
256 if self.match != other.match: return False
257 return True
258
Rich Lanec2ee4b82013-04-24 17:12:38 -0700259 def pretty_print(self, q):
260 q.text("aggregate_stats_request {")
261 with q.group():
262 with q.indent(2):
263 q.breakable()
264 q.text("xid = ");
265 if self.xid != None:
266 q.text("%#x" % self.xid)
267 else:
268 q.text('None')
269 q.text(","); q.breakable()
270 q.text("flags = ");
271 q.text("%#x" % self.flags)
272 q.text(","); q.breakable()
273 q.text("table_id = ");
274 q.text("%#x" % self.table_id)
275 q.text(","); q.breakable()
276 q.text("out_port = ");
277 q.text(util.pretty_port(self.out_port))
278 q.text(","); q.breakable()
279 q.text("out_group = ");
280 q.text("%#x" % self.out_group)
281 q.text(","); q.breakable()
282 q.text("cookie = ");
283 q.text("%#x" % self.cookie)
284 q.text(","); q.breakable()
285 q.text("cookie_mask = ");
286 q.text("%#x" % self.cookie_mask)
287 q.text(","); q.breakable()
288 q.text("match = ");
289 q.pp(self.match)
290 q.breakable()
291 q.text('}')
292
Rich Lane7dcdf022013-12-11 14:45:27 -0800293stats_request.subtypes[2] = aggregate_stats_request
294
295class error_msg(message):
296 subtypes = {}
297
298 @staticmethod
299 def unpack(reader):
300 subtype, = reader.peek('!H', 8)
301 try:
302 subclass = error_msg.subtypes[subtype]
303 except KeyError:
304 raise loxi.ProtocolError("unknown error_msg message subtype %#x" % subtype)
305 return subclass.unpack(reader)
306
307message.subtypes[1] = error_msg
308
309class bad_action_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -0700310 version = 2
311 type = 1
312 err_type = 2
313
314 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800315 if xid != None:
316 self.xid = xid
317 else:
318 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -0700319 if code != None:
320 self.code = code
321 else:
322 self.code = 0
323 if data != None:
324 self.data = data
325 else:
326 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -0800327 return
Rich Lane6f4978c2013-10-20 21:33:52 -0700328
329 def pack(self):
330 packed = []
331 packed.append(struct.pack("!B", self.version))
332 packed.append(struct.pack("!B", self.type))
333 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
334 packed.append(struct.pack("!L", self.xid))
335 packed.append(struct.pack("!H", self.err_type))
336 packed.append(struct.pack("!H", self.code))
337 packed.append(self.data)
338 length = sum([len(x) for x in packed])
339 packed[2] = struct.pack("!H", length)
340 return ''.join(packed)
341
342 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800343 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -0700344 obj = bad_action_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -0700345 _version = reader.read("!B")[0]
346 assert(_version == 2)
347 _type = reader.read("!B")[0]
348 assert(_type == 1)
349 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800350 orig_reader = reader
351 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -0700352 obj.xid = reader.read("!L")[0]
353 _err_type = reader.read("!H")[0]
354 assert(_err_type == 2)
355 obj.code = reader.read("!H")[0]
356 obj.data = str(reader.read_all())
357 return obj
358
359 def __eq__(self, other):
360 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -0700361 if self.xid != other.xid: return False
362 if self.code != other.code: return False
363 if self.data != other.data: return False
364 return True
365
Rich Lane6f4978c2013-10-20 21:33:52 -0700366 def pretty_print(self, q):
367 q.text("bad_action_error_msg {")
368 with q.group():
369 with q.indent(2):
370 q.breakable()
371 q.text("xid = ");
372 if self.xid != None:
373 q.text("%#x" % self.xid)
374 else:
375 q.text('None')
376 q.text(","); q.breakable()
377 q.text("code = ");
378 q.text("%#x" % self.code)
379 q.text(","); q.breakable()
380 q.text("data = ");
381 q.pp(self.data)
382 q.breakable()
383 q.text('}')
384
Rich Lane7dcdf022013-12-11 14:45:27 -0800385error_msg.subtypes[2] = bad_action_error_msg
386
387class bad_instruction_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -0700388 version = 2
389 type = 1
390 err_type = 3
391
392 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800393 if xid != None:
394 self.xid = xid
395 else:
396 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -0700397 if code != None:
398 self.code = code
399 else:
400 self.code = 0
401 if data != None:
402 self.data = data
403 else:
404 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -0800405 return
Rich Lane6f4978c2013-10-20 21:33:52 -0700406
407 def pack(self):
408 packed = []
409 packed.append(struct.pack("!B", self.version))
410 packed.append(struct.pack("!B", self.type))
411 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
412 packed.append(struct.pack("!L", self.xid))
413 packed.append(struct.pack("!H", self.err_type))
414 packed.append(struct.pack("!H", self.code))
415 packed.append(self.data)
416 length = sum([len(x) for x in packed])
417 packed[2] = struct.pack("!H", length)
418 return ''.join(packed)
419
420 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800421 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -0700422 obj = bad_instruction_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -0700423 _version = reader.read("!B")[0]
424 assert(_version == 2)
425 _type = reader.read("!B")[0]
426 assert(_type == 1)
427 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800428 orig_reader = reader
429 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -0700430 obj.xid = reader.read("!L")[0]
431 _err_type = reader.read("!H")[0]
432 assert(_err_type == 3)
433 obj.code = reader.read("!H")[0]
434 obj.data = str(reader.read_all())
435 return obj
436
437 def __eq__(self, other):
438 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -0700439 if self.xid != other.xid: return False
440 if self.code != other.code: return False
441 if self.data != other.data: return False
442 return True
443
Rich Lane6f4978c2013-10-20 21:33:52 -0700444 def pretty_print(self, q):
445 q.text("bad_instruction_error_msg {")
446 with q.group():
447 with q.indent(2):
448 q.breakable()
449 q.text("xid = ");
450 if self.xid != None:
451 q.text("%#x" % self.xid)
452 else:
453 q.text('None')
454 q.text(","); q.breakable()
455 q.text("code = ");
456 q.text("%#x" % self.code)
457 q.text(","); q.breakable()
458 q.text("data = ");
459 q.pp(self.data)
460 q.breakable()
461 q.text('}')
462
Rich Lane7dcdf022013-12-11 14:45:27 -0800463error_msg.subtypes[3] = bad_instruction_error_msg
464
465class bad_match_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -0700466 version = 2
467 type = 1
468 err_type = 4
469
470 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800471 if xid != None:
472 self.xid = xid
473 else:
474 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -0700475 if code != None:
476 self.code = code
477 else:
478 self.code = 0
479 if data != None:
480 self.data = data
481 else:
482 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -0800483 return
Rich Lane6f4978c2013-10-20 21:33:52 -0700484
485 def pack(self):
486 packed = []
487 packed.append(struct.pack("!B", self.version))
488 packed.append(struct.pack("!B", self.type))
489 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
490 packed.append(struct.pack("!L", self.xid))
491 packed.append(struct.pack("!H", self.err_type))
492 packed.append(struct.pack("!H", self.code))
493 packed.append(self.data)
494 length = sum([len(x) for x in packed])
495 packed[2] = struct.pack("!H", length)
496 return ''.join(packed)
497
498 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800499 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -0700500 obj = bad_match_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -0700501 _version = reader.read("!B")[0]
502 assert(_version == 2)
503 _type = reader.read("!B")[0]
504 assert(_type == 1)
505 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800506 orig_reader = reader
507 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -0700508 obj.xid = reader.read("!L")[0]
509 _err_type = reader.read("!H")[0]
510 assert(_err_type == 4)
511 obj.code = reader.read("!H")[0]
512 obj.data = str(reader.read_all())
513 return obj
514
515 def __eq__(self, other):
516 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -0700517 if self.xid != other.xid: return False
518 if self.code != other.code: return False
519 if self.data != other.data: return False
520 return True
521
Rich Lane6f4978c2013-10-20 21:33:52 -0700522 def pretty_print(self, q):
523 q.text("bad_match_error_msg {")
524 with q.group():
525 with q.indent(2):
526 q.breakable()
527 q.text("xid = ");
528 if self.xid != None:
529 q.text("%#x" % self.xid)
530 else:
531 q.text('None')
532 q.text(","); q.breakable()
533 q.text("code = ");
534 q.text("%#x" % self.code)
535 q.text(","); q.breakable()
536 q.text("data = ");
537 q.pp(self.data)
538 q.breakable()
539 q.text('}')
540
Rich Lane7dcdf022013-12-11 14:45:27 -0800541error_msg.subtypes[4] = bad_match_error_msg
542
543class bad_request_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -0700544 version = 2
545 type = 1
546 err_type = 1
547
548 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800549 if xid != None:
550 self.xid = xid
551 else:
552 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -0700553 if code != None:
554 self.code = code
555 else:
556 self.code = 0
557 if data != None:
558 self.data = data
559 else:
560 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -0800561 return
Rich Lane6f4978c2013-10-20 21:33:52 -0700562
563 def pack(self):
564 packed = []
565 packed.append(struct.pack("!B", self.version))
566 packed.append(struct.pack("!B", self.type))
567 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
568 packed.append(struct.pack("!L", self.xid))
569 packed.append(struct.pack("!H", self.err_type))
570 packed.append(struct.pack("!H", self.code))
571 packed.append(self.data)
572 length = sum([len(x) for x in packed])
573 packed[2] = struct.pack("!H", length)
574 return ''.join(packed)
575
576 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800577 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -0700578 obj = bad_request_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -0700579 _version = reader.read("!B")[0]
580 assert(_version == 2)
581 _type = reader.read("!B")[0]
582 assert(_type == 1)
583 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800584 orig_reader = reader
585 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -0700586 obj.xid = reader.read("!L")[0]
587 _err_type = reader.read("!H")[0]
588 assert(_err_type == 1)
589 obj.code = reader.read("!H")[0]
590 obj.data = str(reader.read_all())
591 return obj
592
593 def __eq__(self, other):
594 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -0700595 if self.xid != other.xid: return False
596 if self.code != other.code: return False
597 if self.data != other.data: return False
598 return True
599
Rich Lane6f4978c2013-10-20 21:33:52 -0700600 def pretty_print(self, q):
601 q.text("bad_request_error_msg {")
602 with q.group():
603 with q.indent(2):
604 q.breakable()
605 q.text("xid = ");
606 if self.xid != None:
607 q.text("%#x" % self.xid)
608 else:
609 q.text('None')
610 q.text(","); q.breakable()
611 q.text("code = ");
612 q.text("%#x" % self.code)
613 q.text(","); q.breakable()
614 q.text("data = ");
615 q.pp(self.data)
616 q.breakable()
617 q.text('}')
618
Rich Lane7dcdf022013-12-11 14:45:27 -0800619error_msg.subtypes[1] = bad_request_error_msg
620
621class barrier_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -0700622 version = 2
623 type = 21
Rich Lanec2ee4b82013-04-24 17:12:38 -0700624
625 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800626 if xid != None:
627 self.xid = xid
628 else:
629 self.xid = None
630 return
Rich Lanec2ee4b82013-04-24 17:12:38 -0700631
632 def pack(self):
633 packed = []
634 packed.append(struct.pack("!B", self.version))
635 packed.append(struct.pack("!B", self.type))
636 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
637 packed.append(struct.pack("!L", self.xid))
638 length = sum([len(x) for x in packed])
639 packed[2] = struct.pack("!H", length)
640 return ''.join(packed)
641
642 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800643 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700644 obj = barrier_reply()
Dan Talaycof6202252013-07-02 01:00:29 -0700645 _version = reader.read("!B")[0]
646 assert(_version == 2)
647 _type = reader.read("!B")[0]
648 assert(_type == 21)
649 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800650 orig_reader = reader
651 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700652 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700653 return obj
654
655 def __eq__(self, other):
656 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700657 if self.xid != other.xid: return False
658 return True
659
Rich Lanec2ee4b82013-04-24 17:12:38 -0700660 def pretty_print(self, q):
661 q.text("barrier_reply {")
662 with q.group():
663 with q.indent(2):
664 q.breakable()
665 q.text("xid = ");
666 if self.xid != None:
667 q.text("%#x" % self.xid)
668 else:
669 q.text('None')
670 q.breakable()
671 q.text('}')
672
Rich Lane7dcdf022013-12-11 14:45:27 -0800673message.subtypes[21] = barrier_reply
674
675class barrier_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -0700676 version = 2
677 type = 20
Rich Lanec2ee4b82013-04-24 17:12:38 -0700678
679 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800680 if xid != None:
681 self.xid = xid
682 else:
683 self.xid = None
684 return
Rich Lanec2ee4b82013-04-24 17:12:38 -0700685
686 def pack(self):
687 packed = []
688 packed.append(struct.pack("!B", self.version))
689 packed.append(struct.pack("!B", self.type))
690 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
691 packed.append(struct.pack("!L", self.xid))
692 length = sum([len(x) for x in packed])
693 packed[2] = struct.pack("!H", length)
694 return ''.join(packed)
695
696 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800697 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700698 obj = barrier_request()
Dan Talaycof6202252013-07-02 01:00:29 -0700699 _version = reader.read("!B")[0]
700 assert(_version == 2)
701 _type = reader.read("!B")[0]
702 assert(_type == 20)
703 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800704 orig_reader = reader
705 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700706 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700707 return obj
708
709 def __eq__(self, other):
710 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700711 if self.xid != other.xid: return False
712 return True
713
Rich Lanec2ee4b82013-04-24 17:12:38 -0700714 def pretty_print(self, q):
715 q.text("barrier_request {")
716 with q.group():
717 with q.indent(2):
718 q.breakable()
719 q.text("xid = ");
720 if self.xid != None:
721 q.text("%#x" % self.xid)
722 else:
723 q.text('None')
724 q.breakable()
725 q.text('}')
726
Rich Lane7dcdf022013-12-11 14:45:27 -0800727message.subtypes[20] = barrier_request
728
729class experimenter(message):
730 subtypes = {}
731
732 @staticmethod
733 def unpack(reader):
734 subtype, = reader.peek('!L', 8)
735 try:
736 subclass = experimenter.subtypes[subtype]
737 except KeyError:
738 raise loxi.ProtocolError("unknown experimenter message subtype %#x" % subtype)
739 return subclass.unpack(reader)
740
741message.subtypes[4] = experimenter
742
743class bsn_header(experimenter):
744 subtypes = {}
745
746 @staticmethod
747 def unpack(reader):
748 subtype, = reader.peek('!L', 12)
749 try:
750 subclass = bsn_header.subtypes[subtype]
751 except KeyError:
752 raise loxi.ProtocolError("unknown bsn_header experimenter message subtype %#x" % subtype)
753 return subclass.unpack(reader)
754
755experimenter.subtypes[6035143] = bsn_header
756
757class bsn_bw_clear_data_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -0700758 version = 2
759 type = 4
760 experimenter = 6035143
761 subtype = 22
762
763 def __init__(self, xid=None, status=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800764 if xid != None:
765 self.xid = xid
766 else:
767 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -0700768 if status != None:
769 self.status = status
770 else:
771 self.status = 0
Rich Lane7dcdf022013-12-11 14:45:27 -0800772 return
Dan Talaycof6202252013-07-02 01:00:29 -0700773
774 def pack(self):
775 packed = []
776 packed.append(struct.pack("!B", self.version))
777 packed.append(struct.pack("!B", self.type))
778 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
779 packed.append(struct.pack("!L", self.xid))
780 packed.append(struct.pack("!L", self.experimenter))
781 packed.append(struct.pack("!L", self.subtype))
782 packed.append(struct.pack("!L", self.status))
783 length = sum([len(x) for x in packed])
784 packed[2] = struct.pack("!H", length)
785 return ''.join(packed)
786
787 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800788 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -0700789 obj = bsn_bw_clear_data_reply()
Dan Talaycof6202252013-07-02 01:00:29 -0700790 _version = reader.read("!B")[0]
791 assert(_version == 2)
792 _type = reader.read("!B")[0]
793 assert(_type == 4)
794 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800795 orig_reader = reader
796 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700797 obj.xid = reader.read("!L")[0]
798 _experimenter = reader.read("!L")[0]
799 assert(_experimenter == 6035143)
800 _subtype = reader.read("!L")[0]
801 assert(_subtype == 22)
802 obj.status = reader.read("!L")[0]
803 return obj
804
805 def __eq__(self, other):
806 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -0700807 if self.xid != other.xid: return False
808 if self.status != other.status: return False
809 return True
810
Dan Talaycof6202252013-07-02 01:00:29 -0700811 def pretty_print(self, q):
812 q.text("bsn_bw_clear_data_reply {")
813 with q.group():
814 with q.indent(2):
815 q.breakable()
816 q.text("xid = ");
817 if self.xid != None:
818 q.text("%#x" % self.xid)
819 else:
820 q.text('None')
821 q.text(","); q.breakable()
822 q.text("status = ");
823 q.text("%#x" % self.status)
824 q.breakable()
825 q.text('}')
826
Rich Lane7dcdf022013-12-11 14:45:27 -0800827bsn_header.subtypes[22] = bsn_bw_clear_data_reply
828
829class bsn_bw_clear_data_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -0700830 version = 2
831 type = 4
832 experimenter = 6035143
833 subtype = 21
834
835 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800836 if xid != None:
837 self.xid = xid
838 else:
839 self.xid = None
840 return
Dan Talaycof6202252013-07-02 01:00:29 -0700841
842 def pack(self):
843 packed = []
844 packed.append(struct.pack("!B", self.version))
845 packed.append(struct.pack("!B", self.type))
846 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
847 packed.append(struct.pack("!L", self.xid))
848 packed.append(struct.pack("!L", self.experimenter))
849 packed.append(struct.pack("!L", self.subtype))
850 length = sum([len(x) for x in packed])
851 packed[2] = struct.pack("!H", length)
852 return ''.join(packed)
853
854 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800855 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -0700856 obj = bsn_bw_clear_data_request()
Dan Talaycof6202252013-07-02 01:00:29 -0700857 _version = reader.read("!B")[0]
858 assert(_version == 2)
859 _type = reader.read("!B")[0]
860 assert(_type == 4)
861 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800862 orig_reader = reader
863 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700864 obj.xid = reader.read("!L")[0]
865 _experimenter = reader.read("!L")[0]
866 assert(_experimenter == 6035143)
867 _subtype = reader.read("!L")[0]
868 assert(_subtype == 21)
869 return obj
870
871 def __eq__(self, other):
872 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -0700873 if self.xid != other.xid: return False
874 return True
875
Dan Talaycof6202252013-07-02 01:00:29 -0700876 def pretty_print(self, q):
877 q.text("bsn_bw_clear_data_request {")
878 with q.group():
879 with q.indent(2):
880 q.breakable()
881 q.text("xid = ");
882 if self.xid != None:
883 q.text("%#x" % self.xid)
884 else:
885 q.text('None')
886 q.breakable()
887 q.text('}')
888
Rich Lane7dcdf022013-12-11 14:45:27 -0800889bsn_header.subtypes[21] = bsn_bw_clear_data_request
890
891class bsn_bw_enable_get_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -0700892 version = 2
893 type = 4
894 experimenter = 6035143
895 subtype = 20
896
897 def __init__(self, xid=None, enabled=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800898 if xid != None:
899 self.xid = xid
900 else:
901 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -0700902 if enabled != None:
903 self.enabled = enabled
904 else:
905 self.enabled = 0
Rich Lane7dcdf022013-12-11 14:45:27 -0800906 return
Dan Talaycof6202252013-07-02 01:00:29 -0700907
908 def pack(self):
909 packed = []
910 packed.append(struct.pack("!B", self.version))
911 packed.append(struct.pack("!B", self.type))
912 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
913 packed.append(struct.pack("!L", self.xid))
914 packed.append(struct.pack("!L", self.experimenter))
915 packed.append(struct.pack("!L", self.subtype))
916 packed.append(struct.pack("!L", self.enabled))
917 length = sum([len(x) for x in packed])
918 packed[2] = struct.pack("!H", length)
919 return ''.join(packed)
920
921 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800922 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -0700923 obj = bsn_bw_enable_get_reply()
Dan Talaycof6202252013-07-02 01:00:29 -0700924 _version = reader.read("!B")[0]
925 assert(_version == 2)
926 _type = reader.read("!B")[0]
927 assert(_type == 4)
928 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800929 orig_reader = reader
930 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700931 obj.xid = reader.read("!L")[0]
932 _experimenter = reader.read("!L")[0]
933 assert(_experimenter == 6035143)
934 _subtype = reader.read("!L")[0]
935 assert(_subtype == 20)
936 obj.enabled = reader.read("!L")[0]
937 return obj
938
939 def __eq__(self, other):
940 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -0700941 if self.xid != other.xid: return False
942 if self.enabled != other.enabled: return False
943 return True
944
Dan Talaycof6202252013-07-02 01:00:29 -0700945 def pretty_print(self, q):
946 q.text("bsn_bw_enable_get_reply {")
947 with q.group():
948 with q.indent(2):
949 q.breakable()
950 q.text("xid = ");
951 if self.xid != None:
952 q.text("%#x" % self.xid)
953 else:
954 q.text('None')
955 q.text(","); q.breakable()
956 q.text("enabled = ");
957 q.text("%#x" % self.enabled)
958 q.breakable()
959 q.text('}')
960
Rich Lane7dcdf022013-12-11 14:45:27 -0800961bsn_header.subtypes[20] = bsn_bw_enable_get_reply
962
963class bsn_bw_enable_get_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -0700964 version = 2
965 type = 4
966 experimenter = 6035143
967 subtype = 19
968
969 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800970 if xid != None:
971 self.xid = xid
972 else:
973 self.xid = None
974 return
Dan Talaycof6202252013-07-02 01:00:29 -0700975
976 def pack(self):
977 packed = []
978 packed.append(struct.pack("!B", self.version))
979 packed.append(struct.pack("!B", self.type))
980 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
981 packed.append(struct.pack("!L", self.xid))
982 packed.append(struct.pack("!L", self.experimenter))
983 packed.append(struct.pack("!L", self.subtype))
984 length = sum([len(x) for x in packed])
985 packed[2] = struct.pack("!H", length)
986 return ''.join(packed)
987
988 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800989 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -0700990 obj = bsn_bw_enable_get_request()
Dan Talaycof6202252013-07-02 01:00:29 -0700991 _version = reader.read("!B")[0]
992 assert(_version == 2)
993 _type = reader.read("!B")[0]
994 assert(_type == 4)
995 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800996 orig_reader = reader
997 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700998 obj.xid = reader.read("!L")[0]
999 _experimenter = reader.read("!L")[0]
1000 assert(_experimenter == 6035143)
1001 _subtype = reader.read("!L")[0]
1002 assert(_subtype == 19)
1003 return obj
1004
1005 def __eq__(self, other):
1006 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07001007 if self.xid != other.xid: return False
1008 return True
1009
Dan Talaycof6202252013-07-02 01:00:29 -07001010 def pretty_print(self, q):
1011 q.text("bsn_bw_enable_get_request {")
1012 with q.group():
1013 with q.indent(2):
1014 q.breakable()
1015 q.text("xid = ");
1016 if self.xid != None:
1017 q.text("%#x" % self.xid)
1018 else:
1019 q.text('None')
1020 q.breakable()
1021 q.text('}')
1022
Rich Lane7dcdf022013-12-11 14:45:27 -08001023bsn_header.subtypes[19] = bsn_bw_enable_get_request
1024
1025class bsn_bw_enable_set_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001026 version = 2
1027 type = 4
1028 experimenter = 6035143
1029 subtype = 23
1030
1031 def __init__(self, xid=None, enable=None, status=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001032 if xid != None:
1033 self.xid = xid
1034 else:
1035 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07001036 if enable != None:
1037 self.enable = enable
1038 else:
1039 self.enable = 0
1040 if status != None:
1041 self.status = status
1042 else:
1043 self.status = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001044 return
Dan Talaycof6202252013-07-02 01:00:29 -07001045
1046 def pack(self):
1047 packed = []
1048 packed.append(struct.pack("!B", self.version))
1049 packed.append(struct.pack("!B", self.type))
1050 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1051 packed.append(struct.pack("!L", self.xid))
1052 packed.append(struct.pack("!L", self.experimenter))
1053 packed.append(struct.pack("!L", self.subtype))
1054 packed.append(struct.pack("!L", self.enable))
1055 packed.append(struct.pack("!L", self.status))
1056 length = sum([len(x) for x in packed])
1057 packed[2] = struct.pack("!H", length)
1058 return ''.join(packed)
1059
1060 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001061 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001062 obj = bsn_bw_enable_set_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07001063 _version = reader.read("!B")[0]
1064 assert(_version == 2)
1065 _type = reader.read("!B")[0]
1066 assert(_type == 4)
1067 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001068 orig_reader = reader
1069 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001070 obj.xid = reader.read("!L")[0]
1071 _experimenter = reader.read("!L")[0]
1072 assert(_experimenter == 6035143)
1073 _subtype = reader.read("!L")[0]
1074 assert(_subtype == 23)
1075 obj.enable = reader.read("!L")[0]
1076 obj.status = reader.read("!L")[0]
1077 return obj
1078
1079 def __eq__(self, other):
1080 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07001081 if self.xid != other.xid: return False
1082 if self.enable != other.enable: return False
1083 if self.status != other.status: return False
1084 return True
1085
Dan Talaycof6202252013-07-02 01:00:29 -07001086 def pretty_print(self, q):
1087 q.text("bsn_bw_enable_set_reply {")
1088 with q.group():
1089 with q.indent(2):
1090 q.breakable()
1091 q.text("xid = ");
1092 if self.xid != None:
1093 q.text("%#x" % self.xid)
1094 else:
1095 q.text('None')
1096 q.text(","); q.breakable()
1097 q.text("enable = ");
1098 q.text("%#x" % self.enable)
1099 q.text(","); q.breakable()
1100 q.text("status = ");
1101 q.text("%#x" % self.status)
1102 q.breakable()
1103 q.text('}')
1104
Rich Lane7dcdf022013-12-11 14:45:27 -08001105bsn_header.subtypes[23] = bsn_bw_enable_set_reply
1106
1107class bsn_bw_enable_set_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001108 version = 2
1109 type = 4
1110 experimenter = 6035143
1111 subtype = 18
1112
1113 def __init__(self, xid=None, enable=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001114 if xid != None:
1115 self.xid = xid
1116 else:
1117 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07001118 if enable != None:
1119 self.enable = enable
1120 else:
1121 self.enable = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001122 return
Dan Talaycof6202252013-07-02 01:00:29 -07001123
1124 def pack(self):
1125 packed = []
1126 packed.append(struct.pack("!B", self.version))
1127 packed.append(struct.pack("!B", self.type))
1128 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1129 packed.append(struct.pack("!L", self.xid))
1130 packed.append(struct.pack("!L", self.experimenter))
1131 packed.append(struct.pack("!L", self.subtype))
1132 packed.append(struct.pack("!L", self.enable))
1133 length = sum([len(x) for x in packed])
1134 packed[2] = struct.pack("!H", length)
1135 return ''.join(packed)
1136
1137 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001138 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001139 obj = bsn_bw_enable_set_request()
Dan Talaycof6202252013-07-02 01:00:29 -07001140 _version = reader.read("!B")[0]
1141 assert(_version == 2)
1142 _type = reader.read("!B")[0]
1143 assert(_type == 4)
1144 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001145 orig_reader = reader
1146 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001147 obj.xid = reader.read("!L")[0]
1148 _experimenter = reader.read("!L")[0]
1149 assert(_experimenter == 6035143)
1150 _subtype = reader.read("!L")[0]
1151 assert(_subtype == 18)
1152 obj.enable = reader.read("!L")[0]
1153 return obj
1154
1155 def __eq__(self, other):
1156 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07001157 if self.xid != other.xid: return False
1158 if self.enable != other.enable: return False
1159 return True
1160
Dan Talaycof6202252013-07-02 01:00:29 -07001161 def pretty_print(self, q):
1162 q.text("bsn_bw_enable_set_request {")
1163 with q.group():
1164 with q.indent(2):
1165 q.breakable()
1166 q.text("xid = ");
1167 if self.xid != None:
1168 q.text("%#x" % self.xid)
1169 else:
1170 q.text('None')
1171 q.text(","); q.breakable()
1172 q.text("enable = ");
1173 q.text("%#x" % self.enable)
1174 q.breakable()
1175 q.text('}')
1176
Rich Lane7dcdf022013-12-11 14:45:27 -08001177bsn_header.subtypes[18] = bsn_bw_enable_set_request
1178
1179class bsn_get_interfaces_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001180 version = 2
1181 type = 4
1182 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07001183 subtype = 10
1184
1185 def __init__(self, xid=None, interfaces=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001186 if xid != None:
1187 self.xid = xid
1188 else:
1189 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07001190 if interfaces != None:
1191 self.interfaces = interfaces
1192 else:
1193 self.interfaces = []
Rich Lane7dcdf022013-12-11 14:45:27 -08001194 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07001195
1196 def pack(self):
1197 packed = []
1198 packed.append(struct.pack("!B", self.version))
1199 packed.append(struct.pack("!B", self.type))
1200 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1201 packed.append(struct.pack("!L", self.xid))
1202 packed.append(struct.pack("!L", self.experimenter))
1203 packed.append(struct.pack("!L", self.subtype))
Rich Lane7dcdf022013-12-11 14:45:27 -08001204 packed.append(loxi.generic_util.pack_list(self.interfaces))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001205 length = sum([len(x) for x in packed])
1206 packed[2] = struct.pack("!H", length)
1207 return ''.join(packed)
1208
1209 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001210 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001211 obj = bsn_get_interfaces_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07001212 _version = reader.read("!B")[0]
1213 assert(_version == 2)
1214 _type = reader.read("!B")[0]
1215 assert(_type == 4)
1216 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001217 orig_reader = reader
1218 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001219 obj.xid = reader.read("!L")[0]
1220 _experimenter = reader.read("!L")[0]
1221 assert(_experimenter == 6035143)
1222 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001223 assert(_subtype == 10)
1224 obj.interfaces = loxi.generic_util.unpack_list(reader, common.bsn_interface.unpack)
1225 return obj
1226
1227 def __eq__(self, other):
1228 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001229 if self.xid != other.xid: return False
1230 if self.interfaces != other.interfaces: return False
1231 return True
1232
Rich Lanec2ee4b82013-04-24 17:12:38 -07001233 def pretty_print(self, q):
1234 q.text("bsn_get_interfaces_reply {")
1235 with q.group():
1236 with q.indent(2):
1237 q.breakable()
1238 q.text("xid = ");
1239 if self.xid != None:
1240 q.text("%#x" % self.xid)
1241 else:
1242 q.text('None')
1243 q.text(","); q.breakable()
1244 q.text("interfaces = ");
1245 q.pp(self.interfaces)
1246 q.breakable()
1247 q.text('}')
1248
Rich Lane7dcdf022013-12-11 14:45:27 -08001249bsn_header.subtypes[10] = bsn_get_interfaces_reply
1250
1251class bsn_get_interfaces_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001252 version = 2
1253 type = 4
1254 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07001255 subtype = 9
1256
1257 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001258 if xid != None:
1259 self.xid = xid
1260 else:
1261 self.xid = None
1262 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07001263
1264 def pack(self):
1265 packed = []
1266 packed.append(struct.pack("!B", self.version))
1267 packed.append(struct.pack("!B", self.type))
1268 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1269 packed.append(struct.pack("!L", self.xid))
1270 packed.append(struct.pack("!L", self.experimenter))
1271 packed.append(struct.pack("!L", self.subtype))
1272 length = sum([len(x) for x in packed])
1273 packed[2] = struct.pack("!H", length)
1274 return ''.join(packed)
1275
1276 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001277 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001278 obj = bsn_get_interfaces_request()
Dan Talaycof6202252013-07-02 01:00:29 -07001279 _version = reader.read("!B")[0]
1280 assert(_version == 2)
1281 _type = reader.read("!B")[0]
1282 assert(_type == 4)
1283 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001284 orig_reader = reader
1285 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001286 obj.xid = reader.read("!L")[0]
1287 _experimenter = reader.read("!L")[0]
1288 assert(_experimenter == 6035143)
1289 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001290 assert(_subtype == 9)
1291 return obj
1292
1293 def __eq__(self, other):
1294 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001295 if self.xid != other.xid: return False
1296 return True
1297
Rich Lanec2ee4b82013-04-24 17:12:38 -07001298 def pretty_print(self, q):
1299 q.text("bsn_get_interfaces_request {")
1300 with q.group():
1301 with q.indent(2):
1302 q.breakable()
1303 q.text("xid = ");
1304 if self.xid != None:
1305 q.text("%#x" % self.xid)
1306 else:
1307 q.text('None')
1308 q.breakable()
1309 q.text('}')
1310
Rich Lane7dcdf022013-12-11 14:45:27 -08001311bsn_header.subtypes[9] = bsn_get_interfaces_request
1312
1313class bsn_get_mirroring_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001314 version = 2
1315 type = 4
1316 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07001317 subtype = 5
1318
1319 def __init__(self, xid=None, report_mirror_ports=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001320 if xid != None:
1321 self.xid = xid
1322 else:
1323 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07001324 if report_mirror_ports != None:
1325 self.report_mirror_ports = report_mirror_ports
1326 else:
1327 self.report_mirror_ports = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001328 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07001329
1330 def pack(self):
1331 packed = []
1332 packed.append(struct.pack("!B", self.version))
1333 packed.append(struct.pack("!B", self.type))
1334 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1335 packed.append(struct.pack("!L", self.xid))
1336 packed.append(struct.pack("!L", self.experimenter))
1337 packed.append(struct.pack("!L", self.subtype))
1338 packed.append(struct.pack("!B", self.report_mirror_ports))
1339 packed.append('\x00' * 3)
1340 length = sum([len(x) for x in packed])
1341 packed[2] = struct.pack("!H", length)
1342 return ''.join(packed)
1343
1344 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001345 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001346 obj = bsn_get_mirroring_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07001347 _version = reader.read("!B")[0]
1348 assert(_version == 2)
1349 _type = reader.read("!B")[0]
1350 assert(_type == 4)
1351 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001352 orig_reader = reader
1353 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001354 obj.xid = reader.read("!L")[0]
1355 _experimenter = reader.read("!L")[0]
1356 assert(_experimenter == 6035143)
1357 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001358 assert(_subtype == 5)
Dan Talaycof6202252013-07-02 01:00:29 -07001359 obj.report_mirror_ports = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001360 reader.skip(3)
1361 return obj
1362
1363 def __eq__(self, other):
1364 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001365 if self.xid != other.xid: return False
1366 if self.report_mirror_ports != other.report_mirror_ports: return False
1367 return True
1368
Rich Lanec2ee4b82013-04-24 17:12:38 -07001369 def pretty_print(self, q):
1370 q.text("bsn_get_mirroring_reply {")
1371 with q.group():
1372 with q.indent(2):
1373 q.breakable()
1374 q.text("xid = ");
1375 if self.xid != None:
1376 q.text("%#x" % self.xid)
1377 else:
1378 q.text('None')
1379 q.text(","); q.breakable()
1380 q.text("report_mirror_ports = ");
1381 q.text("%#x" % self.report_mirror_ports)
1382 q.breakable()
1383 q.text('}')
1384
Rich Lane7dcdf022013-12-11 14:45:27 -08001385bsn_header.subtypes[5] = bsn_get_mirroring_reply
1386
1387class bsn_get_mirroring_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001388 version = 2
1389 type = 4
1390 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07001391 subtype = 4
1392
1393 def __init__(self, xid=None, report_mirror_ports=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001394 if xid != None:
1395 self.xid = xid
1396 else:
1397 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07001398 if report_mirror_ports != None:
1399 self.report_mirror_ports = report_mirror_ports
1400 else:
1401 self.report_mirror_ports = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001402 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07001403
1404 def pack(self):
1405 packed = []
1406 packed.append(struct.pack("!B", self.version))
1407 packed.append(struct.pack("!B", self.type))
1408 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1409 packed.append(struct.pack("!L", self.xid))
1410 packed.append(struct.pack("!L", self.experimenter))
1411 packed.append(struct.pack("!L", self.subtype))
1412 packed.append(struct.pack("!B", self.report_mirror_ports))
1413 packed.append('\x00' * 3)
1414 length = sum([len(x) for x in packed])
1415 packed[2] = struct.pack("!H", length)
1416 return ''.join(packed)
1417
1418 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001419 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001420 obj = bsn_get_mirroring_request()
Dan Talaycof6202252013-07-02 01:00:29 -07001421 _version = reader.read("!B")[0]
1422 assert(_version == 2)
1423 _type = reader.read("!B")[0]
1424 assert(_type == 4)
1425 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001426 orig_reader = reader
1427 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001428 obj.xid = reader.read("!L")[0]
1429 _experimenter = reader.read("!L")[0]
1430 assert(_experimenter == 6035143)
1431 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001432 assert(_subtype == 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001433 obj.report_mirror_ports = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001434 reader.skip(3)
1435 return obj
1436
1437 def __eq__(self, other):
1438 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001439 if self.xid != other.xid: return False
1440 if self.report_mirror_ports != other.report_mirror_ports: return False
1441 return True
1442
Rich Lanec2ee4b82013-04-24 17:12:38 -07001443 def pretty_print(self, q):
1444 q.text("bsn_get_mirroring_request {")
1445 with q.group():
1446 with q.indent(2):
1447 q.breakable()
1448 q.text("xid = ");
1449 if self.xid != None:
1450 q.text("%#x" % self.xid)
1451 else:
1452 q.text('None')
1453 q.text(","); q.breakable()
1454 q.text("report_mirror_ports = ");
1455 q.text("%#x" % self.report_mirror_ports)
1456 q.breakable()
1457 q.text('}')
1458
Rich Lane7dcdf022013-12-11 14:45:27 -08001459bsn_header.subtypes[4] = bsn_get_mirroring_request
1460
1461class bsn_pdu_rx_reply(bsn_header):
Rich Lane6f4978c2013-10-20 21:33:52 -07001462 version = 2
1463 type = 4
1464 experimenter = 6035143
1465 subtype = 34
1466
Rich Lane7b0f2012013-11-22 14:15:26 -08001467 def __init__(self, xid=None, status=None, port_no=None, slot_num=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001468 if xid != None:
1469 self.xid = xid
1470 else:
1471 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07001472 if status != None:
1473 self.status = status
1474 else:
1475 self.status = 0
Rich Lane7b0f2012013-11-22 14:15:26 -08001476 if port_no != None:
1477 self.port_no = port_no
1478 else:
1479 self.port_no = 0
1480 if slot_num != None:
1481 self.slot_num = slot_num
1482 else:
1483 self.slot_num = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001484 return
Rich Lane6f4978c2013-10-20 21:33:52 -07001485
1486 def pack(self):
1487 packed = []
1488 packed.append(struct.pack("!B", self.version))
1489 packed.append(struct.pack("!B", self.type))
1490 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1491 packed.append(struct.pack("!L", self.xid))
1492 packed.append(struct.pack("!L", self.experimenter))
1493 packed.append(struct.pack("!L", self.subtype))
1494 packed.append(struct.pack("!L", self.status))
Rich Lane7b0f2012013-11-22 14:15:26 -08001495 packed.append(util.pack_port_no(self.port_no))
1496 packed.append(struct.pack("!B", self.slot_num))
Rich Lane6f4978c2013-10-20 21:33:52 -07001497 length = sum([len(x) for x in packed])
1498 packed[2] = struct.pack("!H", length)
1499 return ''.join(packed)
1500
1501 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001502 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07001503 obj = bsn_pdu_rx_reply()
Rich Lane6f4978c2013-10-20 21:33:52 -07001504 _version = reader.read("!B")[0]
1505 assert(_version == 2)
1506 _type = reader.read("!B")[0]
1507 assert(_type == 4)
1508 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001509 orig_reader = reader
1510 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07001511 obj.xid = reader.read("!L")[0]
1512 _experimenter = reader.read("!L")[0]
1513 assert(_experimenter == 6035143)
1514 _subtype = reader.read("!L")[0]
1515 assert(_subtype == 34)
1516 obj.status = reader.read("!L")[0]
Rich Lane7b0f2012013-11-22 14:15:26 -08001517 obj.port_no = util.unpack_port_no(reader)
1518 obj.slot_num = reader.read("!B")[0]
Rich Lane6f4978c2013-10-20 21:33:52 -07001519 return obj
1520
1521 def __eq__(self, other):
1522 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001523 if self.xid != other.xid: return False
1524 if self.status != other.status: return False
Rich Lane7b0f2012013-11-22 14:15:26 -08001525 if self.port_no != other.port_no: return False
1526 if self.slot_num != other.slot_num: return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001527 return True
1528
Rich Lane6f4978c2013-10-20 21:33:52 -07001529 def pretty_print(self, q):
1530 q.text("bsn_pdu_rx_reply {")
1531 with q.group():
1532 with q.indent(2):
1533 q.breakable()
1534 q.text("xid = ");
1535 if self.xid != None:
1536 q.text("%#x" % self.xid)
1537 else:
1538 q.text('None')
1539 q.text(","); q.breakable()
1540 q.text("status = ");
1541 q.text("%#x" % self.status)
Rich Lane7b0f2012013-11-22 14:15:26 -08001542 q.text(","); q.breakable()
1543 q.text("port_no = ");
1544 q.text(util.pretty_port(self.port_no))
1545 q.text(","); q.breakable()
1546 q.text("slot_num = ");
1547 q.text("%#x" % self.slot_num)
Rich Lane6f4978c2013-10-20 21:33:52 -07001548 q.breakable()
1549 q.text('}')
1550
Rich Lane7dcdf022013-12-11 14:45:27 -08001551bsn_header.subtypes[34] = bsn_pdu_rx_reply
1552
1553class bsn_pdu_rx_request(bsn_header):
Rich Lane6f4978c2013-10-20 21:33:52 -07001554 version = 2
1555 type = 4
1556 experimenter = 6035143
1557 subtype = 33
1558
1559 def __init__(self, xid=None, timeout_ms=None, port_no=None, slot_num=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001560 if xid != None:
1561 self.xid = xid
1562 else:
1563 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07001564 if timeout_ms != None:
1565 self.timeout_ms = timeout_ms
1566 else:
1567 self.timeout_ms = 0
1568 if port_no != None:
1569 self.port_no = port_no
1570 else:
1571 self.port_no = 0
1572 if slot_num != None:
1573 self.slot_num = slot_num
1574 else:
1575 self.slot_num = 0
1576 if data != None:
1577 self.data = data
1578 else:
1579 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08001580 return
Rich Lane6f4978c2013-10-20 21:33:52 -07001581
1582 def pack(self):
1583 packed = []
1584 packed.append(struct.pack("!B", self.version))
1585 packed.append(struct.pack("!B", self.type))
1586 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1587 packed.append(struct.pack("!L", self.xid))
1588 packed.append(struct.pack("!L", self.experimenter))
1589 packed.append(struct.pack("!L", self.subtype))
1590 packed.append(struct.pack("!L", self.timeout_ms))
1591 packed.append(util.pack_port_no(self.port_no))
1592 packed.append(struct.pack("!B", self.slot_num))
1593 packed.append('\x00' * 3)
1594 packed.append(self.data)
1595 length = sum([len(x) for x in packed])
1596 packed[2] = struct.pack("!H", length)
1597 return ''.join(packed)
1598
1599 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001600 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07001601 obj = bsn_pdu_rx_request()
Rich Lane6f4978c2013-10-20 21:33:52 -07001602 _version = reader.read("!B")[0]
1603 assert(_version == 2)
1604 _type = reader.read("!B")[0]
1605 assert(_type == 4)
1606 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001607 orig_reader = reader
1608 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07001609 obj.xid = reader.read("!L")[0]
1610 _experimenter = reader.read("!L")[0]
1611 assert(_experimenter == 6035143)
1612 _subtype = reader.read("!L")[0]
1613 assert(_subtype == 33)
1614 obj.timeout_ms = reader.read("!L")[0]
1615 obj.port_no = util.unpack_port_no(reader)
1616 obj.slot_num = reader.read("!B")[0]
1617 reader.skip(3)
1618 obj.data = str(reader.read_all())
1619 return obj
1620
1621 def __eq__(self, other):
1622 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001623 if self.xid != other.xid: return False
1624 if self.timeout_ms != other.timeout_ms: return False
1625 if self.port_no != other.port_no: return False
1626 if self.slot_num != other.slot_num: return False
1627 if self.data != other.data: return False
1628 return True
1629
Rich Lane6f4978c2013-10-20 21:33:52 -07001630 def pretty_print(self, q):
1631 q.text("bsn_pdu_rx_request {")
1632 with q.group():
1633 with q.indent(2):
1634 q.breakable()
1635 q.text("xid = ");
1636 if self.xid != None:
1637 q.text("%#x" % self.xid)
1638 else:
1639 q.text('None')
1640 q.text(","); q.breakable()
1641 q.text("timeout_ms = ");
1642 q.text("%#x" % self.timeout_ms)
1643 q.text(","); q.breakable()
1644 q.text("port_no = ");
1645 q.text(util.pretty_port(self.port_no))
1646 q.text(","); q.breakable()
1647 q.text("slot_num = ");
1648 q.text("%#x" % self.slot_num)
1649 q.text(","); q.breakable()
1650 q.text("data = ");
1651 q.pp(self.data)
1652 q.breakable()
1653 q.text('}')
1654
Rich Lane7dcdf022013-12-11 14:45:27 -08001655bsn_header.subtypes[33] = bsn_pdu_rx_request
1656
1657class bsn_pdu_rx_timeout(bsn_header):
Rich Lane6f4978c2013-10-20 21:33:52 -07001658 version = 2
1659 type = 4
1660 experimenter = 6035143
1661 subtype = 35
1662
1663 def __init__(self, xid=None, port_no=None, slot_num=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001664 if xid != None:
1665 self.xid = xid
1666 else:
1667 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07001668 if port_no != None:
1669 self.port_no = port_no
1670 else:
1671 self.port_no = 0
1672 if slot_num != None:
1673 self.slot_num = slot_num
1674 else:
1675 self.slot_num = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001676 return
Rich Lane6f4978c2013-10-20 21:33:52 -07001677
1678 def pack(self):
1679 packed = []
1680 packed.append(struct.pack("!B", self.version))
1681 packed.append(struct.pack("!B", self.type))
1682 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1683 packed.append(struct.pack("!L", self.xid))
1684 packed.append(struct.pack("!L", self.experimenter))
1685 packed.append(struct.pack("!L", self.subtype))
1686 packed.append(util.pack_port_no(self.port_no))
1687 packed.append(struct.pack("!B", self.slot_num))
1688 length = sum([len(x) for x in packed])
1689 packed[2] = struct.pack("!H", length)
1690 return ''.join(packed)
1691
1692 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001693 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07001694 obj = bsn_pdu_rx_timeout()
Rich Lane6f4978c2013-10-20 21:33:52 -07001695 _version = reader.read("!B")[0]
1696 assert(_version == 2)
1697 _type = reader.read("!B")[0]
1698 assert(_type == 4)
1699 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001700 orig_reader = reader
1701 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07001702 obj.xid = reader.read("!L")[0]
1703 _experimenter = reader.read("!L")[0]
1704 assert(_experimenter == 6035143)
1705 _subtype = reader.read("!L")[0]
1706 assert(_subtype == 35)
1707 obj.port_no = util.unpack_port_no(reader)
1708 obj.slot_num = reader.read("!B")[0]
1709 return obj
1710
1711 def __eq__(self, other):
1712 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001713 if self.xid != other.xid: return False
1714 if self.port_no != other.port_no: return False
1715 if self.slot_num != other.slot_num: return False
1716 return True
1717
Rich Lane6f4978c2013-10-20 21:33:52 -07001718 def pretty_print(self, q):
1719 q.text("bsn_pdu_rx_timeout {")
1720 with q.group():
1721 with q.indent(2):
1722 q.breakable()
1723 q.text("xid = ");
1724 if self.xid != None:
1725 q.text("%#x" % self.xid)
1726 else:
1727 q.text('None')
1728 q.text(","); q.breakable()
1729 q.text("port_no = ");
1730 q.text(util.pretty_port(self.port_no))
1731 q.text(","); q.breakable()
1732 q.text("slot_num = ");
1733 q.text("%#x" % self.slot_num)
1734 q.breakable()
1735 q.text('}')
1736
Rich Lane7dcdf022013-12-11 14:45:27 -08001737bsn_header.subtypes[35] = bsn_pdu_rx_timeout
1738
1739class bsn_pdu_tx_reply(bsn_header):
Rich Lane6f4978c2013-10-20 21:33:52 -07001740 version = 2
1741 type = 4
1742 experimenter = 6035143
1743 subtype = 32
1744
Rich Lane7b0f2012013-11-22 14:15:26 -08001745 def __init__(self, xid=None, status=None, port_no=None, slot_num=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001746 if xid != None:
1747 self.xid = xid
1748 else:
1749 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07001750 if status != None:
1751 self.status = status
1752 else:
1753 self.status = 0
Rich Lane7b0f2012013-11-22 14:15:26 -08001754 if port_no != None:
1755 self.port_no = port_no
1756 else:
1757 self.port_no = 0
1758 if slot_num != None:
1759 self.slot_num = slot_num
1760 else:
1761 self.slot_num = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001762 return
Rich Lane6f4978c2013-10-20 21:33:52 -07001763
1764 def pack(self):
1765 packed = []
1766 packed.append(struct.pack("!B", self.version))
1767 packed.append(struct.pack("!B", self.type))
1768 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1769 packed.append(struct.pack("!L", self.xid))
1770 packed.append(struct.pack("!L", self.experimenter))
1771 packed.append(struct.pack("!L", self.subtype))
1772 packed.append(struct.pack("!L", self.status))
Rich Lane7b0f2012013-11-22 14:15:26 -08001773 packed.append(util.pack_port_no(self.port_no))
1774 packed.append(struct.pack("!B", self.slot_num))
Rich Lane6f4978c2013-10-20 21:33:52 -07001775 length = sum([len(x) for x in packed])
1776 packed[2] = struct.pack("!H", length)
1777 return ''.join(packed)
1778
1779 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001780 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07001781 obj = bsn_pdu_tx_reply()
Rich Lane6f4978c2013-10-20 21:33:52 -07001782 _version = reader.read("!B")[0]
1783 assert(_version == 2)
1784 _type = reader.read("!B")[0]
1785 assert(_type == 4)
1786 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001787 orig_reader = reader
1788 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07001789 obj.xid = reader.read("!L")[0]
1790 _experimenter = reader.read("!L")[0]
1791 assert(_experimenter == 6035143)
1792 _subtype = reader.read("!L")[0]
1793 assert(_subtype == 32)
1794 obj.status = reader.read("!L")[0]
Rich Lane7b0f2012013-11-22 14:15:26 -08001795 obj.port_no = util.unpack_port_no(reader)
1796 obj.slot_num = reader.read("!B")[0]
Rich Lane6f4978c2013-10-20 21:33:52 -07001797 return obj
1798
1799 def __eq__(self, other):
1800 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001801 if self.xid != other.xid: return False
1802 if self.status != other.status: return False
Rich Lane7b0f2012013-11-22 14:15:26 -08001803 if self.port_no != other.port_no: return False
1804 if self.slot_num != other.slot_num: return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001805 return True
1806
Rich Lane6f4978c2013-10-20 21:33:52 -07001807 def pretty_print(self, q):
1808 q.text("bsn_pdu_tx_reply {")
1809 with q.group():
1810 with q.indent(2):
1811 q.breakable()
1812 q.text("xid = ");
1813 if self.xid != None:
1814 q.text("%#x" % self.xid)
1815 else:
1816 q.text('None')
1817 q.text(","); q.breakable()
1818 q.text("status = ");
1819 q.text("%#x" % self.status)
Rich Lane7b0f2012013-11-22 14:15:26 -08001820 q.text(","); q.breakable()
1821 q.text("port_no = ");
1822 q.text(util.pretty_port(self.port_no))
1823 q.text(","); q.breakable()
1824 q.text("slot_num = ");
1825 q.text("%#x" % self.slot_num)
Rich Lane6f4978c2013-10-20 21:33:52 -07001826 q.breakable()
1827 q.text('}')
1828
Rich Lane7dcdf022013-12-11 14:45:27 -08001829bsn_header.subtypes[32] = bsn_pdu_tx_reply
1830
1831class bsn_pdu_tx_request(bsn_header):
Rich Lane6f4978c2013-10-20 21:33:52 -07001832 version = 2
1833 type = 4
1834 experimenter = 6035143
1835 subtype = 31
1836
1837 def __init__(self, xid=None, tx_interval_ms=None, port_no=None, slot_num=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001838 if xid != None:
1839 self.xid = xid
1840 else:
1841 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07001842 if tx_interval_ms != None:
1843 self.tx_interval_ms = tx_interval_ms
1844 else:
1845 self.tx_interval_ms = 0
1846 if port_no != None:
1847 self.port_no = port_no
1848 else:
1849 self.port_no = 0
1850 if slot_num != None:
1851 self.slot_num = slot_num
1852 else:
1853 self.slot_num = 0
1854 if data != None:
1855 self.data = data
1856 else:
1857 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08001858 return
Rich Lane6f4978c2013-10-20 21:33:52 -07001859
1860 def pack(self):
1861 packed = []
1862 packed.append(struct.pack("!B", self.version))
1863 packed.append(struct.pack("!B", self.type))
1864 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1865 packed.append(struct.pack("!L", self.xid))
1866 packed.append(struct.pack("!L", self.experimenter))
1867 packed.append(struct.pack("!L", self.subtype))
1868 packed.append(struct.pack("!L", self.tx_interval_ms))
1869 packed.append(util.pack_port_no(self.port_no))
1870 packed.append(struct.pack("!B", self.slot_num))
1871 packed.append('\x00' * 3)
1872 packed.append(self.data)
1873 length = sum([len(x) for x in packed])
1874 packed[2] = struct.pack("!H", length)
1875 return ''.join(packed)
1876
1877 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001878 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07001879 obj = bsn_pdu_tx_request()
Rich Lane6f4978c2013-10-20 21:33:52 -07001880 _version = reader.read("!B")[0]
1881 assert(_version == 2)
1882 _type = reader.read("!B")[0]
1883 assert(_type == 4)
1884 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001885 orig_reader = reader
1886 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07001887 obj.xid = reader.read("!L")[0]
1888 _experimenter = reader.read("!L")[0]
1889 assert(_experimenter == 6035143)
1890 _subtype = reader.read("!L")[0]
1891 assert(_subtype == 31)
1892 obj.tx_interval_ms = reader.read("!L")[0]
1893 obj.port_no = util.unpack_port_no(reader)
1894 obj.slot_num = reader.read("!B")[0]
1895 reader.skip(3)
1896 obj.data = str(reader.read_all())
1897 return obj
1898
1899 def __eq__(self, other):
1900 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001901 if self.xid != other.xid: return False
1902 if self.tx_interval_ms != other.tx_interval_ms: return False
1903 if self.port_no != other.port_no: return False
1904 if self.slot_num != other.slot_num: return False
1905 if self.data != other.data: return False
1906 return True
1907
Rich Lane6f4978c2013-10-20 21:33:52 -07001908 def pretty_print(self, q):
1909 q.text("bsn_pdu_tx_request {")
1910 with q.group():
1911 with q.indent(2):
1912 q.breakable()
1913 q.text("xid = ");
1914 if self.xid != None:
1915 q.text("%#x" % self.xid)
1916 else:
1917 q.text('None')
1918 q.text(","); q.breakable()
1919 q.text("tx_interval_ms = ");
1920 q.text("%#x" % self.tx_interval_ms)
1921 q.text(","); q.breakable()
1922 q.text("port_no = ");
1923 q.text(util.pretty_port(self.port_no))
1924 q.text(","); q.breakable()
1925 q.text("slot_num = ");
1926 q.text("%#x" % self.slot_num)
1927 q.text(","); q.breakable()
1928 q.text("data = ");
1929 q.pp(self.data)
1930 q.breakable()
1931 q.text('}')
1932
Rich Lane7dcdf022013-12-11 14:45:27 -08001933bsn_header.subtypes[31] = bsn_pdu_tx_request
1934
1935class bsn_set_mirroring(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001936 version = 2
1937 type = 4
1938 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07001939 subtype = 3
1940
1941 def __init__(self, xid=None, report_mirror_ports=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001942 if xid != None:
1943 self.xid = xid
1944 else:
1945 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07001946 if report_mirror_ports != None:
1947 self.report_mirror_ports = report_mirror_ports
1948 else:
1949 self.report_mirror_ports = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001950 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07001951
1952 def pack(self):
1953 packed = []
1954 packed.append(struct.pack("!B", self.version))
1955 packed.append(struct.pack("!B", self.type))
1956 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1957 packed.append(struct.pack("!L", self.xid))
1958 packed.append(struct.pack("!L", self.experimenter))
1959 packed.append(struct.pack("!L", self.subtype))
1960 packed.append(struct.pack("!B", self.report_mirror_ports))
1961 packed.append('\x00' * 3)
1962 length = sum([len(x) for x in packed])
1963 packed[2] = struct.pack("!H", length)
1964 return ''.join(packed)
1965
1966 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001967 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001968 obj = bsn_set_mirroring()
Dan Talaycof6202252013-07-02 01:00:29 -07001969 _version = reader.read("!B")[0]
1970 assert(_version == 2)
1971 _type = reader.read("!B")[0]
1972 assert(_type == 4)
1973 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001974 orig_reader = reader
1975 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001976 obj.xid = reader.read("!L")[0]
1977 _experimenter = reader.read("!L")[0]
1978 assert(_experimenter == 6035143)
1979 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001980 assert(_subtype == 3)
Dan Talaycof6202252013-07-02 01:00:29 -07001981 obj.report_mirror_ports = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001982 reader.skip(3)
1983 return obj
1984
1985 def __eq__(self, other):
1986 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001987 if self.xid != other.xid: return False
1988 if self.report_mirror_ports != other.report_mirror_ports: return False
1989 return True
1990
Rich Lanec2ee4b82013-04-24 17:12:38 -07001991 def pretty_print(self, q):
1992 q.text("bsn_set_mirroring {")
1993 with q.group():
1994 with q.indent(2):
1995 q.breakable()
1996 q.text("xid = ");
1997 if self.xid != None:
1998 q.text("%#x" % self.xid)
1999 else:
2000 q.text('None')
2001 q.text(","); q.breakable()
2002 q.text("report_mirror_ports = ");
2003 q.text("%#x" % self.report_mirror_ports)
2004 q.breakable()
2005 q.text('}')
2006
Rich Lane7dcdf022013-12-11 14:45:27 -08002007bsn_header.subtypes[3] = bsn_set_mirroring
2008
2009class bsn_set_pktin_suppression_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07002010 version = 2
2011 type = 4
2012 experimenter = 6035143
2013 subtype = 25
2014
2015 def __init__(self, xid=None, status=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002016 if xid != None:
2017 self.xid = xid
2018 else:
2019 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07002020 if status != None:
2021 self.status = status
2022 else:
2023 self.status = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002024 return
Dan Talaycof6202252013-07-02 01:00:29 -07002025
2026 def pack(self):
2027 packed = []
2028 packed.append(struct.pack("!B", self.version))
2029 packed.append(struct.pack("!B", self.type))
2030 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2031 packed.append(struct.pack("!L", self.xid))
2032 packed.append(struct.pack("!L", self.experimenter))
2033 packed.append(struct.pack("!L", self.subtype))
2034 packed.append(struct.pack("!L", self.status))
2035 length = sum([len(x) for x in packed])
2036 packed[2] = struct.pack("!H", length)
2037 return ''.join(packed)
2038
2039 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002040 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07002041 obj = bsn_set_pktin_suppression_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07002042 _version = reader.read("!B")[0]
2043 assert(_version == 2)
2044 _type = reader.read("!B")[0]
2045 assert(_type == 4)
2046 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002047 orig_reader = reader
2048 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002049 obj.xid = reader.read("!L")[0]
2050 _experimenter = reader.read("!L")[0]
2051 assert(_experimenter == 6035143)
2052 _subtype = reader.read("!L")[0]
2053 assert(_subtype == 25)
2054 obj.status = reader.read("!L")[0]
2055 return obj
2056
2057 def __eq__(self, other):
2058 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07002059 if self.xid != other.xid: return False
2060 if self.status != other.status: return False
2061 return True
2062
Dan Talaycof6202252013-07-02 01:00:29 -07002063 def pretty_print(self, q):
2064 q.text("bsn_set_pktin_suppression_reply {")
2065 with q.group():
2066 with q.indent(2):
2067 q.breakable()
2068 q.text("xid = ");
2069 if self.xid != None:
2070 q.text("%#x" % self.xid)
2071 else:
2072 q.text('None')
2073 q.text(","); q.breakable()
2074 q.text("status = ");
2075 q.text("%#x" % self.status)
2076 q.breakable()
2077 q.text('}')
2078
Rich Lane7dcdf022013-12-11 14:45:27 -08002079bsn_header.subtypes[25] = bsn_set_pktin_suppression_reply
2080
2081class bsn_set_pktin_suppression_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07002082 version = 2
2083 type = 4
2084 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07002085 subtype = 11
2086
2087 def __init__(self, xid=None, enabled=None, idle_timeout=None, hard_timeout=None, priority=None, cookie=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002088 if xid != None:
2089 self.xid = xid
2090 else:
2091 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07002092 if enabled != None:
2093 self.enabled = enabled
2094 else:
2095 self.enabled = 0
2096 if idle_timeout != None:
2097 self.idle_timeout = idle_timeout
2098 else:
2099 self.idle_timeout = 0
2100 if hard_timeout != None:
2101 self.hard_timeout = hard_timeout
2102 else:
2103 self.hard_timeout = 0
2104 if priority != None:
2105 self.priority = priority
2106 else:
2107 self.priority = 0
2108 if cookie != None:
2109 self.cookie = cookie
2110 else:
2111 self.cookie = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002112 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07002113
2114 def pack(self):
2115 packed = []
2116 packed.append(struct.pack("!B", self.version))
2117 packed.append(struct.pack("!B", self.type))
2118 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2119 packed.append(struct.pack("!L", self.xid))
2120 packed.append(struct.pack("!L", self.experimenter))
2121 packed.append(struct.pack("!L", self.subtype))
2122 packed.append(struct.pack("!B", self.enabled))
2123 packed.append('\x00' * 1)
2124 packed.append(struct.pack("!H", self.idle_timeout))
2125 packed.append(struct.pack("!H", self.hard_timeout))
2126 packed.append(struct.pack("!H", self.priority))
2127 packed.append(struct.pack("!Q", self.cookie))
2128 length = sum([len(x) for x in packed])
2129 packed[2] = struct.pack("!H", length)
2130 return ''.join(packed)
2131
2132 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002133 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07002134 obj = bsn_set_pktin_suppression_request()
Dan Talaycof6202252013-07-02 01:00:29 -07002135 _version = reader.read("!B")[0]
2136 assert(_version == 2)
2137 _type = reader.read("!B")[0]
2138 assert(_type == 4)
2139 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002140 orig_reader = reader
2141 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002142 obj.xid = reader.read("!L")[0]
2143 _experimenter = reader.read("!L")[0]
2144 assert(_experimenter == 6035143)
2145 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002146 assert(_subtype == 11)
Dan Talaycof6202252013-07-02 01:00:29 -07002147 obj.enabled = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002148 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -07002149 obj.idle_timeout = reader.read("!H")[0]
2150 obj.hard_timeout = reader.read("!H")[0]
2151 obj.priority = reader.read("!H")[0]
2152 obj.cookie = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002153 return obj
2154
2155 def __eq__(self, other):
2156 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002157 if self.xid != other.xid: return False
2158 if self.enabled != other.enabled: return False
2159 if self.idle_timeout != other.idle_timeout: return False
2160 if self.hard_timeout != other.hard_timeout: return False
2161 if self.priority != other.priority: return False
2162 if self.cookie != other.cookie: return False
2163 return True
2164
Rich Lanec2ee4b82013-04-24 17:12:38 -07002165 def pretty_print(self, q):
Dan Talaycof6202252013-07-02 01:00:29 -07002166 q.text("bsn_set_pktin_suppression_request {")
Rich Lanec2ee4b82013-04-24 17:12:38 -07002167 with q.group():
2168 with q.indent(2):
2169 q.breakable()
2170 q.text("xid = ");
2171 if self.xid != None:
2172 q.text("%#x" % self.xid)
2173 else:
2174 q.text('None')
2175 q.text(","); q.breakable()
2176 q.text("enabled = ");
2177 q.text("%#x" % self.enabled)
2178 q.text(","); q.breakable()
2179 q.text("idle_timeout = ");
2180 q.text("%#x" % self.idle_timeout)
2181 q.text(","); q.breakable()
2182 q.text("hard_timeout = ");
2183 q.text("%#x" % self.hard_timeout)
2184 q.text(","); q.breakable()
2185 q.text("priority = ");
2186 q.text("%#x" % self.priority)
2187 q.text(","); q.breakable()
2188 q.text("cookie = ");
2189 q.text("%#x" % self.cookie)
2190 q.breakable()
2191 q.text('}')
2192
Rich Lane7dcdf022013-12-11 14:45:27 -08002193bsn_header.subtypes[11] = bsn_set_pktin_suppression_request
2194
2195class experimenter_stats_reply(stats_reply):
2196 subtypes = {}
2197
2198 @staticmethod
2199 def unpack(reader):
2200 subtype, = reader.peek('!L', 16)
2201 try:
2202 subclass = experimenter_stats_reply.subtypes[subtype]
2203 except KeyError:
2204 raise loxi.ProtocolError("unknown experimenter_stats_reply stats_reply message subtype %#x" % subtype)
2205 return subclass.unpack(reader)
2206
2207stats_reply.subtypes[65535] = experimenter_stats_reply
2208
2209class bsn_stats_reply(experimenter_stats_reply):
2210 subtypes = {}
2211
2212 @staticmethod
2213 def unpack(reader):
2214 subtype, = reader.peek('!L', 20)
2215 try:
2216 subclass = bsn_stats_reply.subtypes[subtype]
2217 except KeyError:
2218 raise loxi.ProtocolError("unknown bsn_stats_reply experimenter_stats_reply stats_reply message subtype %#x" % subtype)
2219 return subclass.unpack(reader)
2220
2221experimenter_stats_reply.subtypes[6035143] = bsn_stats_reply
2222
2223class experimenter_stats_request(stats_request):
2224 subtypes = {}
2225
2226 @staticmethod
2227 def unpack(reader):
2228 subtype, = reader.peek('!L', 16)
2229 try:
2230 subclass = experimenter_stats_request.subtypes[subtype]
2231 except KeyError:
2232 raise loxi.ProtocolError("unknown experimenter_stats_request stats_request message subtype %#x" % subtype)
2233 return subclass.unpack(reader)
2234
2235stats_request.subtypes[65535] = experimenter_stats_request
2236
2237class bsn_stats_request(experimenter_stats_request):
2238 subtypes = {}
2239
2240 @staticmethod
2241 def unpack(reader):
2242 subtype, = reader.peek('!L', 20)
2243 try:
2244 subclass = bsn_stats_request.subtypes[subtype]
2245 except KeyError:
2246 raise loxi.ProtocolError("unknown bsn_stats_request experimenter_stats_request stats_request message subtype %#x" % subtype)
2247 return subclass.unpack(reader)
2248
2249experimenter_stats_request.subtypes[6035143] = bsn_stats_request
2250
2251class bsn_virtual_port_create_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07002252 version = 2
2253 type = 4
2254 experimenter = 6035143
2255 subtype = 16
2256
2257 def __init__(self, xid=None, status=None, vport_no=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002258 if xid != None:
2259 self.xid = xid
2260 else:
2261 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07002262 if status != None:
2263 self.status = status
2264 else:
2265 self.status = 0
2266 if vport_no != None:
2267 self.vport_no = vport_no
2268 else:
2269 self.vport_no = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002270 return
Dan Talaycof6202252013-07-02 01:00:29 -07002271
2272 def pack(self):
2273 packed = []
2274 packed.append(struct.pack("!B", self.version))
2275 packed.append(struct.pack("!B", self.type))
2276 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2277 packed.append(struct.pack("!L", self.xid))
2278 packed.append(struct.pack("!L", self.experimenter))
2279 packed.append(struct.pack("!L", self.subtype))
2280 packed.append(struct.pack("!L", self.status))
2281 packed.append(struct.pack("!L", self.vport_no))
2282 length = sum([len(x) for x in packed])
2283 packed[2] = struct.pack("!H", length)
2284 return ''.join(packed)
2285
2286 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002287 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07002288 obj = bsn_virtual_port_create_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07002289 _version = reader.read("!B")[0]
2290 assert(_version == 2)
2291 _type = reader.read("!B")[0]
2292 assert(_type == 4)
2293 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002294 orig_reader = reader
2295 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002296 obj.xid = reader.read("!L")[0]
2297 _experimenter = reader.read("!L")[0]
2298 assert(_experimenter == 6035143)
2299 _subtype = reader.read("!L")[0]
2300 assert(_subtype == 16)
2301 obj.status = reader.read("!L")[0]
2302 obj.vport_no = reader.read("!L")[0]
2303 return obj
2304
2305 def __eq__(self, other):
2306 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07002307 if self.xid != other.xid: return False
2308 if self.status != other.status: return False
2309 if self.vport_no != other.vport_no: return False
2310 return True
2311
Dan Talaycof6202252013-07-02 01:00:29 -07002312 def pretty_print(self, q):
2313 q.text("bsn_virtual_port_create_reply {")
2314 with q.group():
2315 with q.indent(2):
2316 q.breakable()
2317 q.text("xid = ");
2318 if self.xid != None:
2319 q.text("%#x" % self.xid)
2320 else:
2321 q.text('None')
2322 q.text(","); q.breakable()
2323 q.text("status = ");
2324 q.text("%#x" % self.status)
2325 q.text(","); q.breakable()
2326 q.text("vport_no = ");
2327 q.text("%#x" % self.vport_no)
2328 q.breakable()
2329 q.text('}')
2330
Rich Lane7dcdf022013-12-11 14:45:27 -08002331bsn_header.subtypes[16] = bsn_virtual_port_create_reply
2332
2333class bsn_virtual_port_create_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07002334 version = 2
2335 type = 4
2336 experimenter = 6035143
2337 subtype = 15
2338
2339 def __init__(self, xid=None, vport=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002340 if xid != None:
2341 self.xid = xid
2342 else:
2343 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07002344 if vport != None:
2345 self.vport = vport
2346 else:
2347 self.vport = common.bsn_vport_q_in_q()
Rich Lane7dcdf022013-12-11 14:45:27 -08002348 return
Dan Talaycof6202252013-07-02 01:00:29 -07002349
2350 def pack(self):
2351 packed = []
2352 packed.append(struct.pack("!B", self.version))
2353 packed.append(struct.pack("!B", self.type))
2354 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2355 packed.append(struct.pack("!L", self.xid))
2356 packed.append(struct.pack("!L", self.experimenter))
2357 packed.append(struct.pack("!L", self.subtype))
2358 packed.append(self.vport.pack())
2359 length = sum([len(x) for x in packed])
2360 packed[2] = struct.pack("!H", length)
2361 return ''.join(packed)
2362
2363 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002364 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07002365 obj = bsn_virtual_port_create_request()
Dan Talaycof6202252013-07-02 01:00:29 -07002366 _version = reader.read("!B")[0]
2367 assert(_version == 2)
2368 _type = reader.read("!B")[0]
2369 assert(_type == 4)
2370 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002371 orig_reader = reader
2372 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002373 obj.xid = reader.read("!L")[0]
2374 _experimenter = reader.read("!L")[0]
2375 assert(_experimenter == 6035143)
2376 _subtype = reader.read("!L")[0]
2377 assert(_subtype == 15)
2378 obj.vport = common.bsn_vport_q_in_q.unpack(reader)
2379 return obj
2380
2381 def __eq__(self, other):
2382 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07002383 if self.xid != other.xid: return False
2384 if self.vport != other.vport: return False
2385 return True
2386
Dan Talaycof6202252013-07-02 01:00:29 -07002387 def pretty_print(self, q):
2388 q.text("bsn_virtual_port_create_request {")
2389 with q.group():
2390 with q.indent(2):
2391 q.breakable()
2392 q.text("xid = ");
2393 if self.xid != None:
2394 q.text("%#x" % self.xid)
2395 else:
2396 q.text('None')
2397 q.text(","); q.breakable()
2398 q.text("vport = ");
2399 q.pp(self.vport)
2400 q.breakable()
2401 q.text('}')
2402
Rich Lane7dcdf022013-12-11 14:45:27 -08002403bsn_header.subtypes[15] = bsn_virtual_port_create_request
2404
2405class bsn_virtual_port_remove_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07002406 version = 2
2407 type = 4
2408 experimenter = 6035143
2409 subtype = 26
2410
2411 def __init__(self, xid=None, status=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002412 if xid != None:
2413 self.xid = xid
2414 else:
2415 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07002416 if status != None:
2417 self.status = status
2418 else:
2419 self.status = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002420 return
Dan Talaycof6202252013-07-02 01:00:29 -07002421
2422 def pack(self):
2423 packed = []
2424 packed.append(struct.pack("!B", self.version))
2425 packed.append(struct.pack("!B", self.type))
2426 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2427 packed.append(struct.pack("!L", self.xid))
2428 packed.append(struct.pack("!L", self.experimenter))
2429 packed.append(struct.pack("!L", self.subtype))
2430 packed.append(struct.pack("!L", self.status))
2431 length = sum([len(x) for x in packed])
2432 packed[2] = struct.pack("!H", length)
2433 return ''.join(packed)
2434
2435 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002436 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07002437 obj = bsn_virtual_port_remove_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07002438 _version = reader.read("!B")[0]
2439 assert(_version == 2)
2440 _type = reader.read("!B")[0]
2441 assert(_type == 4)
2442 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002443 orig_reader = reader
2444 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002445 obj.xid = reader.read("!L")[0]
2446 _experimenter = reader.read("!L")[0]
2447 assert(_experimenter == 6035143)
2448 _subtype = reader.read("!L")[0]
2449 assert(_subtype == 26)
2450 obj.status = reader.read("!L")[0]
2451 return obj
2452
2453 def __eq__(self, other):
2454 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07002455 if self.xid != other.xid: return False
2456 if self.status != other.status: return False
2457 return True
2458
Dan Talaycof6202252013-07-02 01:00:29 -07002459 def pretty_print(self, q):
2460 q.text("bsn_virtual_port_remove_reply {")
2461 with q.group():
2462 with q.indent(2):
2463 q.breakable()
2464 q.text("xid = ");
2465 if self.xid != None:
2466 q.text("%#x" % self.xid)
2467 else:
2468 q.text('None')
2469 q.text(","); q.breakable()
2470 q.text("status = ");
2471 q.text("%#x" % self.status)
2472 q.breakable()
2473 q.text('}')
2474
Rich Lane7dcdf022013-12-11 14:45:27 -08002475bsn_header.subtypes[26] = bsn_virtual_port_remove_reply
2476
2477class bsn_virtual_port_remove_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07002478 version = 2
2479 type = 4
2480 experimenter = 6035143
2481 subtype = 17
2482
2483 def __init__(self, xid=None, vport_no=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002484 if xid != None:
2485 self.xid = xid
2486 else:
2487 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07002488 if vport_no != None:
2489 self.vport_no = vport_no
2490 else:
2491 self.vport_no = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002492 return
Dan Talaycof6202252013-07-02 01:00:29 -07002493
2494 def pack(self):
2495 packed = []
2496 packed.append(struct.pack("!B", self.version))
2497 packed.append(struct.pack("!B", self.type))
2498 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2499 packed.append(struct.pack("!L", self.xid))
2500 packed.append(struct.pack("!L", self.experimenter))
2501 packed.append(struct.pack("!L", self.subtype))
2502 packed.append(struct.pack("!L", self.vport_no))
2503 length = sum([len(x) for x in packed])
2504 packed[2] = struct.pack("!H", length)
2505 return ''.join(packed)
2506
2507 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002508 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07002509 obj = bsn_virtual_port_remove_request()
Dan Talaycof6202252013-07-02 01:00:29 -07002510 _version = reader.read("!B")[0]
2511 assert(_version == 2)
2512 _type = reader.read("!B")[0]
2513 assert(_type == 4)
2514 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002515 orig_reader = reader
2516 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002517 obj.xid = reader.read("!L")[0]
2518 _experimenter = reader.read("!L")[0]
2519 assert(_experimenter == 6035143)
2520 _subtype = reader.read("!L")[0]
2521 assert(_subtype == 17)
2522 obj.vport_no = reader.read("!L")[0]
2523 return obj
2524
2525 def __eq__(self, other):
2526 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07002527 if self.xid != other.xid: return False
2528 if self.vport_no != other.vport_no: return False
2529 return True
2530
Dan Talaycof6202252013-07-02 01:00:29 -07002531 def pretty_print(self, q):
2532 q.text("bsn_virtual_port_remove_request {")
2533 with q.group():
2534 with q.indent(2):
2535 q.breakable()
2536 q.text("xid = ");
2537 if self.xid != None:
2538 q.text("%#x" % self.xid)
2539 else:
2540 q.text('None')
2541 q.text(","); q.breakable()
2542 q.text("vport_no = ");
2543 q.text("%#x" % self.vport_no)
2544 q.breakable()
2545 q.text('}')
2546
Rich Lane7dcdf022013-12-11 14:45:27 -08002547bsn_header.subtypes[17] = bsn_virtual_port_remove_request
2548
2549class desc_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07002550 version = 2
2551 type = 19
2552 stats_type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07002553
2554 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 -08002555 if xid != None:
2556 self.xid = xid
2557 else:
2558 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07002559 if flags != None:
2560 self.flags = flags
2561 else:
2562 self.flags = 0
2563 if mfr_desc != None:
2564 self.mfr_desc = mfr_desc
2565 else:
2566 self.mfr_desc = ""
2567 if hw_desc != None:
2568 self.hw_desc = hw_desc
2569 else:
2570 self.hw_desc = ""
2571 if sw_desc != None:
2572 self.sw_desc = sw_desc
2573 else:
2574 self.sw_desc = ""
2575 if serial_num != None:
2576 self.serial_num = serial_num
2577 else:
2578 self.serial_num = ""
2579 if dp_desc != None:
2580 self.dp_desc = dp_desc
2581 else:
2582 self.dp_desc = ""
Rich Lane7dcdf022013-12-11 14:45:27 -08002583 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07002584
2585 def pack(self):
2586 packed = []
2587 packed.append(struct.pack("!B", self.version))
2588 packed.append(struct.pack("!B", self.type))
2589 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2590 packed.append(struct.pack("!L", self.xid))
2591 packed.append(struct.pack("!H", self.stats_type))
2592 packed.append(struct.pack("!H", self.flags))
2593 packed.append('\x00' * 4)
2594 packed.append(struct.pack("!256s", self.mfr_desc))
2595 packed.append(struct.pack("!256s", self.hw_desc))
2596 packed.append(struct.pack("!256s", self.sw_desc))
2597 packed.append(struct.pack("!32s", self.serial_num))
2598 packed.append(struct.pack("!256s", self.dp_desc))
2599 length = sum([len(x) for x in packed])
2600 packed[2] = struct.pack("!H", length)
2601 return ''.join(packed)
2602
2603 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002604 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002605 obj = desc_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07002606 _version = reader.read("!B")[0]
2607 assert(_version == 2)
2608 _type = reader.read("!B")[0]
2609 assert(_type == 19)
2610 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002611 orig_reader = reader
2612 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002613 obj.xid = reader.read("!L")[0]
2614 _stats_type = reader.read("!H")[0]
2615 assert(_stats_type == 0)
2616 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002617 reader.skip(4)
2618 obj.mfr_desc = reader.read("!256s")[0].rstrip("\x00")
2619 obj.hw_desc = reader.read("!256s")[0].rstrip("\x00")
2620 obj.sw_desc = reader.read("!256s")[0].rstrip("\x00")
2621 obj.serial_num = reader.read("!32s")[0].rstrip("\x00")
2622 obj.dp_desc = reader.read("!256s")[0].rstrip("\x00")
2623 return obj
2624
2625 def __eq__(self, other):
2626 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002627 if self.xid != other.xid: return False
2628 if self.flags != other.flags: return False
2629 if self.mfr_desc != other.mfr_desc: return False
2630 if self.hw_desc != other.hw_desc: return False
2631 if self.sw_desc != other.sw_desc: return False
2632 if self.serial_num != other.serial_num: return False
2633 if self.dp_desc != other.dp_desc: return False
2634 return True
2635
Rich Lanec2ee4b82013-04-24 17:12:38 -07002636 def pretty_print(self, q):
2637 q.text("desc_stats_reply {")
2638 with q.group():
2639 with q.indent(2):
2640 q.breakable()
2641 q.text("xid = ");
2642 if self.xid != None:
2643 q.text("%#x" % self.xid)
2644 else:
2645 q.text('None')
2646 q.text(","); q.breakable()
2647 q.text("flags = ");
2648 q.text("%#x" % self.flags)
2649 q.text(","); q.breakable()
2650 q.text("mfr_desc = ");
2651 q.pp(self.mfr_desc)
2652 q.text(","); q.breakable()
2653 q.text("hw_desc = ");
2654 q.pp(self.hw_desc)
2655 q.text(","); q.breakable()
2656 q.text("sw_desc = ");
2657 q.pp(self.sw_desc)
2658 q.text(","); q.breakable()
2659 q.text("serial_num = ");
2660 q.pp(self.serial_num)
2661 q.text(","); q.breakable()
2662 q.text("dp_desc = ");
2663 q.pp(self.dp_desc)
2664 q.breakable()
2665 q.text('}')
2666
Rich Lane7dcdf022013-12-11 14:45:27 -08002667stats_reply.subtypes[0] = desc_stats_reply
2668
2669class desc_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07002670 version = 2
2671 type = 18
2672 stats_type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07002673
2674 def __init__(self, xid=None, flags=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002675 if xid != None:
2676 self.xid = xid
2677 else:
2678 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07002679 if flags != None:
2680 self.flags = flags
2681 else:
2682 self.flags = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002683 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07002684
2685 def pack(self):
2686 packed = []
2687 packed.append(struct.pack("!B", self.version))
2688 packed.append(struct.pack("!B", self.type))
2689 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2690 packed.append(struct.pack("!L", self.xid))
2691 packed.append(struct.pack("!H", self.stats_type))
2692 packed.append(struct.pack("!H", self.flags))
2693 packed.append('\x00' * 4)
2694 length = sum([len(x) for x in packed])
2695 packed[2] = struct.pack("!H", length)
2696 return ''.join(packed)
2697
2698 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002699 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002700 obj = desc_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07002701 _version = reader.read("!B")[0]
2702 assert(_version == 2)
2703 _type = reader.read("!B")[0]
2704 assert(_type == 18)
2705 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002706 orig_reader = reader
2707 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002708 obj.xid = reader.read("!L")[0]
2709 _stats_type = reader.read("!H")[0]
2710 assert(_stats_type == 0)
2711 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002712 reader.skip(4)
2713 return obj
2714
2715 def __eq__(self, other):
2716 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002717 if self.xid != other.xid: return False
2718 if self.flags != other.flags: return False
2719 return True
2720
Rich Lanec2ee4b82013-04-24 17:12:38 -07002721 def pretty_print(self, q):
2722 q.text("desc_stats_request {")
2723 with q.group():
2724 with q.indent(2):
2725 q.breakable()
2726 q.text("xid = ");
2727 if self.xid != None:
2728 q.text("%#x" % self.xid)
2729 else:
2730 q.text('None')
2731 q.text(","); q.breakable()
2732 q.text("flags = ");
2733 q.text("%#x" % self.flags)
2734 q.breakable()
2735 q.text('}')
2736
Rich Lane7dcdf022013-12-11 14:45:27 -08002737stats_request.subtypes[0] = desc_stats_request
2738
2739class echo_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -07002740 version = 2
2741 type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07002742
2743 def __init__(self, xid=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002744 if xid != None:
2745 self.xid = xid
2746 else:
2747 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07002748 if data != None:
2749 self.data = data
2750 else:
Dan Talaycof6202252013-07-02 01:00:29 -07002751 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08002752 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07002753
2754 def pack(self):
2755 packed = []
2756 packed.append(struct.pack("!B", self.version))
2757 packed.append(struct.pack("!B", self.type))
2758 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2759 packed.append(struct.pack("!L", self.xid))
2760 packed.append(self.data)
2761 length = sum([len(x) for x in packed])
2762 packed[2] = struct.pack("!H", length)
2763 return ''.join(packed)
2764
2765 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002766 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002767 obj = echo_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07002768 _version = reader.read("!B")[0]
2769 assert(_version == 2)
2770 _type = reader.read("!B")[0]
2771 assert(_type == 3)
2772 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002773 orig_reader = reader
2774 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002775 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002776 obj.data = str(reader.read_all())
2777 return obj
2778
2779 def __eq__(self, other):
2780 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002781 if self.xid != other.xid: return False
2782 if self.data != other.data: return False
2783 return True
2784
Rich Lanec2ee4b82013-04-24 17:12:38 -07002785 def pretty_print(self, q):
2786 q.text("echo_reply {")
2787 with q.group():
2788 with q.indent(2):
2789 q.breakable()
2790 q.text("xid = ");
2791 if self.xid != None:
2792 q.text("%#x" % self.xid)
2793 else:
2794 q.text('None')
2795 q.text(","); q.breakable()
2796 q.text("data = ");
2797 q.pp(self.data)
2798 q.breakable()
2799 q.text('}')
2800
Rich Lane7dcdf022013-12-11 14:45:27 -08002801message.subtypes[3] = echo_reply
2802
2803class echo_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -07002804 version = 2
2805 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07002806
2807 def __init__(self, xid=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002808 if xid != None:
2809 self.xid = xid
2810 else:
2811 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07002812 if data != None:
2813 self.data = data
2814 else:
Dan Talaycof6202252013-07-02 01:00:29 -07002815 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08002816 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07002817
2818 def pack(self):
2819 packed = []
2820 packed.append(struct.pack("!B", self.version))
2821 packed.append(struct.pack("!B", self.type))
2822 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2823 packed.append(struct.pack("!L", self.xid))
2824 packed.append(self.data)
2825 length = sum([len(x) for x in packed])
2826 packed[2] = struct.pack("!H", length)
2827 return ''.join(packed)
2828
2829 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002830 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002831 obj = echo_request()
Dan Talaycof6202252013-07-02 01:00:29 -07002832 _version = reader.read("!B")[0]
2833 assert(_version == 2)
2834 _type = reader.read("!B")[0]
2835 assert(_type == 2)
2836 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002837 orig_reader = reader
2838 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002839 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002840 obj.data = str(reader.read_all())
2841 return obj
2842
2843 def __eq__(self, other):
2844 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002845 if self.xid != other.xid: return False
2846 if self.data != other.data: return False
2847 return True
2848
Rich Lanec2ee4b82013-04-24 17:12:38 -07002849 def pretty_print(self, q):
2850 q.text("echo_request {")
2851 with q.group():
2852 with q.indent(2):
2853 q.breakable()
2854 q.text("xid = ");
2855 if self.xid != None:
2856 q.text("%#x" % self.xid)
2857 else:
2858 q.text('None')
2859 q.text(","); q.breakable()
2860 q.text("data = ");
2861 q.pp(self.data)
2862 q.breakable()
2863 q.text('}')
2864
Rich Lane7dcdf022013-12-11 14:45:27 -08002865message.subtypes[2] = echo_request
2866
2867class features_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -07002868 version = 2
2869 type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07002870
2871 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 -08002872 if xid != None:
2873 self.xid = xid
2874 else:
2875 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07002876 if datapath_id != None:
2877 self.datapath_id = datapath_id
2878 else:
2879 self.datapath_id = 0
2880 if n_buffers != None:
2881 self.n_buffers = n_buffers
2882 else:
2883 self.n_buffers = 0
2884 if n_tables != None:
2885 self.n_tables = n_tables
2886 else:
2887 self.n_tables = 0
2888 if capabilities != None:
2889 self.capabilities = capabilities
2890 else:
2891 self.capabilities = 0
2892 if reserved != None:
2893 self.reserved = reserved
2894 else:
2895 self.reserved = 0
2896 if ports != None:
2897 self.ports = ports
2898 else:
2899 self.ports = []
Rich Lane7dcdf022013-12-11 14:45:27 -08002900 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07002901
2902 def pack(self):
2903 packed = []
2904 packed.append(struct.pack("!B", self.version))
2905 packed.append(struct.pack("!B", self.type))
2906 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2907 packed.append(struct.pack("!L", self.xid))
2908 packed.append(struct.pack("!Q", self.datapath_id))
2909 packed.append(struct.pack("!L", self.n_buffers))
2910 packed.append(struct.pack("!B", self.n_tables))
2911 packed.append('\x00' * 3)
2912 packed.append(struct.pack("!L", self.capabilities))
2913 packed.append(struct.pack("!L", self.reserved))
Rich Lane7dcdf022013-12-11 14:45:27 -08002914 packed.append(loxi.generic_util.pack_list(self.ports))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002915 length = sum([len(x) for x in packed])
2916 packed[2] = struct.pack("!H", length)
2917 return ''.join(packed)
2918
2919 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002920 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002921 obj = features_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07002922 _version = reader.read("!B")[0]
2923 assert(_version == 2)
2924 _type = reader.read("!B")[0]
2925 assert(_type == 6)
2926 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002927 orig_reader = reader
2928 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002929 obj.xid = reader.read("!L")[0]
2930 obj.datapath_id = reader.read("!Q")[0]
2931 obj.n_buffers = reader.read("!L")[0]
2932 obj.n_tables = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002933 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07002934 obj.capabilities = reader.read("!L")[0]
2935 obj.reserved = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002936 obj.ports = loxi.generic_util.unpack_list(reader, common.port_desc.unpack)
2937 return obj
2938
2939 def __eq__(self, other):
2940 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002941 if self.xid != other.xid: return False
2942 if self.datapath_id != other.datapath_id: return False
2943 if self.n_buffers != other.n_buffers: return False
2944 if self.n_tables != other.n_tables: return False
2945 if self.capabilities != other.capabilities: return False
2946 if self.reserved != other.reserved: return False
2947 if self.ports != other.ports: return False
2948 return True
2949
Rich Lanec2ee4b82013-04-24 17:12:38 -07002950 def pretty_print(self, q):
2951 q.text("features_reply {")
2952 with q.group():
2953 with q.indent(2):
2954 q.breakable()
2955 q.text("xid = ");
2956 if self.xid != None:
2957 q.text("%#x" % self.xid)
2958 else:
2959 q.text('None')
2960 q.text(","); q.breakable()
2961 q.text("datapath_id = ");
2962 q.text("%#x" % self.datapath_id)
2963 q.text(","); q.breakable()
2964 q.text("n_buffers = ");
2965 q.text("%#x" % self.n_buffers)
2966 q.text(","); q.breakable()
2967 q.text("n_tables = ");
2968 q.text("%#x" % self.n_tables)
2969 q.text(","); q.breakable()
2970 q.text("capabilities = ");
2971 q.text("%#x" % self.capabilities)
2972 q.text(","); q.breakable()
2973 q.text("reserved = ");
2974 q.text("%#x" % self.reserved)
2975 q.text(","); q.breakable()
2976 q.text("ports = ");
2977 q.pp(self.ports)
2978 q.breakable()
2979 q.text('}')
2980
Rich Lane7dcdf022013-12-11 14:45:27 -08002981message.subtypes[6] = features_reply
2982
2983class features_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -07002984 version = 2
2985 type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07002986
2987 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002988 if xid != None:
2989 self.xid = xid
2990 else:
2991 self.xid = None
2992 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07002993
2994 def pack(self):
2995 packed = []
2996 packed.append(struct.pack("!B", self.version))
2997 packed.append(struct.pack("!B", self.type))
2998 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2999 packed.append(struct.pack("!L", self.xid))
3000 length = sum([len(x) for x in packed])
3001 packed[2] = struct.pack("!H", length)
3002 return ''.join(packed)
3003
3004 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003005 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003006 obj = features_request()
Dan Talaycof6202252013-07-02 01:00:29 -07003007 _version = reader.read("!B")[0]
3008 assert(_version == 2)
3009 _type = reader.read("!B")[0]
3010 assert(_type == 5)
3011 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003012 orig_reader = reader
3013 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003014 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003015 return obj
3016
3017 def __eq__(self, other):
3018 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003019 if self.xid != other.xid: return False
3020 return True
3021
Rich Lanec2ee4b82013-04-24 17:12:38 -07003022 def pretty_print(self, q):
3023 q.text("features_request {")
3024 with q.group():
3025 with q.indent(2):
3026 q.breakable()
3027 q.text("xid = ");
3028 if self.xid != None:
3029 q.text("%#x" % self.xid)
3030 else:
3031 q.text('None')
3032 q.breakable()
3033 q.text('}')
3034
Rich Lane7dcdf022013-12-11 14:45:27 -08003035message.subtypes[5] = features_request
3036
3037class flow_mod(message):
3038 subtypes = {}
3039
3040 @staticmethod
3041 def unpack(reader):
3042 subtype, = reader.peek('B', 25)
3043 try:
3044 subclass = flow_mod.subtypes[subtype]
3045 except KeyError:
3046 raise loxi.ProtocolError("unknown flow_mod message subtype %#x" % subtype)
3047 return subclass.unpack(reader)
3048
3049message.subtypes[14] = flow_mod
3050
3051class flow_add(flow_mod):
Dan Talaycof6202252013-07-02 01:00:29 -07003052 version = 2
3053 type = 14
3054 _command = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07003055
3056 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 -08003057 if xid != None:
3058 self.xid = xid
3059 else:
3060 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003061 if cookie != None:
3062 self.cookie = cookie
3063 else:
3064 self.cookie = 0
3065 if cookie_mask != None:
3066 self.cookie_mask = cookie_mask
3067 else:
3068 self.cookie_mask = 0
3069 if table_id != None:
3070 self.table_id = table_id
3071 else:
3072 self.table_id = 0
3073 if idle_timeout != None:
3074 self.idle_timeout = idle_timeout
3075 else:
3076 self.idle_timeout = 0
3077 if hard_timeout != None:
3078 self.hard_timeout = hard_timeout
3079 else:
3080 self.hard_timeout = 0
3081 if priority != None:
3082 self.priority = priority
3083 else:
3084 self.priority = 0
3085 if buffer_id != None:
3086 self.buffer_id = buffer_id
3087 else:
3088 self.buffer_id = 0
3089 if out_port != None:
3090 self.out_port = out_port
3091 else:
3092 self.out_port = 0
3093 if out_group != None:
3094 self.out_group = out_group
3095 else:
3096 self.out_group = 0
3097 if flags != None:
3098 self.flags = flags
3099 else:
3100 self.flags = 0
3101 if match != None:
3102 self.match = match
3103 else:
3104 self.match = common.match()
3105 if instructions != None:
3106 self.instructions = instructions
3107 else:
3108 self.instructions = []
Rich Lane7dcdf022013-12-11 14:45:27 -08003109 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003110
3111 def pack(self):
3112 packed = []
3113 packed.append(struct.pack("!B", self.version))
3114 packed.append(struct.pack("!B", self.type))
3115 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3116 packed.append(struct.pack("!L", self.xid))
3117 packed.append(struct.pack("!Q", self.cookie))
3118 packed.append(struct.pack("!Q", self.cookie_mask))
3119 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003120 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003121 packed.append(struct.pack("!H", self.idle_timeout))
3122 packed.append(struct.pack("!H", self.hard_timeout))
3123 packed.append(struct.pack("!H", self.priority))
3124 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003125 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003126 packed.append(struct.pack("!L", self.out_group))
3127 packed.append(struct.pack("!H", self.flags))
3128 packed.append('\x00' * 2)
3129 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08003130 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003131 length = sum([len(x) for x in packed])
3132 packed[2] = struct.pack("!H", length)
3133 return ''.join(packed)
3134
3135 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003136 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003137 obj = flow_add()
Dan Talaycof6202252013-07-02 01:00:29 -07003138 _version = reader.read("!B")[0]
3139 assert(_version == 2)
3140 _type = reader.read("!B")[0]
3141 assert(_type == 14)
3142 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003143 orig_reader = reader
3144 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003145 obj.xid = reader.read("!L")[0]
3146 obj.cookie = reader.read("!Q")[0]
3147 obj.cookie_mask = reader.read("!Q")[0]
3148 obj.table_id = reader.read("!B")[0]
3149 __command = util.unpack_fm_cmd(reader)
3150 assert(__command == 0)
3151 obj.idle_timeout = reader.read("!H")[0]
3152 obj.hard_timeout = reader.read("!H")[0]
3153 obj.priority = reader.read("!H")[0]
3154 obj.buffer_id = reader.read("!L")[0]
3155 obj.out_port = util.unpack_port_no(reader)
3156 obj.out_group = reader.read("!L")[0]
3157 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003158 reader.skip(2)
3159 obj.match = common.match.unpack(reader)
Rich Lane7dcdf022013-12-11 14:45:27 -08003160 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003161 return obj
3162
3163 def __eq__(self, other):
3164 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003165 if self.xid != other.xid: return False
3166 if self.cookie != other.cookie: return False
3167 if self.cookie_mask != other.cookie_mask: return False
3168 if self.table_id != other.table_id: return False
3169 if self.idle_timeout != other.idle_timeout: return False
3170 if self.hard_timeout != other.hard_timeout: return False
3171 if self.priority != other.priority: return False
3172 if self.buffer_id != other.buffer_id: return False
3173 if self.out_port != other.out_port: return False
3174 if self.out_group != other.out_group: return False
3175 if self.flags != other.flags: return False
3176 if self.match != other.match: return False
3177 if self.instructions != other.instructions: return False
3178 return True
3179
Rich Lanec2ee4b82013-04-24 17:12:38 -07003180 def pretty_print(self, q):
3181 q.text("flow_add {")
3182 with q.group():
3183 with q.indent(2):
3184 q.breakable()
3185 q.text("xid = ");
3186 if self.xid != None:
3187 q.text("%#x" % self.xid)
3188 else:
3189 q.text('None')
3190 q.text(","); q.breakable()
3191 q.text("cookie = ");
3192 q.text("%#x" % self.cookie)
3193 q.text(","); q.breakable()
3194 q.text("cookie_mask = ");
3195 q.text("%#x" % self.cookie_mask)
3196 q.text(","); q.breakable()
3197 q.text("table_id = ");
3198 q.text("%#x" % self.table_id)
3199 q.text(","); q.breakable()
3200 q.text("idle_timeout = ");
3201 q.text("%#x" % self.idle_timeout)
3202 q.text(","); q.breakable()
3203 q.text("hard_timeout = ");
3204 q.text("%#x" % self.hard_timeout)
3205 q.text(","); q.breakable()
3206 q.text("priority = ");
3207 q.text("%#x" % self.priority)
3208 q.text(","); q.breakable()
3209 q.text("buffer_id = ");
3210 q.text("%#x" % self.buffer_id)
3211 q.text(","); q.breakable()
3212 q.text("out_port = ");
3213 q.text(util.pretty_port(self.out_port))
3214 q.text(","); q.breakable()
3215 q.text("out_group = ");
3216 q.text("%#x" % self.out_group)
3217 q.text(","); q.breakable()
3218 q.text("flags = ");
3219 q.text("%#x" % self.flags)
3220 q.text(","); q.breakable()
3221 q.text("match = ");
3222 q.pp(self.match)
3223 q.text(","); q.breakable()
3224 q.text("instructions = ");
3225 q.pp(self.instructions)
3226 q.breakable()
3227 q.text('}')
3228
Rich Lane7dcdf022013-12-11 14:45:27 -08003229flow_mod.subtypes[0] = flow_add
3230
3231class flow_delete(flow_mod):
Dan Talaycof6202252013-07-02 01:00:29 -07003232 version = 2
3233 type = 14
3234 _command = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07003235
3236 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 -08003237 if xid != None:
3238 self.xid = xid
3239 else:
3240 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003241 if cookie != None:
3242 self.cookie = cookie
3243 else:
3244 self.cookie = 0
3245 if cookie_mask != None:
3246 self.cookie_mask = cookie_mask
3247 else:
3248 self.cookie_mask = 0
3249 if table_id != None:
3250 self.table_id = table_id
3251 else:
3252 self.table_id = 0
3253 if idle_timeout != None:
3254 self.idle_timeout = idle_timeout
3255 else:
3256 self.idle_timeout = 0
3257 if hard_timeout != None:
3258 self.hard_timeout = hard_timeout
3259 else:
3260 self.hard_timeout = 0
3261 if priority != None:
3262 self.priority = priority
3263 else:
3264 self.priority = 0
3265 if buffer_id != None:
3266 self.buffer_id = buffer_id
3267 else:
3268 self.buffer_id = 0
3269 if out_port != None:
3270 self.out_port = out_port
3271 else:
3272 self.out_port = 0
3273 if out_group != None:
3274 self.out_group = out_group
3275 else:
3276 self.out_group = 0
3277 if flags != None:
3278 self.flags = flags
3279 else:
3280 self.flags = 0
3281 if match != None:
3282 self.match = match
3283 else:
3284 self.match = common.match()
3285 if instructions != None:
3286 self.instructions = instructions
3287 else:
3288 self.instructions = []
Rich Lane7dcdf022013-12-11 14:45:27 -08003289 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003290
3291 def pack(self):
3292 packed = []
3293 packed.append(struct.pack("!B", self.version))
3294 packed.append(struct.pack("!B", self.type))
3295 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3296 packed.append(struct.pack("!L", self.xid))
3297 packed.append(struct.pack("!Q", self.cookie))
3298 packed.append(struct.pack("!Q", self.cookie_mask))
3299 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003300 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003301 packed.append(struct.pack("!H", self.idle_timeout))
3302 packed.append(struct.pack("!H", self.hard_timeout))
3303 packed.append(struct.pack("!H", self.priority))
3304 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003305 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003306 packed.append(struct.pack("!L", self.out_group))
3307 packed.append(struct.pack("!H", self.flags))
3308 packed.append('\x00' * 2)
3309 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08003310 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003311 length = sum([len(x) for x in packed])
3312 packed[2] = struct.pack("!H", length)
3313 return ''.join(packed)
3314
3315 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003316 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003317 obj = flow_delete()
Dan Talaycof6202252013-07-02 01:00:29 -07003318 _version = reader.read("!B")[0]
3319 assert(_version == 2)
3320 _type = reader.read("!B")[0]
3321 assert(_type == 14)
3322 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003323 orig_reader = reader
3324 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003325 obj.xid = reader.read("!L")[0]
3326 obj.cookie = reader.read("!Q")[0]
3327 obj.cookie_mask = reader.read("!Q")[0]
3328 obj.table_id = reader.read("!B")[0]
3329 __command = util.unpack_fm_cmd(reader)
3330 assert(__command == 3)
3331 obj.idle_timeout = reader.read("!H")[0]
3332 obj.hard_timeout = reader.read("!H")[0]
3333 obj.priority = reader.read("!H")[0]
3334 obj.buffer_id = reader.read("!L")[0]
3335 obj.out_port = util.unpack_port_no(reader)
3336 obj.out_group = reader.read("!L")[0]
3337 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003338 reader.skip(2)
3339 obj.match = common.match.unpack(reader)
Rich Lane7dcdf022013-12-11 14:45:27 -08003340 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003341 return obj
3342
3343 def __eq__(self, other):
3344 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003345 if self.xid != other.xid: return False
3346 if self.cookie != other.cookie: return False
3347 if self.cookie_mask != other.cookie_mask: return False
3348 if self.table_id != other.table_id: return False
3349 if self.idle_timeout != other.idle_timeout: return False
3350 if self.hard_timeout != other.hard_timeout: return False
3351 if self.priority != other.priority: return False
3352 if self.buffer_id != other.buffer_id: return False
3353 if self.out_port != other.out_port: return False
3354 if self.out_group != other.out_group: return False
3355 if self.flags != other.flags: return False
3356 if self.match != other.match: return False
3357 if self.instructions != other.instructions: return False
3358 return True
3359
Rich Lanec2ee4b82013-04-24 17:12:38 -07003360 def pretty_print(self, q):
3361 q.text("flow_delete {")
3362 with q.group():
3363 with q.indent(2):
3364 q.breakable()
3365 q.text("xid = ");
3366 if self.xid != None:
3367 q.text("%#x" % self.xid)
3368 else:
3369 q.text('None')
3370 q.text(","); q.breakable()
3371 q.text("cookie = ");
3372 q.text("%#x" % self.cookie)
3373 q.text(","); q.breakable()
3374 q.text("cookie_mask = ");
3375 q.text("%#x" % self.cookie_mask)
3376 q.text(","); q.breakable()
3377 q.text("table_id = ");
3378 q.text("%#x" % self.table_id)
3379 q.text(","); q.breakable()
3380 q.text("idle_timeout = ");
3381 q.text("%#x" % self.idle_timeout)
3382 q.text(","); q.breakable()
3383 q.text("hard_timeout = ");
3384 q.text("%#x" % self.hard_timeout)
3385 q.text(","); q.breakable()
3386 q.text("priority = ");
3387 q.text("%#x" % self.priority)
3388 q.text(","); q.breakable()
3389 q.text("buffer_id = ");
3390 q.text("%#x" % self.buffer_id)
3391 q.text(","); q.breakable()
3392 q.text("out_port = ");
3393 q.text(util.pretty_port(self.out_port))
3394 q.text(","); q.breakable()
3395 q.text("out_group = ");
3396 q.text("%#x" % self.out_group)
3397 q.text(","); q.breakable()
3398 q.text("flags = ");
3399 q.text("%#x" % self.flags)
3400 q.text(","); q.breakable()
3401 q.text("match = ");
3402 q.pp(self.match)
3403 q.text(","); q.breakable()
3404 q.text("instructions = ");
3405 q.pp(self.instructions)
3406 q.breakable()
3407 q.text('}')
3408
Rich Lane7dcdf022013-12-11 14:45:27 -08003409flow_mod.subtypes[3] = flow_delete
3410
3411class flow_delete_strict(flow_mod):
Dan Talaycof6202252013-07-02 01:00:29 -07003412 version = 2
3413 type = 14
3414 _command = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07003415
3416 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 -08003417 if xid != None:
3418 self.xid = xid
3419 else:
3420 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003421 if cookie != None:
3422 self.cookie = cookie
3423 else:
3424 self.cookie = 0
3425 if cookie_mask != None:
3426 self.cookie_mask = cookie_mask
3427 else:
3428 self.cookie_mask = 0
3429 if table_id != None:
3430 self.table_id = table_id
3431 else:
3432 self.table_id = 0
3433 if idle_timeout != None:
3434 self.idle_timeout = idle_timeout
3435 else:
3436 self.idle_timeout = 0
3437 if hard_timeout != None:
3438 self.hard_timeout = hard_timeout
3439 else:
3440 self.hard_timeout = 0
3441 if priority != None:
3442 self.priority = priority
3443 else:
3444 self.priority = 0
3445 if buffer_id != None:
3446 self.buffer_id = buffer_id
3447 else:
3448 self.buffer_id = 0
3449 if out_port != None:
3450 self.out_port = out_port
3451 else:
3452 self.out_port = 0
3453 if out_group != None:
3454 self.out_group = out_group
3455 else:
3456 self.out_group = 0
3457 if flags != None:
3458 self.flags = flags
3459 else:
3460 self.flags = 0
3461 if match != None:
3462 self.match = match
3463 else:
3464 self.match = common.match()
3465 if instructions != None:
3466 self.instructions = instructions
3467 else:
3468 self.instructions = []
Rich Lane7dcdf022013-12-11 14:45:27 -08003469 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003470
3471 def pack(self):
3472 packed = []
3473 packed.append(struct.pack("!B", self.version))
3474 packed.append(struct.pack("!B", self.type))
3475 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3476 packed.append(struct.pack("!L", self.xid))
3477 packed.append(struct.pack("!Q", self.cookie))
3478 packed.append(struct.pack("!Q", self.cookie_mask))
3479 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003480 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003481 packed.append(struct.pack("!H", self.idle_timeout))
3482 packed.append(struct.pack("!H", self.hard_timeout))
3483 packed.append(struct.pack("!H", self.priority))
3484 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003485 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003486 packed.append(struct.pack("!L", self.out_group))
3487 packed.append(struct.pack("!H", self.flags))
3488 packed.append('\x00' * 2)
3489 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08003490 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003491 length = sum([len(x) for x in packed])
3492 packed[2] = struct.pack("!H", length)
3493 return ''.join(packed)
3494
3495 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003496 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003497 obj = flow_delete_strict()
Dan Talaycof6202252013-07-02 01:00:29 -07003498 _version = reader.read("!B")[0]
3499 assert(_version == 2)
3500 _type = reader.read("!B")[0]
3501 assert(_type == 14)
3502 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003503 orig_reader = reader
3504 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003505 obj.xid = reader.read("!L")[0]
3506 obj.cookie = reader.read("!Q")[0]
3507 obj.cookie_mask = reader.read("!Q")[0]
3508 obj.table_id = reader.read("!B")[0]
3509 __command = util.unpack_fm_cmd(reader)
3510 assert(__command == 4)
3511 obj.idle_timeout = reader.read("!H")[0]
3512 obj.hard_timeout = reader.read("!H")[0]
3513 obj.priority = reader.read("!H")[0]
3514 obj.buffer_id = reader.read("!L")[0]
3515 obj.out_port = util.unpack_port_no(reader)
3516 obj.out_group = reader.read("!L")[0]
3517 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003518 reader.skip(2)
3519 obj.match = common.match.unpack(reader)
Rich Lane7dcdf022013-12-11 14:45:27 -08003520 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003521 return obj
3522
3523 def __eq__(self, other):
3524 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003525 if self.xid != other.xid: return False
3526 if self.cookie != other.cookie: return False
3527 if self.cookie_mask != other.cookie_mask: return False
3528 if self.table_id != other.table_id: return False
3529 if self.idle_timeout != other.idle_timeout: return False
3530 if self.hard_timeout != other.hard_timeout: return False
3531 if self.priority != other.priority: return False
3532 if self.buffer_id != other.buffer_id: return False
3533 if self.out_port != other.out_port: return False
3534 if self.out_group != other.out_group: return False
3535 if self.flags != other.flags: return False
3536 if self.match != other.match: return False
3537 if self.instructions != other.instructions: return False
3538 return True
3539
Rich Lanec2ee4b82013-04-24 17:12:38 -07003540 def pretty_print(self, q):
3541 q.text("flow_delete_strict {")
3542 with q.group():
3543 with q.indent(2):
3544 q.breakable()
3545 q.text("xid = ");
3546 if self.xid != None:
3547 q.text("%#x" % self.xid)
3548 else:
3549 q.text('None')
3550 q.text(","); q.breakable()
3551 q.text("cookie = ");
3552 q.text("%#x" % self.cookie)
3553 q.text(","); q.breakable()
3554 q.text("cookie_mask = ");
3555 q.text("%#x" % self.cookie_mask)
3556 q.text(","); q.breakable()
3557 q.text("table_id = ");
3558 q.text("%#x" % self.table_id)
3559 q.text(","); q.breakable()
3560 q.text("idle_timeout = ");
3561 q.text("%#x" % self.idle_timeout)
3562 q.text(","); q.breakable()
3563 q.text("hard_timeout = ");
3564 q.text("%#x" % self.hard_timeout)
3565 q.text(","); q.breakable()
3566 q.text("priority = ");
3567 q.text("%#x" % self.priority)
3568 q.text(","); q.breakable()
3569 q.text("buffer_id = ");
3570 q.text("%#x" % self.buffer_id)
3571 q.text(","); q.breakable()
3572 q.text("out_port = ");
3573 q.text(util.pretty_port(self.out_port))
3574 q.text(","); q.breakable()
3575 q.text("out_group = ");
3576 q.text("%#x" % self.out_group)
3577 q.text(","); q.breakable()
3578 q.text("flags = ");
3579 q.text("%#x" % self.flags)
3580 q.text(","); q.breakable()
3581 q.text("match = ");
3582 q.pp(self.match)
3583 q.text(","); q.breakable()
3584 q.text("instructions = ");
3585 q.pp(self.instructions)
3586 q.breakable()
3587 q.text('}')
3588
Rich Lane7dcdf022013-12-11 14:45:27 -08003589flow_mod.subtypes[4] = flow_delete_strict
3590
3591class flow_mod_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07003592 version = 2
3593 type = 1
3594 err_type = 5
3595
3596 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003597 if xid != None:
3598 self.xid = xid
3599 else:
3600 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07003601 if code != None:
3602 self.code = code
3603 else:
3604 self.code = 0
3605 if data != None:
3606 self.data = data
3607 else:
3608 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08003609 return
Rich Lane6f4978c2013-10-20 21:33:52 -07003610
3611 def pack(self):
3612 packed = []
3613 packed.append(struct.pack("!B", self.version))
3614 packed.append(struct.pack("!B", self.type))
3615 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3616 packed.append(struct.pack("!L", self.xid))
3617 packed.append(struct.pack("!H", self.err_type))
3618 packed.append(struct.pack("!H", self.code))
3619 packed.append(self.data)
3620 length = sum([len(x) for x in packed])
3621 packed[2] = struct.pack("!H", length)
3622 return ''.join(packed)
3623
3624 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003625 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07003626 obj = flow_mod_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07003627 _version = reader.read("!B")[0]
3628 assert(_version == 2)
3629 _type = reader.read("!B")[0]
3630 assert(_type == 1)
3631 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003632 orig_reader = reader
3633 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07003634 obj.xid = reader.read("!L")[0]
3635 _err_type = reader.read("!H")[0]
3636 assert(_err_type == 5)
3637 obj.code = reader.read("!H")[0]
3638 obj.data = str(reader.read_all())
3639 return obj
3640
3641 def __eq__(self, other):
3642 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07003643 if self.xid != other.xid: return False
3644 if self.code != other.code: return False
3645 if self.data != other.data: return False
3646 return True
3647
Rich Lane6f4978c2013-10-20 21:33:52 -07003648 def pretty_print(self, q):
3649 q.text("flow_mod_failed_error_msg {")
3650 with q.group():
3651 with q.indent(2):
3652 q.breakable()
3653 q.text("xid = ");
3654 if self.xid != None:
3655 q.text("%#x" % self.xid)
3656 else:
3657 q.text('None')
3658 q.text(","); q.breakable()
3659 q.text("code = ");
3660 q.text("%#x" % self.code)
3661 q.text(","); q.breakable()
3662 q.text("data = ");
3663 q.pp(self.data)
3664 q.breakable()
3665 q.text('}')
3666
Rich Lane7dcdf022013-12-11 14:45:27 -08003667error_msg.subtypes[5] = flow_mod_failed_error_msg
3668
3669class flow_modify(flow_mod):
Dan Talaycof6202252013-07-02 01:00:29 -07003670 version = 2
3671 type = 14
3672 _command = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07003673
3674 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 -08003675 if xid != None:
3676 self.xid = xid
3677 else:
3678 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003679 if cookie != None:
3680 self.cookie = cookie
3681 else:
3682 self.cookie = 0
3683 if cookie_mask != None:
3684 self.cookie_mask = cookie_mask
3685 else:
3686 self.cookie_mask = 0
3687 if table_id != None:
3688 self.table_id = table_id
3689 else:
3690 self.table_id = 0
3691 if idle_timeout != None:
3692 self.idle_timeout = idle_timeout
3693 else:
3694 self.idle_timeout = 0
3695 if hard_timeout != None:
3696 self.hard_timeout = hard_timeout
3697 else:
3698 self.hard_timeout = 0
3699 if priority != None:
3700 self.priority = priority
3701 else:
3702 self.priority = 0
3703 if buffer_id != None:
3704 self.buffer_id = buffer_id
3705 else:
3706 self.buffer_id = 0
3707 if out_port != None:
3708 self.out_port = out_port
3709 else:
3710 self.out_port = 0
3711 if out_group != None:
3712 self.out_group = out_group
3713 else:
3714 self.out_group = 0
3715 if flags != None:
3716 self.flags = flags
3717 else:
3718 self.flags = 0
3719 if match != None:
3720 self.match = match
3721 else:
3722 self.match = common.match()
3723 if instructions != None:
3724 self.instructions = instructions
3725 else:
3726 self.instructions = []
Rich Lane7dcdf022013-12-11 14:45:27 -08003727 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003728
3729 def pack(self):
3730 packed = []
3731 packed.append(struct.pack("!B", self.version))
3732 packed.append(struct.pack("!B", self.type))
3733 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3734 packed.append(struct.pack("!L", self.xid))
3735 packed.append(struct.pack("!Q", self.cookie))
3736 packed.append(struct.pack("!Q", self.cookie_mask))
3737 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003738 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003739 packed.append(struct.pack("!H", self.idle_timeout))
3740 packed.append(struct.pack("!H", self.hard_timeout))
3741 packed.append(struct.pack("!H", self.priority))
3742 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003743 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003744 packed.append(struct.pack("!L", self.out_group))
3745 packed.append(struct.pack("!H", self.flags))
3746 packed.append('\x00' * 2)
3747 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08003748 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003749 length = sum([len(x) for x in packed])
3750 packed[2] = struct.pack("!H", length)
3751 return ''.join(packed)
3752
3753 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003754 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003755 obj = flow_modify()
Dan Talaycof6202252013-07-02 01:00:29 -07003756 _version = reader.read("!B")[0]
3757 assert(_version == 2)
3758 _type = reader.read("!B")[0]
3759 assert(_type == 14)
3760 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003761 orig_reader = reader
3762 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003763 obj.xid = reader.read("!L")[0]
3764 obj.cookie = reader.read("!Q")[0]
3765 obj.cookie_mask = reader.read("!Q")[0]
3766 obj.table_id = reader.read("!B")[0]
3767 __command = util.unpack_fm_cmd(reader)
3768 assert(__command == 1)
3769 obj.idle_timeout = reader.read("!H")[0]
3770 obj.hard_timeout = reader.read("!H")[0]
3771 obj.priority = reader.read("!H")[0]
3772 obj.buffer_id = reader.read("!L")[0]
3773 obj.out_port = util.unpack_port_no(reader)
3774 obj.out_group = reader.read("!L")[0]
3775 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003776 reader.skip(2)
3777 obj.match = common.match.unpack(reader)
Rich Lane7dcdf022013-12-11 14:45:27 -08003778 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003779 return obj
3780
3781 def __eq__(self, other):
3782 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003783 if self.xid != other.xid: return False
3784 if self.cookie != other.cookie: return False
3785 if self.cookie_mask != other.cookie_mask: return False
3786 if self.table_id != other.table_id: return False
3787 if self.idle_timeout != other.idle_timeout: return False
3788 if self.hard_timeout != other.hard_timeout: return False
3789 if self.priority != other.priority: return False
3790 if self.buffer_id != other.buffer_id: return False
3791 if self.out_port != other.out_port: return False
3792 if self.out_group != other.out_group: return False
3793 if self.flags != other.flags: return False
3794 if self.match != other.match: return False
3795 if self.instructions != other.instructions: return False
3796 return True
3797
Rich Lanec2ee4b82013-04-24 17:12:38 -07003798 def pretty_print(self, q):
3799 q.text("flow_modify {")
3800 with q.group():
3801 with q.indent(2):
3802 q.breakable()
3803 q.text("xid = ");
3804 if self.xid != None:
3805 q.text("%#x" % self.xid)
3806 else:
3807 q.text('None')
3808 q.text(","); q.breakable()
3809 q.text("cookie = ");
3810 q.text("%#x" % self.cookie)
3811 q.text(","); q.breakable()
3812 q.text("cookie_mask = ");
3813 q.text("%#x" % self.cookie_mask)
3814 q.text(","); q.breakable()
3815 q.text("table_id = ");
3816 q.text("%#x" % self.table_id)
3817 q.text(","); q.breakable()
3818 q.text("idle_timeout = ");
3819 q.text("%#x" % self.idle_timeout)
3820 q.text(","); q.breakable()
3821 q.text("hard_timeout = ");
3822 q.text("%#x" % self.hard_timeout)
3823 q.text(","); q.breakable()
3824 q.text("priority = ");
3825 q.text("%#x" % self.priority)
3826 q.text(","); q.breakable()
3827 q.text("buffer_id = ");
3828 q.text("%#x" % self.buffer_id)
3829 q.text(","); q.breakable()
3830 q.text("out_port = ");
3831 q.text(util.pretty_port(self.out_port))
3832 q.text(","); q.breakable()
3833 q.text("out_group = ");
3834 q.text("%#x" % self.out_group)
3835 q.text(","); q.breakable()
3836 q.text("flags = ");
3837 q.text("%#x" % self.flags)
3838 q.text(","); q.breakable()
3839 q.text("match = ");
3840 q.pp(self.match)
3841 q.text(","); q.breakable()
3842 q.text("instructions = ");
3843 q.pp(self.instructions)
3844 q.breakable()
3845 q.text('}')
3846
Rich Lane7dcdf022013-12-11 14:45:27 -08003847flow_mod.subtypes[1] = flow_modify
3848
3849class flow_modify_strict(flow_mod):
Dan Talaycof6202252013-07-02 01:00:29 -07003850 version = 2
3851 type = 14
3852 _command = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07003853
3854 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 -08003855 if xid != None:
3856 self.xid = xid
3857 else:
3858 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003859 if cookie != None:
3860 self.cookie = cookie
3861 else:
3862 self.cookie = 0
3863 if cookie_mask != None:
3864 self.cookie_mask = cookie_mask
3865 else:
3866 self.cookie_mask = 0
3867 if table_id != None:
3868 self.table_id = table_id
3869 else:
3870 self.table_id = 0
3871 if idle_timeout != None:
3872 self.idle_timeout = idle_timeout
3873 else:
3874 self.idle_timeout = 0
3875 if hard_timeout != None:
3876 self.hard_timeout = hard_timeout
3877 else:
3878 self.hard_timeout = 0
3879 if priority != None:
3880 self.priority = priority
3881 else:
3882 self.priority = 0
3883 if buffer_id != None:
3884 self.buffer_id = buffer_id
3885 else:
3886 self.buffer_id = 0
3887 if out_port != None:
3888 self.out_port = out_port
3889 else:
3890 self.out_port = 0
3891 if out_group != None:
3892 self.out_group = out_group
3893 else:
3894 self.out_group = 0
3895 if flags != None:
3896 self.flags = flags
3897 else:
3898 self.flags = 0
3899 if match != None:
3900 self.match = match
3901 else:
3902 self.match = common.match()
3903 if instructions != None:
3904 self.instructions = instructions
3905 else:
3906 self.instructions = []
Rich Lane7dcdf022013-12-11 14:45:27 -08003907 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003908
3909 def pack(self):
3910 packed = []
3911 packed.append(struct.pack("!B", self.version))
3912 packed.append(struct.pack("!B", self.type))
3913 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3914 packed.append(struct.pack("!L", self.xid))
3915 packed.append(struct.pack("!Q", self.cookie))
3916 packed.append(struct.pack("!Q", self.cookie_mask))
3917 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003918 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003919 packed.append(struct.pack("!H", self.idle_timeout))
3920 packed.append(struct.pack("!H", self.hard_timeout))
3921 packed.append(struct.pack("!H", self.priority))
3922 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003923 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003924 packed.append(struct.pack("!L", self.out_group))
3925 packed.append(struct.pack("!H", self.flags))
3926 packed.append('\x00' * 2)
3927 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08003928 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003929 length = sum([len(x) for x in packed])
3930 packed[2] = struct.pack("!H", length)
3931 return ''.join(packed)
3932
3933 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003934 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003935 obj = flow_modify_strict()
Dan Talaycof6202252013-07-02 01:00:29 -07003936 _version = reader.read("!B")[0]
3937 assert(_version == 2)
3938 _type = reader.read("!B")[0]
3939 assert(_type == 14)
3940 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003941 orig_reader = reader
3942 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003943 obj.xid = reader.read("!L")[0]
3944 obj.cookie = reader.read("!Q")[0]
3945 obj.cookie_mask = reader.read("!Q")[0]
3946 obj.table_id = reader.read("!B")[0]
3947 __command = util.unpack_fm_cmd(reader)
3948 assert(__command == 2)
3949 obj.idle_timeout = reader.read("!H")[0]
3950 obj.hard_timeout = reader.read("!H")[0]
3951 obj.priority = reader.read("!H")[0]
3952 obj.buffer_id = reader.read("!L")[0]
3953 obj.out_port = util.unpack_port_no(reader)
3954 obj.out_group = reader.read("!L")[0]
3955 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003956 reader.skip(2)
3957 obj.match = common.match.unpack(reader)
Rich Lane7dcdf022013-12-11 14:45:27 -08003958 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003959 return obj
3960
3961 def __eq__(self, other):
3962 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003963 if self.xid != other.xid: return False
3964 if self.cookie != other.cookie: return False
3965 if self.cookie_mask != other.cookie_mask: return False
3966 if self.table_id != other.table_id: return False
3967 if self.idle_timeout != other.idle_timeout: return False
3968 if self.hard_timeout != other.hard_timeout: return False
3969 if self.priority != other.priority: return False
3970 if self.buffer_id != other.buffer_id: return False
3971 if self.out_port != other.out_port: return False
3972 if self.out_group != other.out_group: return False
3973 if self.flags != other.flags: return False
3974 if self.match != other.match: return False
3975 if self.instructions != other.instructions: return False
3976 return True
3977
Rich Lanec2ee4b82013-04-24 17:12:38 -07003978 def pretty_print(self, q):
3979 q.text("flow_modify_strict {")
3980 with q.group():
3981 with q.indent(2):
3982 q.breakable()
3983 q.text("xid = ");
3984 if self.xid != None:
3985 q.text("%#x" % self.xid)
3986 else:
3987 q.text('None')
3988 q.text(","); q.breakable()
3989 q.text("cookie = ");
3990 q.text("%#x" % self.cookie)
3991 q.text(","); q.breakable()
3992 q.text("cookie_mask = ");
3993 q.text("%#x" % self.cookie_mask)
3994 q.text(","); q.breakable()
3995 q.text("table_id = ");
3996 q.text("%#x" % self.table_id)
3997 q.text(","); q.breakable()
3998 q.text("idle_timeout = ");
3999 q.text("%#x" % self.idle_timeout)
4000 q.text(","); q.breakable()
4001 q.text("hard_timeout = ");
4002 q.text("%#x" % self.hard_timeout)
4003 q.text(","); q.breakable()
4004 q.text("priority = ");
4005 q.text("%#x" % self.priority)
4006 q.text(","); q.breakable()
4007 q.text("buffer_id = ");
4008 q.text("%#x" % self.buffer_id)
4009 q.text(","); q.breakable()
4010 q.text("out_port = ");
4011 q.text(util.pretty_port(self.out_port))
4012 q.text(","); q.breakable()
4013 q.text("out_group = ");
4014 q.text("%#x" % self.out_group)
4015 q.text(","); q.breakable()
4016 q.text("flags = ");
4017 q.text("%#x" % self.flags)
4018 q.text(","); q.breakable()
4019 q.text("match = ");
4020 q.pp(self.match)
4021 q.text(","); q.breakable()
4022 q.text("instructions = ");
4023 q.pp(self.instructions)
4024 q.breakable()
4025 q.text('}')
4026
Rich Lane7dcdf022013-12-11 14:45:27 -08004027flow_mod.subtypes[2] = flow_modify_strict
4028
4029class flow_removed(message):
Dan Talaycof6202252013-07-02 01:00:29 -07004030 version = 2
4031 type = 11
Rich Lanec2ee4b82013-04-24 17:12:38 -07004032
4033 def __init__(self, xid=None, cookie=None, priority=None, reason=None, table_id=None, duration_sec=None, duration_nsec=None, idle_timeout=None, packet_count=None, byte_count=None, match=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08004034 if xid != None:
4035 self.xid = xid
4036 else:
4037 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004038 if cookie != None:
4039 self.cookie = cookie
4040 else:
4041 self.cookie = 0
4042 if priority != None:
4043 self.priority = priority
4044 else:
4045 self.priority = 0
4046 if reason != None:
4047 self.reason = reason
4048 else:
4049 self.reason = 0
4050 if table_id != None:
4051 self.table_id = table_id
4052 else:
4053 self.table_id = 0
4054 if duration_sec != None:
4055 self.duration_sec = duration_sec
4056 else:
4057 self.duration_sec = 0
4058 if duration_nsec != None:
4059 self.duration_nsec = duration_nsec
4060 else:
4061 self.duration_nsec = 0
4062 if idle_timeout != None:
4063 self.idle_timeout = idle_timeout
4064 else:
4065 self.idle_timeout = 0
4066 if packet_count != None:
4067 self.packet_count = packet_count
4068 else:
4069 self.packet_count = 0
4070 if byte_count != None:
4071 self.byte_count = byte_count
4072 else:
4073 self.byte_count = 0
4074 if match != None:
4075 self.match = match
4076 else:
4077 self.match = common.match()
Rich Lane7dcdf022013-12-11 14:45:27 -08004078 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004079
4080 def pack(self):
4081 packed = []
4082 packed.append(struct.pack("!B", self.version))
4083 packed.append(struct.pack("!B", self.type))
4084 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4085 packed.append(struct.pack("!L", self.xid))
4086 packed.append(struct.pack("!Q", self.cookie))
4087 packed.append(struct.pack("!H", self.priority))
4088 packed.append(struct.pack("!B", self.reason))
4089 packed.append(struct.pack("!B", self.table_id))
4090 packed.append(struct.pack("!L", self.duration_sec))
4091 packed.append(struct.pack("!L", self.duration_nsec))
4092 packed.append(struct.pack("!H", self.idle_timeout))
4093 packed.append('\x00' * 2)
4094 packed.append(struct.pack("!Q", self.packet_count))
4095 packed.append(struct.pack("!Q", self.byte_count))
4096 packed.append(self.match.pack())
4097 length = sum([len(x) for x in packed])
4098 packed[2] = struct.pack("!H", length)
4099 return ''.join(packed)
4100
4101 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004102 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004103 obj = flow_removed()
Dan Talaycof6202252013-07-02 01:00:29 -07004104 _version = reader.read("!B")[0]
4105 assert(_version == 2)
4106 _type = reader.read("!B")[0]
4107 assert(_type == 11)
4108 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004109 orig_reader = reader
4110 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07004111 obj.xid = reader.read("!L")[0]
4112 obj.cookie = reader.read("!Q")[0]
4113 obj.priority = reader.read("!H")[0]
4114 obj.reason = reader.read("!B")[0]
4115 obj.table_id = reader.read("!B")[0]
4116 obj.duration_sec = reader.read("!L")[0]
4117 obj.duration_nsec = reader.read("!L")[0]
4118 obj.idle_timeout = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004119 reader.skip(2)
Dan Talaycof6202252013-07-02 01:00:29 -07004120 obj.packet_count = reader.read("!Q")[0]
4121 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004122 obj.match = common.match.unpack(reader)
4123 return obj
4124
4125 def __eq__(self, other):
4126 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004127 if self.xid != other.xid: return False
4128 if self.cookie != other.cookie: return False
4129 if self.priority != other.priority: return False
4130 if self.reason != other.reason: return False
4131 if self.table_id != other.table_id: return False
4132 if self.duration_sec != other.duration_sec: return False
4133 if self.duration_nsec != other.duration_nsec: return False
4134 if self.idle_timeout != other.idle_timeout: return False
4135 if self.packet_count != other.packet_count: return False
4136 if self.byte_count != other.byte_count: return False
4137 if self.match != other.match: return False
4138 return True
4139
Rich Lanec2ee4b82013-04-24 17:12:38 -07004140 def pretty_print(self, q):
4141 q.text("flow_removed {")
4142 with q.group():
4143 with q.indent(2):
4144 q.breakable()
4145 q.text("xid = ");
4146 if self.xid != None:
4147 q.text("%#x" % self.xid)
4148 else:
4149 q.text('None')
4150 q.text(","); q.breakable()
4151 q.text("cookie = ");
4152 q.text("%#x" % self.cookie)
4153 q.text(","); q.breakable()
4154 q.text("priority = ");
4155 q.text("%#x" % self.priority)
4156 q.text(","); q.breakable()
4157 q.text("reason = ");
4158 q.text("%#x" % self.reason)
4159 q.text(","); q.breakable()
4160 q.text("table_id = ");
4161 q.text("%#x" % self.table_id)
4162 q.text(","); q.breakable()
4163 q.text("duration_sec = ");
4164 q.text("%#x" % self.duration_sec)
4165 q.text(","); q.breakable()
4166 q.text("duration_nsec = ");
4167 q.text("%#x" % self.duration_nsec)
4168 q.text(","); q.breakable()
4169 q.text("idle_timeout = ");
4170 q.text("%#x" % self.idle_timeout)
4171 q.text(","); q.breakable()
4172 q.text("packet_count = ");
4173 q.text("%#x" % self.packet_count)
4174 q.text(","); q.breakable()
4175 q.text("byte_count = ");
4176 q.text("%#x" % self.byte_count)
4177 q.text(","); q.breakable()
4178 q.text("match = ");
4179 q.pp(self.match)
4180 q.breakable()
4181 q.text('}')
4182
Rich Lane7dcdf022013-12-11 14:45:27 -08004183message.subtypes[11] = flow_removed
4184
4185class flow_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07004186 version = 2
4187 type = 19
4188 stats_type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07004189
4190 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08004191 if xid != None:
4192 self.xid = xid
4193 else:
4194 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004195 if flags != None:
4196 self.flags = flags
4197 else:
4198 self.flags = 0
4199 if entries != None:
4200 self.entries = entries
4201 else:
4202 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08004203 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004204
4205 def pack(self):
4206 packed = []
4207 packed.append(struct.pack("!B", self.version))
4208 packed.append(struct.pack("!B", self.type))
4209 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4210 packed.append(struct.pack("!L", self.xid))
4211 packed.append(struct.pack("!H", self.stats_type))
4212 packed.append(struct.pack("!H", self.flags))
4213 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08004214 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004215 length = sum([len(x) for x in packed])
4216 packed[2] = struct.pack("!H", length)
4217 return ''.join(packed)
4218
4219 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004220 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004221 obj = flow_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07004222 _version = reader.read("!B")[0]
4223 assert(_version == 2)
4224 _type = reader.read("!B")[0]
4225 assert(_type == 19)
4226 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004227 orig_reader = reader
4228 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07004229 obj.xid = reader.read("!L")[0]
4230 _stats_type = reader.read("!H")[0]
4231 assert(_stats_type == 1)
4232 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004233 reader.skip(4)
Rich Lane7dcdf022013-12-11 14:45:27 -08004234 obj.entries = loxi.generic_util.unpack_list(reader, common.flow_stats_entry.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07004235 return obj
4236
4237 def __eq__(self, other):
4238 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004239 if self.xid != other.xid: return False
4240 if self.flags != other.flags: return False
4241 if self.entries != other.entries: return False
4242 return True
4243
Rich Lanec2ee4b82013-04-24 17:12:38 -07004244 def pretty_print(self, q):
4245 q.text("flow_stats_reply {")
4246 with q.group():
4247 with q.indent(2):
4248 q.breakable()
4249 q.text("xid = ");
4250 if self.xid != None:
4251 q.text("%#x" % self.xid)
4252 else:
4253 q.text('None')
4254 q.text(","); q.breakable()
4255 q.text("flags = ");
4256 q.text("%#x" % self.flags)
4257 q.text(","); q.breakable()
4258 q.text("entries = ");
4259 q.pp(self.entries)
4260 q.breakable()
4261 q.text('}')
4262
Rich Lane7dcdf022013-12-11 14:45:27 -08004263stats_reply.subtypes[1] = flow_stats_reply
4264
4265class flow_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07004266 version = 2
4267 type = 18
4268 stats_type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07004269
4270 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 -08004271 if xid != None:
4272 self.xid = xid
4273 else:
4274 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004275 if flags != None:
4276 self.flags = flags
4277 else:
4278 self.flags = 0
4279 if table_id != None:
4280 self.table_id = table_id
4281 else:
4282 self.table_id = 0
4283 if out_port != None:
4284 self.out_port = out_port
4285 else:
4286 self.out_port = 0
4287 if out_group != None:
4288 self.out_group = out_group
4289 else:
4290 self.out_group = 0
4291 if cookie != None:
4292 self.cookie = cookie
4293 else:
4294 self.cookie = 0
4295 if cookie_mask != None:
4296 self.cookie_mask = cookie_mask
4297 else:
4298 self.cookie_mask = 0
4299 if match != None:
4300 self.match = match
4301 else:
4302 self.match = common.match()
Rich Lane7dcdf022013-12-11 14:45:27 -08004303 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004304
4305 def pack(self):
4306 packed = []
4307 packed.append(struct.pack("!B", self.version))
4308 packed.append(struct.pack("!B", self.type))
4309 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4310 packed.append(struct.pack("!L", self.xid))
4311 packed.append(struct.pack("!H", self.stats_type))
4312 packed.append(struct.pack("!H", self.flags))
4313 packed.append('\x00' * 4)
4314 packed.append(struct.pack("!B", self.table_id))
4315 packed.append('\x00' * 3)
Dan Talaycof6202252013-07-02 01:00:29 -07004316 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004317 packed.append(struct.pack("!L", self.out_group))
4318 packed.append('\x00' * 4)
4319 packed.append(struct.pack("!Q", self.cookie))
4320 packed.append(struct.pack("!Q", self.cookie_mask))
4321 packed.append(self.match.pack())
4322 length = sum([len(x) for x in packed])
4323 packed[2] = struct.pack("!H", length)
4324 return ''.join(packed)
4325
4326 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004327 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004328 obj = flow_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07004329 _version = reader.read("!B")[0]
4330 assert(_version == 2)
4331 _type = reader.read("!B")[0]
4332 assert(_type == 18)
4333 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004334 orig_reader = reader
4335 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07004336 obj.xid = reader.read("!L")[0]
4337 _stats_type = reader.read("!H")[0]
4338 assert(_stats_type == 1)
4339 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004340 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07004341 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004342 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07004343 obj.out_port = util.unpack_port_no(reader)
4344 obj.out_group = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004345 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07004346 obj.cookie = reader.read("!Q")[0]
4347 obj.cookie_mask = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004348 obj.match = common.match.unpack(reader)
4349 return obj
4350
4351 def __eq__(self, other):
4352 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004353 if self.xid != other.xid: return False
4354 if self.flags != other.flags: return False
4355 if self.table_id != other.table_id: return False
4356 if self.out_port != other.out_port: return False
4357 if self.out_group != other.out_group: return False
4358 if self.cookie != other.cookie: return False
4359 if self.cookie_mask != other.cookie_mask: return False
4360 if self.match != other.match: return False
4361 return True
4362
Rich Lanec2ee4b82013-04-24 17:12:38 -07004363 def pretty_print(self, q):
4364 q.text("flow_stats_request {")
4365 with q.group():
4366 with q.indent(2):
4367 q.breakable()
4368 q.text("xid = ");
4369 if self.xid != None:
4370 q.text("%#x" % self.xid)
4371 else:
4372 q.text('None')
4373 q.text(","); q.breakable()
4374 q.text("flags = ");
4375 q.text("%#x" % self.flags)
4376 q.text(","); q.breakable()
4377 q.text("table_id = ");
4378 q.text("%#x" % self.table_id)
4379 q.text(","); q.breakable()
4380 q.text("out_port = ");
4381 q.text(util.pretty_port(self.out_port))
4382 q.text(","); q.breakable()
4383 q.text("out_group = ");
4384 q.text("%#x" % self.out_group)
4385 q.text(","); q.breakable()
4386 q.text("cookie = ");
4387 q.text("%#x" % self.cookie)
4388 q.text(","); q.breakable()
4389 q.text("cookie_mask = ");
4390 q.text("%#x" % self.cookie_mask)
4391 q.text(","); q.breakable()
4392 q.text("match = ");
4393 q.pp(self.match)
4394 q.breakable()
4395 q.text('}')
4396
Rich Lane7dcdf022013-12-11 14:45:27 -08004397stats_request.subtypes[1] = flow_stats_request
4398
4399class get_config_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -07004400 version = 2
4401 type = 8
Rich Lanec2ee4b82013-04-24 17:12:38 -07004402
4403 def __init__(self, xid=None, flags=None, miss_send_len=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08004404 if xid != None:
4405 self.xid = xid
4406 else:
4407 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004408 if flags != None:
4409 self.flags = flags
4410 else:
4411 self.flags = 0
4412 if miss_send_len != None:
4413 self.miss_send_len = miss_send_len
4414 else:
4415 self.miss_send_len = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08004416 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004417
4418 def pack(self):
4419 packed = []
4420 packed.append(struct.pack("!B", self.version))
4421 packed.append(struct.pack("!B", self.type))
4422 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4423 packed.append(struct.pack("!L", self.xid))
4424 packed.append(struct.pack("!H", self.flags))
4425 packed.append(struct.pack("!H", self.miss_send_len))
4426 length = sum([len(x) for x in packed])
4427 packed[2] = struct.pack("!H", length)
4428 return ''.join(packed)
4429
4430 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004431 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004432 obj = get_config_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07004433 _version = reader.read("!B")[0]
4434 assert(_version == 2)
4435 _type = reader.read("!B")[0]
4436 assert(_type == 8)
4437 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004438 orig_reader = reader
4439 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07004440 obj.xid = reader.read("!L")[0]
4441 obj.flags = reader.read("!H")[0]
4442 obj.miss_send_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004443 return obj
4444
4445 def __eq__(self, other):
4446 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004447 if self.xid != other.xid: return False
4448 if self.flags != other.flags: return False
4449 if self.miss_send_len != other.miss_send_len: return False
4450 return True
4451
Rich Lanec2ee4b82013-04-24 17:12:38 -07004452 def pretty_print(self, q):
4453 q.text("get_config_reply {")
4454 with q.group():
4455 with q.indent(2):
4456 q.breakable()
4457 q.text("xid = ");
4458 if self.xid != None:
4459 q.text("%#x" % self.xid)
4460 else:
4461 q.text('None')
4462 q.text(","); q.breakable()
4463 q.text("flags = ");
4464 q.text("%#x" % self.flags)
4465 q.text(","); q.breakable()
4466 q.text("miss_send_len = ");
4467 q.text("%#x" % self.miss_send_len)
4468 q.breakable()
4469 q.text('}')
4470
Rich Lane7dcdf022013-12-11 14:45:27 -08004471message.subtypes[8] = get_config_reply
4472
4473class get_config_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -07004474 version = 2
4475 type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07004476
4477 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08004478 if xid != None:
4479 self.xid = xid
4480 else:
4481 self.xid = None
4482 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004483
4484 def pack(self):
4485 packed = []
4486 packed.append(struct.pack("!B", self.version))
4487 packed.append(struct.pack("!B", self.type))
4488 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4489 packed.append(struct.pack("!L", self.xid))
4490 length = sum([len(x) for x in packed])
4491 packed[2] = struct.pack("!H", length)
4492 return ''.join(packed)
4493
4494 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004495 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004496 obj = get_config_request()
Dan Talaycof6202252013-07-02 01:00:29 -07004497 _version = reader.read("!B")[0]
4498 assert(_version == 2)
4499 _type = reader.read("!B")[0]
4500 assert(_type == 7)
4501 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004502 orig_reader = reader
4503 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07004504 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004505 return obj
4506
4507 def __eq__(self, other):
4508 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004509 if self.xid != other.xid: return False
4510 return True
4511
Rich Lanec2ee4b82013-04-24 17:12:38 -07004512 def pretty_print(self, q):
4513 q.text("get_config_request {")
4514 with q.group():
4515 with q.indent(2):
4516 q.breakable()
4517 q.text("xid = ");
4518 if self.xid != None:
4519 q.text("%#x" % self.xid)
4520 else:
4521 q.text('None')
4522 q.breakable()
4523 q.text('}')
4524
Rich Lane7dcdf022013-12-11 14:45:27 -08004525message.subtypes[7] = get_config_request
4526
4527class group_mod(message):
4528 subtypes = {}
4529
4530 @staticmethod
4531 def unpack(reader):
4532 subtype, = reader.peek('!H', 8)
4533 try:
4534 subclass = group_mod.subtypes[subtype]
4535 except KeyError:
4536 raise loxi.ProtocolError("unknown group_mod message subtype %#x" % subtype)
4537 return subclass.unpack(reader)
4538
4539message.subtypes[15] = group_mod
4540
4541class group_add(group_mod):
Rich Lane7b0f2012013-11-22 14:15:26 -08004542 version = 2
4543 type = 15
4544 command = 0
4545
4546 def __init__(self, xid=None, group_type=None, group_id=None, buckets=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08004547 if xid != None:
4548 self.xid = xid
4549 else:
4550 self.xid = None
Rich Lane7b0f2012013-11-22 14:15:26 -08004551 if group_type != None:
4552 self.group_type = group_type
4553 else:
4554 self.group_type = 0
4555 if group_id != None:
4556 self.group_id = group_id
4557 else:
4558 self.group_id = 0
4559 if buckets != None:
4560 self.buckets = buckets
4561 else:
4562 self.buckets = []
Rich Lane7dcdf022013-12-11 14:45:27 -08004563 return
Rich Lane7b0f2012013-11-22 14:15:26 -08004564
4565 def pack(self):
4566 packed = []
4567 packed.append(struct.pack("!B", self.version))
4568 packed.append(struct.pack("!B", self.type))
4569 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4570 packed.append(struct.pack("!L", self.xid))
4571 packed.append(struct.pack("!H", self.command))
4572 packed.append(struct.pack("!B", self.group_type))
4573 packed.append('\x00' * 1)
4574 packed.append(struct.pack("!L", self.group_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08004575 packed.append(loxi.generic_util.pack_list(self.buckets))
Rich Lane7b0f2012013-11-22 14:15:26 -08004576 length = sum([len(x) for x in packed])
4577 packed[2] = struct.pack("!H", length)
4578 return ''.join(packed)
4579
4580 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004581 def unpack(reader):
Rich Lane7b0f2012013-11-22 14:15:26 -08004582 obj = group_add()
Rich Lane7b0f2012013-11-22 14:15:26 -08004583 _version = reader.read("!B")[0]
4584 assert(_version == 2)
4585 _type = reader.read("!B")[0]
4586 assert(_type == 15)
4587 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004588 orig_reader = reader
4589 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane7b0f2012013-11-22 14:15:26 -08004590 obj.xid = reader.read("!L")[0]
4591 _command = reader.read("!H")[0]
4592 assert(_command == 0)
4593 obj.group_type = reader.read("!B")[0]
4594 reader.skip(1)
4595 obj.group_id = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004596 obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack)
Rich Lane7b0f2012013-11-22 14:15:26 -08004597 return obj
4598
4599 def __eq__(self, other):
4600 if type(self) != type(other): return False
Rich Lane7b0f2012013-11-22 14:15:26 -08004601 if self.xid != other.xid: return False
4602 if self.group_type != other.group_type: return False
4603 if self.group_id != other.group_id: return False
4604 if self.buckets != other.buckets: return False
4605 return True
4606
Rich Lane7b0f2012013-11-22 14:15:26 -08004607 def pretty_print(self, q):
4608 q.text("group_add {")
4609 with q.group():
4610 with q.indent(2):
4611 q.breakable()
4612 q.text("xid = ");
4613 if self.xid != None:
4614 q.text("%#x" % self.xid)
4615 else:
4616 q.text('None')
4617 q.text(","); q.breakable()
4618 q.text("group_type = ");
4619 q.text("%#x" % self.group_type)
4620 q.text(","); q.breakable()
4621 q.text("group_id = ");
4622 q.text("%#x" % self.group_id)
4623 q.text(","); q.breakable()
4624 q.text("buckets = ");
4625 q.pp(self.buckets)
4626 q.breakable()
4627 q.text('}')
4628
Rich Lane7dcdf022013-12-11 14:45:27 -08004629group_mod.subtypes[0] = group_add
4630
4631class group_delete(group_mod):
Rich Lane7b0f2012013-11-22 14:15:26 -08004632 version = 2
4633 type = 15
4634 command = 2
4635
4636 def __init__(self, xid=None, group_type=None, group_id=None, buckets=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08004637 if xid != None:
4638 self.xid = xid
4639 else:
4640 self.xid = None
Rich Lane7b0f2012013-11-22 14:15:26 -08004641 if group_type != None:
4642 self.group_type = group_type
4643 else:
4644 self.group_type = 0
4645 if group_id != None:
4646 self.group_id = group_id
4647 else:
4648 self.group_id = 0
4649 if buckets != None:
4650 self.buckets = buckets
4651 else:
4652 self.buckets = []
Rich Lane7dcdf022013-12-11 14:45:27 -08004653 return
Rich Lane7b0f2012013-11-22 14:15:26 -08004654
4655 def pack(self):
4656 packed = []
4657 packed.append(struct.pack("!B", self.version))
4658 packed.append(struct.pack("!B", self.type))
4659 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4660 packed.append(struct.pack("!L", self.xid))
4661 packed.append(struct.pack("!H", self.command))
4662 packed.append(struct.pack("!B", self.group_type))
4663 packed.append('\x00' * 1)
4664 packed.append(struct.pack("!L", self.group_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08004665 packed.append(loxi.generic_util.pack_list(self.buckets))
Rich Lane7b0f2012013-11-22 14:15:26 -08004666 length = sum([len(x) for x in packed])
4667 packed[2] = struct.pack("!H", length)
4668 return ''.join(packed)
4669
4670 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004671 def unpack(reader):
Rich Lane7b0f2012013-11-22 14:15:26 -08004672 obj = group_delete()
Rich Lane7b0f2012013-11-22 14:15:26 -08004673 _version = reader.read("!B")[0]
4674 assert(_version == 2)
4675 _type = reader.read("!B")[0]
4676 assert(_type == 15)
4677 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004678 orig_reader = reader
4679 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane7b0f2012013-11-22 14:15:26 -08004680 obj.xid = reader.read("!L")[0]
4681 _command = reader.read("!H")[0]
4682 assert(_command == 2)
4683 obj.group_type = reader.read("!B")[0]
4684 reader.skip(1)
4685 obj.group_id = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004686 obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack)
Rich Lane7b0f2012013-11-22 14:15:26 -08004687 return obj
4688
4689 def __eq__(self, other):
4690 if type(self) != type(other): return False
Rich Lane7b0f2012013-11-22 14:15:26 -08004691 if self.xid != other.xid: return False
4692 if self.group_type != other.group_type: return False
4693 if self.group_id != other.group_id: return False
4694 if self.buckets != other.buckets: return False
4695 return True
4696
Rich Lane7b0f2012013-11-22 14:15:26 -08004697 def pretty_print(self, q):
4698 q.text("group_delete {")
4699 with q.group():
4700 with q.indent(2):
4701 q.breakable()
4702 q.text("xid = ");
4703 if self.xid != None:
4704 q.text("%#x" % self.xid)
4705 else:
4706 q.text('None')
4707 q.text(","); q.breakable()
4708 q.text("group_type = ");
4709 q.text("%#x" % self.group_type)
4710 q.text(","); q.breakable()
4711 q.text("group_id = ");
4712 q.text("%#x" % self.group_id)
4713 q.text(","); q.breakable()
4714 q.text("buckets = ");
4715 q.pp(self.buckets)
4716 q.breakable()
4717 q.text('}')
4718
Rich Lane7dcdf022013-12-11 14:45:27 -08004719group_mod.subtypes[2] = group_delete
4720
4721class group_desc_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07004722 version = 2
4723 type = 19
4724 stats_type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07004725
4726 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08004727 if xid != None:
4728 self.xid = xid
4729 else:
4730 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004731 if flags != None:
4732 self.flags = flags
4733 else:
4734 self.flags = 0
4735 if entries != None:
4736 self.entries = entries
4737 else:
4738 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08004739 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004740
4741 def pack(self):
4742 packed = []
4743 packed.append(struct.pack("!B", self.version))
4744 packed.append(struct.pack("!B", self.type))
4745 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4746 packed.append(struct.pack("!L", self.xid))
4747 packed.append(struct.pack("!H", self.stats_type))
4748 packed.append(struct.pack("!H", self.flags))
4749 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08004750 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004751 length = sum([len(x) for x in packed])
4752 packed[2] = struct.pack("!H", length)
4753 return ''.join(packed)
4754
4755 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004756 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004757 obj = group_desc_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07004758 _version = reader.read("!B")[0]
4759 assert(_version == 2)
4760 _type = reader.read("!B")[0]
4761 assert(_type == 19)
4762 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004763 orig_reader = reader
4764 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07004765 obj.xid = reader.read("!L")[0]
4766 _stats_type = reader.read("!H")[0]
4767 assert(_stats_type == 7)
4768 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004769 reader.skip(4)
Rich Lane7dcdf022013-12-11 14:45:27 -08004770 obj.entries = loxi.generic_util.unpack_list(reader, common.group_desc_stats_entry.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07004771 return obj
4772
4773 def __eq__(self, other):
4774 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004775 if self.xid != other.xid: return False
4776 if self.flags != other.flags: return False
4777 if self.entries != other.entries: return False
4778 return True
4779
Rich Lanec2ee4b82013-04-24 17:12:38 -07004780 def pretty_print(self, q):
4781 q.text("group_desc_stats_reply {")
4782 with q.group():
4783 with q.indent(2):
4784 q.breakable()
4785 q.text("xid = ");
4786 if self.xid != None:
4787 q.text("%#x" % self.xid)
4788 else:
4789 q.text('None')
4790 q.text(","); q.breakable()
4791 q.text("flags = ");
4792 q.text("%#x" % self.flags)
4793 q.text(","); q.breakable()
4794 q.text("entries = ");
4795 q.pp(self.entries)
4796 q.breakable()
4797 q.text('}')
4798
Rich Lane7dcdf022013-12-11 14:45:27 -08004799stats_reply.subtypes[7] = group_desc_stats_reply
4800
4801class group_desc_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07004802 version = 2
4803 type = 18
4804 stats_type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07004805
4806 def __init__(self, xid=None, flags=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08004807 if xid != None:
4808 self.xid = xid
4809 else:
4810 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004811 if flags != None:
4812 self.flags = flags
4813 else:
4814 self.flags = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08004815 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004816
4817 def pack(self):
4818 packed = []
4819 packed.append(struct.pack("!B", self.version))
4820 packed.append(struct.pack("!B", self.type))
4821 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4822 packed.append(struct.pack("!L", self.xid))
4823 packed.append(struct.pack("!H", self.stats_type))
4824 packed.append(struct.pack("!H", self.flags))
4825 packed.append('\x00' * 4)
4826 length = sum([len(x) for x in packed])
4827 packed[2] = struct.pack("!H", length)
4828 return ''.join(packed)
4829
4830 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004831 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004832 obj = group_desc_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07004833 _version = reader.read("!B")[0]
4834 assert(_version == 2)
4835 _type = reader.read("!B")[0]
4836 assert(_type == 18)
4837 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004838 orig_reader = reader
4839 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07004840 obj.xid = reader.read("!L")[0]
4841 _stats_type = reader.read("!H")[0]
4842 assert(_stats_type == 7)
4843 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004844 reader.skip(4)
4845 return obj
4846
4847 def __eq__(self, other):
4848 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004849 if self.xid != other.xid: return False
4850 if self.flags != other.flags: return False
4851 return True
4852
Rich Lanec2ee4b82013-04-24 17:12:38 -07004853 def pretty_print(self, q):
4854 q.text("group_desc_stats_request {")
4855 with q.group():
4856 with q.indent(2):
4857 q.breakable()
4858 q.text("xid = ");
4859 if self.xid != None:
4860 q.text("%#x" % self.xid)
4861 else:
4862 q.text('None')
4863 q.text(","); q.breakable()
4864 q.text("flags = ");
4865 q.text("%#x" % self.flags)
4866 q.breakable()
4867 q.text('}')
4868
Rich Lane7dcdf022013-12-11 14:45:27 -08004869stats_request.subtypes[7] = group_desc_stats_request
4870
4871class group_mod_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07004872 version = 2
4873 type = 1
4874 err_type = 6
4875
4876 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08004877 if xid != None:
4878 self.xid = xid
4879 else:
4880 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07004881 if code != None:
4882 self.code = code
4883 else:
4884 self.code = 0
4885 if data != None:
4886 self.data = data
4887 else:
4888 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08004889 return
Rich Lane6f4978c2013-10-20 21:33:52 -07004890
4891 def pack(self):
4892 packed = []
4893 packed.append(struct.pack("!B", self.version))
4894 packed.append(struct.pack("!B", self.type))
4895 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4896 packed.append(struct.pack("!L", self.xid))
4897 packed.append(struct.pack("!H", self.err_type))
4898 packed.append(struct.pack("!H", self.code))
4899 packed.append(self.data)
4900 length = sum([len(x) for x in packed])
4901 packed[2] = struct.pack("!H", length)
4902 return ''.join(packed)
4903
4904 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004905 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07004906 obj = group_mod_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07004907 _version = reader.read("!B")[0]
4908 assert(_version == 2)
4909 _type = reader.read("!B")[0]
4910 assert(_type == 1)
4911 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004912 orig_reader = reader
4913 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07004914 obj.xid = reader.read("!L")[0]
4915 _err_type = reader.read("!H")[0]
4916 assert(_err_type == 6)
4917 obj.code = reader.read("!H")[0]
4918 obj.data = str(reader.read_all())
4919 return obj
4920
4921 def __eq__(self, other):
4922 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07004923 if self.xid != other.xid: return False
4924 if self.code != other.code: return False
4925 if self.data != other.data: return False
4926 return True
4927
Rich Lane6f4978c2013-10-20 21:33:52 -07004928 def pretty_print(self, q):
4929 q.text("group_mod_failed_error_msg {")
4930 with q.group():
4931 with q.indent(2):
4932 q.breakable()
4933 q.text("xid = ");
4934 if self.xid != None:
4935 q.text("%#x" % self.xid)
4936 else:
4937 q.text('None')
4938 q.text(","); q.breakable()
4939 q.text("code = ");
4940 q.text("%#x" % self.code)
4941 q.text(","); q.breakable()
4942 q.text("data = ");
4943 q.pp(self.data)
4944 q.breakable()
4945 q.text('}')
4946
Rich Lane7dcdf022013-12-11 14:45:27 -08004947error_msg.subtypes[6] = group_mod_failed_error_msg
4948
4949class group_modify(group_mod):
Rich Lane7b0f2012013-11-22 14:15:26 -08004950 version = 2
4951 type = 15
4952 command = 1
4953
4954 def __init__(self, xid=None, group_type=None, group_id=None, buckets=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08004955 if xid != None:
4956 self.xid = xid
4957 else:
4958 self.xid = None
Rich Lane7b0f2012013-11-22 14:15:26 -08004959 if group_type != None:
4960 self.group_type = group_type
4961 else:
4962 self.group_type = 0
4963 if group_id != None:
4964 self.group_id = group_id
4965 else:
4966 self.group_id = 0
4967 if buckets != None:
4968 self.buckets = buckets
4969 else:
4970 self.buckets = []
Rich Lane7dcdf022013-12-11 14:45:27 -08004971 return
Rich Lane7b0f2012013-11-22 14:15:26 -08004972
4973 def pack(self):
4974 packed = []
4975 packed.append(struct.pack("!B", self.version))
4976 packed.append(struct.pack("!B", self.type))
4977 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4978 packed.append(struct.pack("!L", self.xid))
4979 packed.append(struct.pack("!H", self.command))
4980 packed.append(struct.pack("!B", self.group_type))
4981 packed.append('\x00' * 1)
4982 packed.append(struct.pack("!L", self.group_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08004983 packed.append(loxi.generic_util.pack_list(self.buckets))
Rich Lane7b0f2012013-11-22 14:15:26 -08004984 length = sum([len(x) for x in packed])
4985 packed[2] = struct.pack("!H", length)
4986 return ''.join(packed)
4987
4988 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004989 def unpack(reader):
Rich Lane7b0f2012013-11-22 14:15:26 -08004990 obj = group_modify()
Rich Lane7b0f2012013-11-22 14:15:26 -08004991 _version = reader.read("!B")[0]
4992 assert(_version == 2)
4993 _type = reader.read("!B")[0]
4994 assert(_type == 15)
4995 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004996 orig_reader = reader
4997 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane7b0f2012013-11-22 14:15:26 -08004998 obj.xid = reader.read("!L")[0]
4999 _command = reader.read("!H")[0]
5000 assert(_command == 1)
5001 obj.group_type = reader.read("!B")[0]
5002 reader.skip(1)
5003 obj.group_id = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005004 obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack)
Rich Lane7b0f2012013-11-22 14:15:26 -08005005 return obj
5006
5007 def __eq__(self, other):
5008 if type(self) != type(other): return False
Rich Lane7b0f2012013-11-22 14:15:26 -08005009 if self.xid != other.xid: return False
5010 if self.group_type != other.group_type: return False
5011 if self.group_id != other.group_id: return False
5012 if self.buckets != other.buckets: return False
5013 return True
5014
Rich Lane7b0f2012013-11-22 14:15:26 -08005015 def pretty_print(self, q):
5016 q.text("group_modify {")
5017 with q.group():
5018 with q.indent(2):
5019 q.breakable()
5020 q.text("xid = ");
5021 if self.xid != None:
5022 q.text("%#x" % self.xid)
5023 else:
5024 q.text('None')
5025 q.text(","); q.breakable()
5026 q.text("group_type = ");
5027 q.text("%#x" % self.group_type)
5028 q.text(","); q.breakable()
5029 q.text("group_id = ");
5030 q.text("%#x" % self.group_id)
5031 q.text(","); q.breakable()
5032 q.text("buckets = ");
5033 q.pp(self.buckets)
5034 q.breakable()
5035 q.text('}')
5036
Rich Lane7dcdf022013-12-11 14:45:27 -08005037group_mod.subtypes[1] = group_modify
5038
5039class group_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07005040 version = 2
5041 type = 19
5042 stats_type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07005043
5044 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005045 if xid != None:
5046 self.xid = xid
5047 else:
5048 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005049 if flags != None:
5050 self.flags = flags
5051 else:
5052 self.flags = 0
5053 if entries != None:
5054 self.entries = entries
5055 else:
5056 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08005057 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005058
5059 def pack(self):
5060 packed = []
5061 packed.append(struct.pack("!B", self.version))
5062 packed.append(struct.pack("!B", self.type))
5063 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5064 packed.append(struct.pack("!L", self.xid))
5065 packed.append(struct.pack("!H", self.stats_type))
5066 packed.append(struct.pack("!H", self.flags))
5067 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08005068 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005069 length = sum([len(x) for x in packed])
5070 packed[2] = struct.pack("!H", length)
5071 return ''.join(packed)
5072
5073 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005074 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005075 obj = group_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07005076 _version = reader.read("!B")[0]
5077 assert(_version == 2)
5078 _type = reader.read("!B")[0]
5079 assert(_type == 19)
5080 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005081 orig_reader = reader
5082 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005083 obj.xid = reader.read("!L")[0]
5084 _stats_type = reader.read("!H")[0]
5085 assert(_stats_type == 6)
5086 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005087 reader.skip(4)
Rich Lane7dcdf022013-12-11 14:45:27 -08005088 obj.entries = loxi.generic_util.unpack_list(reader, common.group_stats_entry.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07005089 return obj
5090
5091 def __eq__(self, other):
5092 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005093 if self.xid != other.xid: return False
5094 if self.flags != other.flags: return False
5095 if self.entries != other.entries: return False
5096 return True
5097
Rich Lanec2ee4b82013-04-24 17:12:38 -07005098 def pretty_print(self, q):
5099 q.text("group_stats_reply {")
5100 with q.group():
5101 with q.indent(2):
5102 q.breakable()
5103 q.text("xid = ");
5104 if self.xid != None:
5105 q.text("%#x" % self.xid)
5106 else:
5107 q.text('None')
5108 q.text(","); q.breakable()
5109 q.text("flags = ");
5110 q.text("%#x" % self.flags)
5111 q.text(","); q.breakable()
5112 q.text("entries = ");
5113 q.pp(self.entries)
5114 q.breakable()
5115 q.text('}')
5116
Rich Lane7dcdf022013-12-11 14:45:27 -08005117stats_reply.subtypes[6] = group_stats_reply
5118
5119class group_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07005120 version = 2
5121 type = 18
5122 stats_type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07005123
5124 def __init__(self, xid=None, flags=None, group_id=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005125 if xid != None:
5126 self.xid = xid
5127 else:
5128 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005129 if flags != None:
5130 self.flags = flags
5131 else:
5132 self.flags = 0
5133 if group_id != None:
5134 self.group_id = group_id
5135 else:
5136 self.group_id = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08005137 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005138
5139 def pack(self):
5140 packed = []
5141 packed.append(struct.pack("!B", self.version))
5142 packed.append(struct.pack("!B", self.type))
5143 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5144 packed.append(struct.pack("!L", self.xid))
5145 packed.append(struct.pack("!H", self.stats_type))
5146 packed.append(struct.pack("!H", self.flags))
5147 packed.append('\x00' * 4)
5148 packed.append(struct.pack("!L", self.group_id))
5149 packed.append('\x00' * 4)
5150 length = sum([len(x) for x in packed])
5151 packed[2] = struct.pack("!H", length)
5152 return ''.join(packed)
5153
5154 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005155 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005156 obj = group_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07005157 _version = reader.read("!B")[0]
5158 assert(_version == 2)
5159 _type = reader.read("!B")[0]
5160 assert(_type == 18)
5161 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005162 orig_reader = reader
5163 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005164 obj.xid = reader.read("!L")[0]
5165 _stats_type = reader.read("!H")[0]
5166 assert(_stats_type == 6)
5167 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005168 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07005169 obj.group_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005170 reader.skip(4)
5171 return obj
5172
5173 def __eq__(self, other):
5174 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005175 if self.xid != other.xid: return False
5176 if self.flags != other.flags: return False
5177 if self.group_id != other.group_id: return False
5178 return True
5179
Rich Lanec2ee4b82013-04-24 17:12:38 -07005180 def pretty_print(self, q):
5181 q.text("group_stats_request {")
5182 with q.group():
5183 with q.indent(2):
5184 q.breakable()
5185 q.text("xid = ");
5186 if self.xid != None:
5187 q.text("%#x" % self.xid)
5188 else:
5189 q.text('None')
5190 q.text(","); q.breakable()
5191 q.text("flags = ");
5192 q.text("%#x" % self.flags)
5193 q.text(","); q.breakable()
5194 q.text("group_id = ");
5195 q.text("%#x" % self.group_id)
5196 q.breakable()
5197 q.text('}')
5198
Rich Lane7dcdf022013-12-11 14:45:27 -08005199stats_request.subtypes[6] = group_stats_request
5200
5201class hello(message):
Dan Talaycof6202252013-07-02 01:00:29 -07005202 version = 2
5203 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07005204
5205 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005206 if xid != None:
5207 self.xid = xid
5208 else:
5209 self.xid = None
5210 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005211
5212 def pack(self):
5213 packed = []
5214 packed.append(struct.pack("!B", self.version))
5215 packed.append(struct.pack("!B", self.type))
5216 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5217 packed.append(struct.pack("!L", self.xid))
5218 length = sum([len(x) for x in packed])
5219 packed[2] = struct.pack("!H", length)
5220 return ''.join(packed)
5221
5222 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005223 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005224 obj = hello()
Dan Talaycof6202252013-07-02 01:00:29 -07005225 _version = reader.read("!B")[0]
5226 assert(_version == 2)
5227 _type = reader.read("!B")[0]
5228 assert(_type == 0)
5229 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005230 orig_reader = reader
5231 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005232 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005233 return obj
5234
5235 def __eq__(self, other):
5236 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005237 if self.xid != other.xid: return False
5238 return True
5239
Rich Lanec2ee4b82013-04-24 17:12:38 -07005240 def pretty_print(self, q):
5241 q.text("hello {")
5242 with q.group():
5243 with q.indent(2):
5244 q.breakable()
5245 q.text("xid = ");
5246 if self.xid != None:
5247 q.text("%#x" % self.xid)
5248 else:
5249 q.text('None')
5250 q.breakable()
5251 q.text('}')
5252
Rich Lane7dcdf022013-12-11 14:45:27 -08005253message.subtypes[0] = hello
5254
5255class hello_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07005256 version = 2
5257 type = 1
5258 err_type = 0
5259
5260 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005261 if xid != None:
5262 self.xid = xid
5263 else:
5264 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07005265 if code != None:
5266 self.code = code
5267 else:
5268 self.code = 0
5269 if data != None:
5270 self.data = data
5271 else:
5272 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08005273 return
Rich Lane6f4978c2013-10-20 21:33:52 -07005274
5275 def pack(self):
5276 packed = []
5277 packed.append(struct.pack("!B", self.version))
5278 packed.append(struct.pack("!B", self.type))
5279 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5280 packed.append(struct.pack("!L", self.xid))
5281 packed.append(struct.pack("!H", self.err_type))
5282 packed.append(struct.pack("!H", self.code))
5283 packed.append(self.data)
5284 length = sum([len(x) for x in packed])
5285 packed[2] = struct.pack("!H", length)
5286 return ''.join(packed)
5287
5288 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005289 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07005290 obj = hello_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07005291 _version = reader.read("!B")[0]
5292 assert(_version == 2)
5293 _type = reader.read("!B")[0]
5294 assert(_type == 1)
5295 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005296 orig_reader = reader
5297 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07005298 obj.xid = reader.read("!L")[0]
5299 _err_type = reader.read("!H")[0]
5300 assert(_err_type == 0)
5301 obj.code = reader.read("!H")[0]
5302 obj.data = str(reader.read_all())
5303 return obj
5304
5305 def __eq__(self, other):
5306 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07005307 if self.xid != other.xid: return False
5308 if self.code != other.code: return False
5309 if self.data != other.data: return False
5310 return True
5311
Rich Lane6f4978c2013-10-20 21:33:52 -07005312 def pretty_print(self, q):
5313 q.text("hello_failed_error_msg {")
5314 with q.group():
5315 with q.indent(2):
5316 q.breakable()
5317 q.text("xid = ");
5318 if self.xid != None:
5319 q.text("%#x" % self.xid)
5320 else:
5321 q.text('None')
5322 q.text(","); q.breakable()
5323 q.text("code = ");
5324 q.text("%#x" % self.code)
5325 q.text(","); q.breakable()
5326 q.text("data = ");
5327 q.pp(self.data)
5328 q.breakable()
5329 q.text('}')
5330
Rich Lane7dcdf022013-12-11 14:45:27 -08005331error_msg.subtypes[0] = hello_failed_error_msg
5332
5333class nicira_header(experimenter):
5334 subtypes = {}
5335
5336 @staticmethod
5337 def unpack(reader):
5338 subtype, = reader.peek('!L', 12)
5339 try:
5340 subclass = nicira_header.subtypes[subtype]
5341 except KeyError:
5342 raise loxi.ProtocolError("unknown nicira_header experimenter message subtype %#x" % subtype)
5343 return subclass.unpack(reader)
5344
5345experimenter.subtypes[8992] = nicira_header
5346
5347class packet_in(message):
Dan Talaycof6202252013-07-02 01:00:29 -07005348 version = 2
5349 type = 10
Rich Lanec2ee4b82013-04-24 17:12:38 -07005350
5351 def __init__(self, xid=None, buffer_id=None, in_port=None, in_phy_port=None, total_len=None, reason=None, table_id=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005352 if xid != None:
5353 self.xid = xid
5354 else:
5355 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005356 if buffer_id != None:
5357 self.buffer_id = buffer_id
5358 else:
5359 self.buffer_id = 0
5360 if in_port != None:
5361 self.in_port = in_port
5362 else:
5363 self.in_port = 0
5364 if in_phy_port != None:
5365 self.in_phy_port = in_phy_port
5366 else:
5367 self.in_phy_port = 0
5368 if total_len != None:
5369 self.total_len = total_len
5370 else:
5371 self.total_len = 0
5372 if reason != None:
5373 self.reason = reason
5374 else:
5375 self.reason = 0
5376 if table_id != None:
5377 self.table_id = table_id
5378 else:
5379 self.table_id = 0
5380 if data != None:
5381 self.data = data
5382 else:
Dan Talaycof6202252013-07-02 01:00:29 -07005383 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08005384 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005385
5386 def pack(self):
5387 packed = []
5388 packed.append(struct.pack("!B", self.version))
5389 packed.append(struct.pack("!B", self.type))
5390 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5391 packed.append(struct.pack("!L", self.xid))
5392 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07005393 packed.append(util.pack_port_no(self.in_port))
5394 packed.append(util.pack_port_no(self.in_phy_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005395 packed.append(struct.pack("!H", self.total_len))
5396 packed.append(struct.pack("!B", self.reason))
5397 packed.append(struct.pack("!B", self.table_id))
5398 packed.append(self.data)
5399 length = sum([len(x) for x in packed])
5400 packed[2] = struct.pack("!H", length)
5401 return ''.join(packed)
5402
5403 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005404 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005405 obj = packet_in()
Dan Talaycof6202252013-07-02 01:00:29 -07005406 _version = reader.read("!B")[0]
5407 assert(_version == 2)
5408 _type = reader.read("!B")[0]
5409 assert(_type == 10)
5410 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005411 orig_reader = reader
5412 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005413 obj.xid = reader.read("!L")[0]
5414 obj.buffer_id = reader.read("!L")[0]
5415 obj.in_port = util.unpack_port_no(reader)
5416 obj.in_phy_port = util.unpack_port_no(reader)
5417 obj.total_len = reader.read("!H")[0]
5418 obj.reason = reader.read("!B")[0]
5419 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005420 obj.data = str(reader.read_all())
5421 return obj
5422
5423 def __eq__(self, other):
5424 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005425 if self.xid != other.xid: return False
5426 if self.buffer_id != other.buffer_id: return False
5427 if self.in_port != other.in_port: return False
5428 if self.in_phy_port != other.in_phy_port: return False
5429 if self.total_len != other.total_len: return False
5430 if self.reason != other.reason: return False
5431 if self.table_id != other.table_id: return False
5432 if self.data != other.data: return False
5433 return True
5434
Rich Lanec2ee4b82013-04-24 17:12:38 -07005435 def pretty_print(self, q):
5436 q.text("packet_in {")
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("buffer_id = ");
5447 q.text("%#x" % self.buffer_id)
5448 q.text(","); q.breakable()
5449 q.text("in_port = ");
5450 q.text(util.pretty_port(self.in_port))
5451 q.text(","); q.breakable()
5452 q.text("in_phy_port = ");
5453 q.text(util.pretty_port(self.in_phy_port))
5454 q.text(","); q.breakable()
5455 q.text("total_len = ");
5456 q.text("%#x" % self.total_len)
5457 q.text(","); q.breakable()
5458 q.text("reason = ");
5459 q.text("%#x" % self.reason)
5460 q.text(","); q.breakable()
5461 q.text("table_id = ");
5462 q.text("%#x" % self.table_id)
5463 q.text(","); q.breakable()
5464 q.text("data = ");
5465 q.pp(self.data)
5466 q.breakable()
5467 q.text('}')
5468
Rich Lane7dcdf022013-12-11 14:45:27 -08005469message.subtypes[10] = packet_in
5470
5471class packet_out(message):
Dan Talaycof6202252013-07-02 01:00:29 -07005472 version = 2
5473 type = 13
Rich Lanec2ee4b82013-04-24 17:12:38 -07005474
5475 def __init__(self, xid=None, buffer_id=None, in_port=None, actions=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005476 if xid != None:
5477 self.xid = xid
5478 else:
5479 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005480 if buffer_id != None:
5481 self.buffer_id = buffer_id
5482 else:
5483 self.buffer_id = 0
5484 if in_port != None:
5485 self.in_port = in_port
5486 else:
5487 self.in_port = 0
5488 if actions != None:
5489 self.actions = actions
5490 else:
5491 self.actions = []
5492 if data != None:
5493 self.data = data
5494 else:
Dan Talaycof6202252013-07-02 01:00:29 -07005495 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08005496 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005497
5498 def pack(self):
5499 packed = []
5500 packed.append(struct.pack("!B", self.version))
5501 packed.append(struct.pack("!B", self.type))
5502 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5503 packed.append(struct.pack("!L", self.xid))
5504 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07005505 packed.append(util.pack_port_no(self.in_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005506 packed.append(struct.pack("!H", 0)) # placeholder for actions_len at index 6
5507 packed.append('\x00' * 6)
Rich Lane7dcdf022013-12-11 14:45:27 -08005508 packed.append(loxi.generic_util.pack_list(self.actions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005509 packed[6] = struct.pack("!H", len(packed[-1]))
5510 packed.append(self.data)
5511 length = sum([len(x) for x in packed])
5512 packed[2] = struct.pack("!H", length)
5513 return ''.join(packed)
5514
5515 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005516 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005517 obj = packet_out()
Dan Talaycof6202252013-07-02 01:00:29 -07005518 _version = reader.read("!B")[0]
5519 assert(_version == 2)
5520 _type = reader.read("!B")[0]
5521 assert(_type == 13)
5522 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005523 orig_reader = reader
5524 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005525 obj.xid = reader.read("!L")[0]
5526 obj.buffer_id = reader.read("!L")[0]
5527 obj.in_port = util.unpack_port_no(reader)
5528 _actions_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005529 reader.skip(6)
Rich Lane7dcdf022013-12-11 14:45:27 -08005530 obj.actions = loxi.generic_util.unpack_list(reader.slice(_actions_len), action.action.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07005531 obj.data = str(reader.read_all())
5532 return obj
5533
5534 def __eq__(self, other):
5535 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005536 if self.xid != other.xid: return False
5537 if self.buffer_id != other.buffer_id: return False
5538 if self.in_port != other.in_port: return False
5539 if self.actions != other.actions: return False
5540 if self.data != other.data: return False
5541 return True
5542
Rich Lanec2ee4b82013-04-24 17:12:38 -07005543 def pretty_print(self, q):
5544 q.text("packet_out {")
5545 with q.group():
5546 with q.indent(2):
5547 q.breakable()
5548 q.text("xid = ");
5549 if self.xid != None:
5550 q.text("%#x" % self.xid)
5551 else:
5552 q.text('None')
5553 q.text(","); q.breakable()
5554 q.text("buffer_id = ");
5555 q.text("%#x" % self.buffer_id)
5556 q.text(","); q.breakable()
5557 q.text("in_port = ");
5558 q.text(util.pretty_port(self.in_port))
5559 q.text(","); q.breakable()
5560 q.text("actions = ");
5561 q.pp(self.actions)
5562 q.text(","); q.breakable()
5563 q.text("data = ");
5564 q.pp(self.data)
5565 q.breakable()
5566 q.text('}')
5567
Rich Lane7dcdf022013-12-11 14:45:27 -08005568message.subtypes[13] = packet_out
5569
5570class port_mod(message):
Dan Talaycof6202252013-07-02 01:00:29 -07005571 version = 2
5572 type = 16
Rich Lanec2ee4b82013-04-24 17:12:38 -07005573
5574 def __init__(self, xid=None, port_no=None, hw_addr=None, config=None, mask=None, advertise=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005575 if xid != None:
5576 self.xid = xid
5577 else:
5578 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005579 if port_no != None:
5580 self.port_no = port_no
5581 else:
5582 self.port_no = 0
5583 if hw_addr != None:
5584 self.hw_addr = hw_addr
5585 else:
5586 self.hw_addr = [0,0,0,0,0,0]
5587 if config != None:
5588 self.config = config
5589 else:
5590 self.config = 0
5591 if mask != None:
5592 self.mask = mask
5593 else:
5594 self.mask = 0
5595 if advertise != None:
5596 self.advertise = advertise
5597 else:
5598 self.advertise = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08005599 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005600
5601 def pack(self):
5602 packed = []
5603 packed.append(struct.pack("!B", self.version))
5604 packed.append(struct.pack("!B", self.type))
5605 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5606 packed.append(struct.pack("!L", self.xid))
Dan Talaycof6202252013-07-02 01:00:29 -07005607 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005608 packed.append('\x00' * 4)
5609 packed.append(struct.pack("!6B", *self.hw_addr))
5610 packed.append('\x00' * 2)
5611 packed.append(struct.pack("!L", self.config))
5612 packed.append(struct.pack("!L", self.mask))
5613 packed.append(struct.pack("!L", self.advertise))
5614 packed.append('\x00' * 4)
5615 length = sum([len(x) for x in packed])
5616 packed[2] = struct.pack("!H", length)
5617 return ''.join(packed)
5618
5619 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005620 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005621 obj = port_mod()
Dan Talaycof6202252013-07-02 01:00:29 -07005622 _version = reader.read("!B")[0]
5623 assert(_version == 2)
5624 _type = reader.read("!B")[0]
5625 assert(_type == 16)
5626 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005627 orig_reader = reader
5628 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005629 obj.xid = reader.read("!L")[0]
5630 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07005631 reader.skip(4)
5632 obj.hw_addr = list(reader.read('!6B'))
5633 reader.skip(2)
Dan Talaycof6202252013-07-02 01:00:29 -07005634 obj.config = reader.read("!L")[0]
5635 obj.mask = reader.read("!L")[0]
5636 obj.advertise = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005637 reader.skip(4)
5638 return obj
5639
5640 def __eq__(self, other):
5641 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005642 if self.xid != other.xid: return False
5643 if self.port_no != other.port_no: return False
5644 if self.hw_addr != other.hw_addr: return False
5645 if self.config != other.config: return False
5646 if self.mask != other.mask: return False
5647 if self.advertise != other.advertise: return False
5648 return True
5649
Rich Lanec2ee4b82013-04-24 17:12:38 -07005650 def pretty_print(self, q):
5651 q.text("port_mod {")
5652 with q.group():
5653 with q.indent(2):
5654 q.breakable()
5655 q.text("xid = ");
5656 if self.xid != None:
5657 q.text("%#x" % self.xid)
5658 else:
5659 q.text('None')
5660 q.text(","); q.breakable()
5661 q.text("port_no = ");
5662 q.text(util.pretty_port(self.port_no))
5663 q.text(","); q.breakable()
5664 q.text("hw_addr = ");
5665 q.text(util.pretty_mac(self.hw_addr))
5666 q.text(","); q.breakable()
5667 q.text("config = ");
5668 q.text("%#x" % self.config)
5669 q.text(","); q.breakable()
5670 q.text("mask = ");
5671 q.text("%#x" % self.mask)
5672 q.text(","); q.breakable()
5673 q.text("advertise = ");
5674 q.text("%#x" % self.advertise)
5675 q.breakable()
5676 q.text('}')
5677
Rich Lane7dcdf022013-12-11 14:45:27 -08005678message.subtypes[16] = port_mod
5679
5680class port_mod_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07005681 version = 2
5682 type = 1
5683 err_type = 7
5684
5685 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005686 if xid != None:
5687 self.xid = xid
5688 else:
5689 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07005690 if code != None:
5691 self.code = code
5692 else:
5693 self.code = 0
5694 if data != None:
5695 self.data = data
5696 else:
5697 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08005698 return
Rich Lane6f4978c2013-10-20 21:33:52 -07005699
5700 def pack(self):
5701 packed = []
5702 packed.append(struct.pack("!B", self.version))
5703 packed.append(struct.pack("!B", self.type))
5704 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5705 packed.append(struct.pack("!L", self.xid))
5706 packed.append(struct.pack("!H", self.err_type))
5707 packed.append(struct.pack("!H", self.code))
5708 packed.append(self.data)
5709 length = sum([len(x) for x in packed])
5710 packed[2] = struct.pack("!H", length)
5711 return ''.join(packed)
5712
5713 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005714 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07005715 obj = port_mod_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07005716 _version = reader.read("!B")[0]
5717 assert(_version == 2)
5718 _type = reader.read("!B")[0]
5719 assert(_type == 1)
5720 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005721 orig_reader = reader
5722 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07005723 obj.xid = reader.read("!L")[0]
5724 _err_type = reader.read("!H")[0]
5725 assert(_err_type == 7)
5726 obj.code = reader.read("!H")[0]
5727 obj.data = str(reader.read_all())
5728 return obj
5729
5730 def __eq__(self, other):
5731 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07005732 if self.xid != other.xid: return False
5733 if self.code != other.code: return False
5734 if self.data != other.data: return False
5735 return True
5736
Rich Lane6f4978c2013-10-20 21:33:52 -07005737 def pretty_print(self, q):
5738 q.text("port_mod_failed_error_msg {")
5739 with q.group():
5740 with q.indent(2):
5741 q.breakable()
5742 q.text("xid = ");
5743 if self.xid != None:
5744 q.text("%#x" % self.xid)
5745 else:
5746 q.text('None')
5747 q.text(","); q.breakable()
5748 q.text("code = ");
5749 q.text("%#x" % self.code)
5750 q.text(","); q.breakable()
5751 q.text("data = ");
5752 q.pp(self.data)
5753 q.breakable()
5754 q.text('}')
5755
Rich Lane7dcdf022013-12-11 14:45:27 -08005756error_msg.subtypes[7] = port_mod_failed_error_msg
5757
5758class port_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07005759 version = 2
5760 type = 19
5761 stats_type = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07005762
5763 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005764 if xid != None:
5765 self.xid = xid
5766 else:
5767 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005768 if flags != None:
5769 self.flags = flags
5770 else:
5771 self.flags = 0
5772 if entries != None:
5773 self.entries = entries
5774 else:
5775 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08005776 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005777
5778 def pack(self):
5779 packed = []
5780 packed.append(struct.pack("!B", self.version))
5781 packed.append(struct.pack("!B", self.type))
5782 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5783 packed.append(struct.pack("!L", self.xid))
5784 packed.append(struct.pack("!H", self.stats_type))
5785 packed.append(struct.pack("!H", self.flags))
5786 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08005787 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005788 length = sum([len(x) for x in packed])
5789 packed[2] = struct.pack("!H", length)
5790 return ''.join(packed)
5791
5792 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005793 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005794 obj = port_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07005795 _version = reader.read("!B")[0]
5796 assert(_version == 2)
5797 _type = reader.read("!B")[0]
5798 assert(_type == 19)
5799 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005800 orig_reader = reader
5801 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005802 obj.xid = reader.read("!L")[0]
5803 _stats_type = reader.read("!H")[0]
5804 assert(_stats_type == 4)
5805 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005806 reader.skip(4)
5807 obj.entries = loxi.generic_util.unpack_list(reader, common.port_stats_entry.unpack)
5808 return obj
5809
5810 def __eq__(self, other):
5811 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005812 if self.xid != other.xid: return False
5813 if self.flags != other.flags: return False
5814 if self.entries != other.entries: return False
5815 return True
5816
Rich Lanec2ee4b82013-04-24 17:12:38 -07005817 def pretty_print(self, q):
5818 q.text("port_stats_reply {")
5819 with q.group():
5820 with q.indent(2):
5821 q.breakable()
5822 q.text("xid = ");
5823 if self.xid != None:
5824 q.text("%#x" % self.xid)
5825 else:
5826 q.text('None')
5827 q.text(","); q.breakable()
5828 q.text("flags = ");
5829 q.text("%#x" % self.flags)
5830 q.text(","); q.breakable()
5831 q.text("entries = ");
5832 q.pp(self.entries)
5833 q.breakable()
5834 q.text('}')
5835
Rich Lane7dcdf022013-12-11 14:45:27 -08005836stats_reply.subtypes[4] = port_stats_reply
5837
5838class port_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07005839 version = 2
5840 type = 18
5841 stats_type = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07005842
5843 def __init__(self, xid=None, flags=None, port_no=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005844 if xid != None:
5845 self.xid = xid
5846 else:
5847 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005848 if flags != None:
5849 self.flags = flags
5850 else:
5851 self.flags = 0
5852 if port_no != None:
5853 self.port_no = port_no
5854 else:
5855 self.port_no = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08005856 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005857
5858 def pack(self):
5859 packed = []
5860 packed.append(struct.pack("!B", self.version))
5861 packed.append(struct.pack("!B", self.type))
5862 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5863 packed.append(struct.pack("!L", self.xid))
5864 packed.append(struct.pack("!H", self.stats_type))
5865 packed.append(struct.pack("!H", self.flags))
5866 packed.append('\x00' * 4)
Dan Talaycof6202252013-07-02 01:00:29 -07005867 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005868 packed.append('\x00' * 4)
5869 length = sum([len(x) for x in packed])
5870 packed[2] = struct.pack("!H", length)
5871 return ''.join(packed)
5872
5873 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005874 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005875 obj = port_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07005876 _version = reader.read("!B")[0]
5877 assert(_version == 2)
5878 _type = reader.read("!B")[0]
5879 assert(_type == 18)
5880 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005881 orig_reader = reader
5882 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005883 obj.xid = reader.read("!L")[0]
5884 _stats_type = reader.read("!H")[0]
5885 assert(_stats_type == 4)
5886 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005887 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07005888 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07005889 reader.skip(4)
5890 return obj
5891
5892 def __eq__(self, other):
5893 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005894 if self.xid != other.xid: return False
5895 if self.flags != other.flags: return False
5896 if self.port_no != other.port_no: return False
5897 return True
5898
Rich Lanec2ee4b82013-04-24 17:12:38 -07005899 def pretty_print(self, q):
5900 q.text("port_stats_request {")
5901 with q.group():
5902 with q.indent(2):
5903 q.breakable()
5904 q.text("xid = ");
5905 if self.xid != None:
5906 q.text("%#x" % self.xid)
5907 else:
5908 q.text('None')
5909 q.text(","); q.breakable()
5910 q.text("flags = ");
5911 q.text("%#x" % self.flags)
5912 q.text(","); q.breakable()
5913 q.text("port_no = ");
5914 q.text(util.pretty_port(self.port_no))
5915 q.breakable()
5916 q.text('}')
5917
Rich Lane7dcdf022013-12-11 14:45:27 -08005918stats_request.subtypes[4] = port_stats_request
5919
5920class port_status(message):
Dan Talaycof6202252013-07-02 01:00:29 -07005921 version = 2
5922 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -07005923
5924 def __init__(self, xid=None, reason=None, desc=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005925 if xid != None:
5926 self.xid = xid
5927 else:
5928 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005929 if reason != None:
5930 self.reason = reason
5931 else:
5932 self.reason = 0
5933 if desc != None:
5934 self.desc = desc
5935 else:
5936 self.desc = common.port_desc()
Rich Lane7dcdf022013-12-11 14:45:27 -08005937 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005938
5939 def pack(self):
5940 packed = []
5941 packed.append(struct.pack("!B", self.version))
5942 packed.append(struct.pack("!B", self.type))
5943 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5944 packed.append(struct.pack("!L", self.xid))
5945 packed.append(struct.pack("!B", self.reason))
5946 packed.append('\x00' * 7)
5947 packed.append(self.desc.pack())
5948 length = sum([len(x) for x in packed])
5949 packed[2] = struct.pack("!H", length)
5950 return ''.join(packed)
5951
5952 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005953 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005954 obj = port_status()
Dan Talaycof6202252013-07-02 01:00:29 -07005955 _version = reader.read("!B")[0]
5956 assert(_version == 2)
5957 _type = reader.read("!B")[0]
5958 assert(_type == 12)
5959 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005960 orig_reader = reader
5961 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07005962 obj.xid = reader.read("!L")[0]
5963 obj.reason = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005964 reader.skip(7)
5965 obj.desc = common.port_desc.unpack(reader)
5966 return obj
5967
5968 def __eq__(self, other):
5969 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005970 if self.xid != other.xid: return False
5971 if self.reason != other.reason: return False
5972 if self.desc != other.desc: return False
5973 return True
5974
Rich Lanec2ee4b82013-04-24 17:12:38 -07005975 def pretty_print(self, q):
5976 q.text("port_status {")
5977 with q.group():
5978 with q.indent(2):
5979 q.breakable()
5980 q.text("xid = ");
5981 if self.xid != None:
5982 q.text("%#x" % self.xid)
5983 else:
5984 q.text('None')
5985 q.text(","); q.breakable()
5986 q.text("reason = ");
5987 q.text("%#x" % self.reason)
5988 q.text(","); q.breakable()
5989 q.text("desc = ");
5990 q.pp(self.desc)
5991 q.breakable()
5992 q.text('}')
5993
Rich Lane7dcdf022013-12-11 14:45:27 -08005994message.subtypes[12] = port_status
5995
5996class queue_get_config_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -07005997 version = 2
5998 type = 23
Rich Lanec2ee4b82013-04-24 17:12:38 -07005999
6000 def __init__(self, xid=None, port=None, queues=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006001 if xid != None:
6002 self.xid = xid
6003 else:
6004 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006005 if port != None:
6006 self.port = port
6007 else:
6008 self.port = 0
6009 if queues != None:
6010 self.queues = queues
6011 else:
6012 self.queues = []
Rich Lane7dcdf022013-12-11 14:45:27 -08006013 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006014
6015 def pack(self):
6016 packed = []
6017 packed.append(struct.pack("!B", self.version))
6018 packed.append(struct.pack("!B", self.type))
6019 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6020 packed.append(struct.pack("!L", self.xid))
Dan Talaycof6202252013-07-02 01:00:29 -07006021 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006022 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08006023 packed.append(loxi.generic_util.pack_list(self.queues))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006024 length = sum([len(x) for x in packed])
6025 packed[2] = struct.pack("!H", length)
6026 return ''.join(packed)
6027
6028 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006029 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006030 obj = queue_get_config_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07006031 _version = reader.read("!B")[0]
6032 assert(_version == 2)
6033 _type = reader.read("!B")[0]
6034 assert(_type == 23)
6035 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006036 orig_reader = reader
6037 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006038 obj.xid = reader.read("!L")[0]
6039 obj.port = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006040 reader.skip(4)
Rich Lane7dcdf022013-12-11 14:45:27 -08006041 obj.queues = loxi.generic_util.unpack_list(reader, common.packet_queue.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006042 return obj
6043
6044 def __eq__(self, other):
6045 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006046 if self.xid != other.xid: return False
6047 if self.port != other.port: return False
6048 if self.queues != other.queues: return False
6049 return True
6050
Rich Lanec2ee4b82013-04-24 17:12:38 -07006051 def pretty_print(self, q):
6052 q.text("queue_get_config_reply {")
6053 with q.group():
6054 with q.indent(2):
6055 q.breakable()
6056 q.text("xid = ");
6057 if self.xid != None:
6058 q.text("%#x" % self.xid)
6059 else:
6060 q.text('None')
6061 q.text(","); q.breakable()
6062 q.text("port = ");
6063 q.text(util.pretty_port(self.port))
6064 q.text(","); q.breakable()
6065 q.text("queues = ");
6066 q.pp(self.queues)
6067 q.breakable()
6068 q.text('}')
6069
Rich Lane7dcdf022013-12-11 14:45:27 -08006070message.subtypes[23] = queue_get_config_reply
6071
6072class queue_get_config_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -07006073 version = 2
6074 type = 22
Rich Lanec2ee4b82013-04-24 17:12:38 -07006075
6076 def __init__(self, xid=None, port=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006077 if xid != None:
6078 self.xid = xid
6079 else:
6080 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006081 if port != None:
6082 self.port = port
6083 else:
6084 self.port = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08006085 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006086
6087 def pack(self):
6088 packed = []
6089 packed.append(struct.pack("!B", self.version))
6090 packed.append(struct.pack("!B", self.type))
6091 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6092 packed.append(struct.pack("!L", self.xid))
Dan Talaycof6202252013-07-02 01:00:29 -07006093 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006094 packed.append('\x00' * 4)
6095 length = sum([len(x) for x in packed])
6096 packed[2] = struct.pack("!H", length)
6097 return ''.join(packed)
6098
6099 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006100 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006101 obj = queue_get_config_request()
Dan Talaycof6202252013-07-02 01:00:29 -07006102 _version = reader.read("!B")[0]
6103 assert(_version == 2)
6104 _type = reader.read("!B")[0]
6105 assert(_type == 22)
6106 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006107 orig_reader = reader
6108 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006109 obj.xid = reader.read("!L")[0]
6110 obj.port = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006111 reader.skip(4)
6112 return obj
6113
6114 def __eq__(self, other):
6115 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006116 if self.xid != other.xid: return False
6117 if self.port != other.port: return False
6118 return True
6119
Rich Lanec2ee4b82013-04-24 17:12:38 -07006120 def pretty_print(self, q):
6121 q.text("queue_get_config_request {")
6122 with q.group():
6123 with q.indent(2):
6124 q.breakable()
6125 q.text("xid = ");
6126 if self.xid != None:
6127 q.text("%#x" % self.xid)
6128 else:
6129 q.text('None')
6130 q.text(","); q.breakable()
6131 q.text("port = ");
6132 q.text(util.pretty_port(self.port))
6133 q.breakable()
6134 q.text('}')
6135
Rich Lane7dcdf022013-12-11 14:45:27 -08006136message.subtypes[22] = queue_get_config_request
6137
6138class queue_op_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07006139 version = 2
6140 type = 1
6141 err_type = 9
6142
6143 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006144 if xid != None:
6145 self.xid = xid
6146 else:
6147 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07006148 if code != None:
6149 self.code = code
6150 else:
6151 self.code = 0
6152 if data != None:
6153 self.data = data
6154 else:
6155 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08006156 return
Rich Lane6f4978c2013-10-20 21:33:52 -07006157
6158 def pack(self):
6159 packed = []
6160 packed.append(struct.pack("!B", self.version))
6161 packed.append(struct.pack("!B", self.type))
6162 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6163 packed.append(struct.pack("!L", self.xid))
6164 packed.append(struct.pack("!H", self.err_type))
6165 packed.append(struct.pack("!H", self.code))
6166 packed.append(self.data)
6167 length = sum([len(x) for x in packed])
6168 packed[2] = struct.pack("!H", length)
6169 return ''.join(packed)
6170
6171 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006172 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07006173 obj = queue_op_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07006174 _version = reader.read("!B")[0]
6175 assert(_version == 2)
6176 _type = reader.read("!B")[0]
6177 assert(_type == 1)
6178 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006179 orig_reader = reader
6180 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07006181 obj.xid = reader.read("!L")[0]
6182 _err_type = reader.read("!H")[0]
6183 assert(_err_type == 9)
6184 obj.code = reader.read("!H")[0]
6185 obj.data = str(reader.read_all())
6186 return obj
6187
6188 def __eq__(self, other):
6189 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07006190 if self.xid != other.xid: return False
6191 if self.code != other.code: return False
6192 if self.data != other.data: return False
6193 return True
6194
Rich Lane6f4978c2013-10-20 21:33:52 -07006195 def pretty_print(self, q):
6196 q.text("queue_op_failed_error_msg {")
6197 with q.group():
6198 with q.indent(2):
6199 q.breakable()
6200 q.text("xid = ");
6201 if self.xid != None:
6202 q.text("%#x" % self.xid)
6203 else:
6204 q.text('None')
6205 q.text(","); q.breakable()
6206 q.text("code = ");
6207 q.text("%#x" % self.code)
6208 q.text(","); q.breakable()
6209 q.text("data = ");
6210 q.pp(self.data)
6211 q.breakable()
6212 q.text('}')
6213
Rich Lane7dcdf022013-12-11 14:45:27 -08006214error_msg.subtypes[9] = queue_op_failed_error_msg
6215
6216class queue_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07006217 version = 2
6218 type = 19
6219 stats_type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07006220
6221 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006222 if xid != None:
6223 self.xid = xid
6224 else:
6225 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006226 if flags != None:
6227 self.flags = flags
6228 else:
6229 self.flags = 0
6230 if entries != None:
6231 self.entries = entries
6232 else:
6233 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08006234 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006235
6236 def pack(self):
6237 packed = []
6238 packed.append(struct.pack("!B", self.version))
6239 packed.append(struct.pack("!B", self.type))
6240 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6241 packed.append(struct.pack("!L", self.xid))
6242 packed.append(struct.pack("!H", self.stats_type))
6243 packed.append(struct.pack("!H", self.flags))
6244 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08006245 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006246 length = sum([len(x) for x in packed])
6247 packed[2] = struct.pack("!H", length)
6248 return ''.join(packed)
6249
6250 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006251 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006252 obj = queue_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07006253 _version = reader.read("!B")[0]
6254 assert(_version == 2)
6255 _type = reader.read("!B")[0]
6256 assert(_type == 19)
6257 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006258 orig_reader = reader
6259 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006260 obj.xid = reader.read("!L")[0]
6261 _stats_type = reader.read("!H")[0]
6262 assert(_stats_type == 5)
6263 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006264 reader.skip(4)
6265 obj.entries = loxi.generic_util.unpack_list(reader, common.queue_stats_entry.unpack)
6266 return obj
6267
6268 def __eq__(self, other):
6269 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006270 if self.xid != other.xid: return False
6271 if self.flags != other.flags: return False
6272 if self.entries != other.entries: return False
6273 return True
6274
Rich Lanec2ee4b82013-04-24 17:12:38 -07006275 def pretty_print(self, q):
6276 q.text("queue_stats_reply {")
6277 with q.group():
6278 with q.indent(2):
6279 q.breakable()
6280 q.text("xid = ");
6281 if self.xid != None:
6282 q.text("%#x" % self.xid)
6283 else:
6284 q.text('None')
6285 q.text(","); q.breakable()
6286 q.text("flags = ");
6287 q.text("%#x" % self.flags)
6288 q.text(","); q.breakable()
6289 q.text("entries = ");
6290 q.pp(self.entries)
6291 q.breakable()
6292 q.text('}')
6293
Rich Lane7dcdf022013-12-11 14:45:27 -08006294stats_reply.subtypes[5] = queue_stats_reply
6295
6296class queue_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07006297 version = 2
6298 type = 18
6299 stats_type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07006300
6301 def __init__(self, xid=None, flags=None, port_no=None, queue_id=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006302 if xid != None:
6303 self.xid = xid
6304 else:
6305 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006306 if flags != None:
6307 self.flags = flags
6308 else:
6309 self.flags = 0
6310 if port_no != None:
6311 self.port_no = port_no
6312 else:
6313 self.port_no = 0
6314 if queue_id != None:
6315 self.queue_id = queue_id
6316 else:
6317 self.queue_id = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08006318 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006319
6320 def pack(self):
6321 packed = []
6322 packed.append(struct.pack("!B", self.version))
6323 packed.append(struct.pack("!B", self.type))
6324 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6325 packed.append(struct.pack("!L", self.xid))
6326 packed.append(struct.pack("!H", self.stats_type))
6327 packed.append(struct.pack("!H", self.flags))
6328 packed.append('\x00' * 4)
Dan Talaycof6202252013-07-02 01:00:29 -07006329 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006330 packed.append(struct.pack("!L", self.queue_id))
6331 length = sum([len(x) for x in packed])
6332 packed[2] = struct.pack("!H", length)
6333 return ''.join(packed)
6334
6335 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006336 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006337 obj = queue_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07006338 _version = reader.read("!B")[0]
6339 assert(_version == 2)
6340 _type = reader.read("!B")[0]
6341 assert(_type == 18)
6342 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006343 orig_reader = reader
6344 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006345 obj.xid = reader.read("!L")[0]
6346 _stats_type = reader.read("!H")[0]
6347 assert(_stats_type == 5)
6348 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006349 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07006350 obj.port_no = util.unpack_port_no(reader)
6351 obj.queue_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006352 return obj
6353
6354 def __eq__(self, other):
6355 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006356 if self.xid != other.xid: return False
6357 if self.flags != other.flags: return False
6358 if self.port_no != other.port_no: return False
6359 if self.queue_id != other.queue_id: return False
6360 return True
6361
Rich Lanec2ee4b82013-04-24 17:12:38 -07006362 def pretty_print(self, q):
6363 q.text("queue_stats_request {")
6364 with q.group():
6365 with q.indent(2):
6366 q.breakable()
6367 q.text("xid = ");
6368 if self.xid != None:
6369 q.text("%#x" % self.xid)
6370 else:
6371 q.text('None')
6372 q.text(","); q.breakable()
6373 q.text("flags = ");
6374 q.text("%#x" % self.flags)
6375 q.text(","); q.breakable()
6376 q.text("port_no = ");
6377 q.text(util.pretty_port(self.port_no))
6378 q.text(","); q.breakable()
6379 q.text("queue_id = ");
6380 q.text("%#x" % self.queue_id)
6381 q.breakable()
6382 q.text('}')
6383
Rich Lane7dcdf022013-12-11 14:45:27 -08006384stats_request.subtypes[5] = queue_stats_request
6385
6386class set_config(message):
Dan Talaycof6202252013-07-02 01:00:29 -07006387 version = 2
6388 type = 9
Rich Lanec2ee4b82013-04-24 17:12:38 -07006389
6390 def __init__(self, xid=None, flags=None, miss_send_len=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006391 if xid != None:
6392 self.xid = xid
6393 else:
6394 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006395 if flags != None:
6396 self.flags = flags
6397 else:
6398 self.flags = 0
6399 if miss_send_len != None:
6400 self.miss_send_len = miss_send_len
6401 else:
6402 self.miss_send_len = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08006403 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006404
6405 def pack(self):
6406 packed = []
6407 packed.append(struct.pack("!B", self.version))
6408 packed.append(struct.pack("!B", self.type))
6409 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6410 packed.append(struct.pack("!L", self.xid))
6411 packed.append(struct.pack("!H", self.flags))
6412 packed.append(struct.pack("!H", self.miss_send_len))
6413 length = sum([len(x) for x in packed])
6414 packed[2] = struct.pack("!H", length)
6415 return ''.join(packed)
6416
6417 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006418 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006419 obj = set_config()
Dan Talaycof6202252013-07-02 01:00:29 -07006420 _version = reader.read("!B")[0]
6421 assert(_version == 2)
6422 _type = reader.read("!B")[0]
6423 assert(_type == 9)
6424 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006425 orig_reader = reader
6426 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006427 obj.xid = reader.read("!L")[0]
6428 obj.flags = reader.read("!H")[0]
6429 obj.miss_send_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006430 return obj
6431
6432 def __eq__(self, other):
6433 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006434 if self.xid != other.xid: return False
6435 if self.flags != other.flags: return False
6436 if self.miss_send_len != other.miss_send_len: return False
6437 return True
6438
Rich Lanec2ee4b82013-04-24 17:12:38 -07006439 def pretty_print(self, q):
6440 q.text("set_config {")
6441 with q.group():
6442 with q.indent(2):
6443 q.breakable()
6444 q.text("xid = ");
6445 if self.xid != None:
6446 q.text("%#x" % self.xid)
6447 else:
6448 q.text('None')
6449 q.text(","); q.breakable()
6450 q.text("flags = ");
6451 q.text("%#x" % self.flags)
6452 q.text(","); q.breakable()
6453 q.text("miss_send_len = ");
6454 q.text("%#x" % self.miss_send_len)
6455 q.breakable()
6456 q.text('}')
6457
Rich Lane7dcdf022013-12-11 14:45:27 -08006458message.subtypes[9] = set_config
6459
6460class switch_config_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07006461 version = 2
6462 type = 1
6463 err_type = 10
6464
6465 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006466 if xid != None:
6467 self.xid = xid
6468 else:
6469 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07006470 if code != None:
6471 self.code = code
6472 else:
6473 self.code = 0
6474 if data != None:
6475 self.data = data
6476 else:
6477 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08006478 return
Rich Lane6f4978c2013-10-20 21:33:52 -07006479
6480 def pack(self):
6481 packed = []
6482 packed.append(struct.pack("!B", self.version))
6483 packed.append(struct.pack("!B", self.type))
6484 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6485 packed.append(struct.pack("!L", self.xid))
6486 packed.append(struct.pack("!H", self.err_type))
6487 packed.append(struct.pack("!H", self.code))
6488 packed.append(self.data)
6489 length = sum([len(x) for x in packed])
6490 packed[2] = struct.pack("!H", length)
6491 return ''.join(packed)
6492
6493 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006494 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07006495 obj = switch_config_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07006496 _version = reader.read("!B")[0]
6497 assert(_version == 2)
6498 _type = reader.read("!B")[0]
6499 assert(_type == 1)
6500 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006501 orig_reader = reader
6502 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07006503 obj.xid = reader.read("!L")[0]
6504 _err_type = reader.read("!H")[0]
6505 assert(_err_type == 10)
6506 obj.code = reader.read("!H")[0]
6507 obj.data = str(reader.read_all())
6508 return obj
6509
6510 def __eq__(self, other):
6511 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07006512 if self.xid != other.xid: return False
6513 if self.code != other.code: return False
6514 if self.data != other.data: return False
6515 return True
6516
Rich Lane6f4978c2013-10-20 21:33:52 -07006517 def pretty_print(self, q):
6518 q.text("switch_config_failed_error_msg {")
6519 with q.group():
6520 with q.indent(2):
6521 q.breakable()
6522 q.text("xid = ");
6523 if self.xid != None:
6524 q.text("%#x" % self.xid)
6525 else:
6526 q.text('None')
6527 q.text(","); q.breakable()
6528 q.text("code = ");
6529 q.text("%#x" % self.code)
6530 q.text(","); q.breakable()
6531 q.text("data = ");
6532 q.pp(self.data)
6533 q.breakable()
6534 q.text('}')
6535
Rich Lane7dcdf022013-12-11 14:45:27 -08006536error_msg.subtypes[10] = switch_config_failed_error_msg
6537
6538class table_mod(message):
Dan Talaycof6202252013-07-02 01:00:29 -07006539 version = 2
6540 type = 17
Rich Lanec2ee4b82013-04-24 17:12:38 -07006541
6542 def __init__(self, xid=None, table_id=None, config=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006543 if xid != None:
6544 self.xid = xid
6545 else:
6546 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006547 if table_id != None:
6548 self.table_id = table_id
6549 else:
6550 self.table_id = 0
6551 if config != None:
6552 self.config = config
6553 else:
6554 self.config = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08006555 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006556
6557 def pack(self):
6558 packed = []
6559 packed.append(struct.pack("!B", self.version))
6560 packed.append(struct.pack("!B", self.type))
6561 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6562 packed.append(struct.pack("!L", self.xid))
6563 packed.append(struct.pack("!B", self.table_id))
6564 packed.append('\x00' * 3)
6565 packed.append(struct.pack("!L", self.config))
6566 length = sum([len(x) for x in packed])
6567 packed[2] = struct.pack("!H", length)
6568 return ''.join(packed)
6569
6570 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006571 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006572 obj = table_mod()
Dan Talaycof6202252013-07-02 01:00:29 -07006573 _version = reader.read("!B")[0]
6574 assert(_version == 2)
6575 _type = reader.read("!B")[0]
6576 assert(_type == 17)
6577 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006578 orig_reader = reader
6579 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006580 obj.xid = reader.read("!L")[0]
6581 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006582 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07006583 obj.config = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006584 return obj
6585
6586 def __eq__(self, other):
6587 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006588 if self.xid != other.xid: return False
6589 if self.table_id != other.table_id: return False
6590 if self.config != other.config: return False
6591 return True
6592
Rich Lanec2ee4b82013-04-24 17:12:38 -07006593 def pretty_print(self, q):
6594 q.text("table_mod {")
6595 with q.group():
6596 with q.indent(2):
6597 q.breakable()
6598 q.text("xid = ");
6599 if self.xid != None:
6600 q.text("%#x" % self.xid)
6601 else:
6602 q.text('None')
6603 q.text(","); q.breakable()
6604 q.text("table_id = ");
6605 q.text("%#x" % self.table_id)
6606 q.text(","); q.breakable()
6607 q.text("config = ");
6608 q.text("%#x" % self.config)
6609 q.breakable()
6610 q.text('}')
6611
Rich Lane7dcdf022013-12-11 14:45:27 -08006612message.subtypes[17] = table_mod
6613
6614class table_mod_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07006615 version = 2
6616 type = 1
6617 err_type = 8
6618
6619 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006620 if xid != None:
6621 self.xid = xid
6622 else:
6623 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07006624 if code != None:
6625 self.code = code
6626 else:
6627 self.code = 0
6628 if data != None:
6629 self.data = data
6630 else:
6631 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08006632 return
Rich Lane6f4978c2013-10-20 21:33:52 -07006633
6634 def pack(self):
6635 packed = []
6636 packed.append(struct.pack("!B", self.version))
6637 packed.append(struct.pack("!B", self.type))
6638 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6639 packed.append(struct.pack("!L", self.xid))
6640 packed.append(struct.pack("!H", self.err_type))
6641 packed.append(struct.pack("!H", self.code))
6642 packed.append(self.data)
6643 length = sum([len(x) for x in packed])
6644 packed[2] = struct.pack("!H", length)
6645 return ''.join(packed)
6646
6647 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006648 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07006649 obj = table_mod_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07006650 _version = reader.read("!B")[0]
6651 assert(_version == 2)
6652 _type = reader.read("!B")[0]
6653 assert(_type == 1)
6654 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006655 orig_reader = reader
6656 reader = orig_reader.slice(_length - (2 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07006657 obj.xid = reader.read("!L")[0]
6658 _err_type = reader.read("!H")[0]
6659 assert(_err_type == 8)
6660 obj.code = reader.read("!H")[0]
6661 obj.data = str(reader.read_all())
6662 return obj
6663
6664 def __eq__(self, other):
6665 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07006666 if self.xid != other.xid: return False
6667 if self.code != other.code: return False
6668 if self.data != other.data: return False
6669 return True
6670
Rich Lane6f4978c2013-10-20 21:33:52 -07006671 def pretty_print(self, q):
6672 q.text("table_mod_failed_error_msg {")
6673 with q.group():
6674 with q.indent(2):
6675 q.breakable()
6676 q.text("xid = ");
6677 if self.xid != None:
6678 q.text("%#x" % self.xid)
6679 else:
6680 q.text('None')
6681 q.text(","); q.breakable()
6682 q.text("code = ");
6683 q.text("%#x" % self.code)
6684 q.text(","); q.breakable()
6685 q.text("data = ");
6686 q.pp(self.data)
6687 q.breakable()
6688 q.text('}')
6689
Rich Lane7dcdf022013-12-11 14:45:27 -08006690error_msg.subtypes[8] = table_mod_failed_error_msg
6691
6692class table_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07006693 version = 2
6694 type = 19
6695 stats_type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07006696
6697 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006698 if xid != None:
6699 self.xid = xid
6700 else:
6701 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006702 if flags != None:
6703 self.flags = flags
6704 else:
6705 self.flags = 0
6706 if entries != None:
6707 self.entries = entries
6708 else:
6709 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08006710 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006711
6712 def pack(self):
6713 packed = []
6714 packed.append(struct.pack("!B", self.version))
6715 packed.append(struct.pack("!B", self.type))
6716 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6717 packed.append(struct.pack("!L", self.xid))
6718 packed.append(struct.pack("!H", self.stats_type))
6719 packed.append(struct.pack("!H", self.flags))
6720 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08006721 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006722 length = sum([len(x) for x in packed])
6723 packed[2] = struct.pack("!H", length)
6724 return ''.join(packed)
6725
6726 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006727 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006728 obj = table_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07006729 _version = reader.read("!B")[0]
6730 assert(_version == 2)
6731 _type = reader.read("!B")[0]
6732 assert(_type == 19)
6733 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006734 orig_reader = reader
6735 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006736 obj.xid = reader.read("!L")[0]
6737 _stats_type = reader.read("!H")[0]
6738 assert(_stats_type == 3)
6739 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006740 reader.skip(4)
6741 obj.entries = loxi.generic_util.unpack_list(reader, common.table_stats_entry.unpack)
6742 return obj
6743
6744 def __eq__(self, other):
6745 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006746 if self.xid != other.xid: return False
6747 if self.flags != other.flags: return False
6748 if self.entries != other.entries: return False
6749 return True
6750
Rich Lanec2ee4b82013-04-24 17:12:38 -07006751 def pretty_print(self, q):
6752 q.text("table_stats_reply {")
6753 with q.group():
6754 with q.indent(2):
6755 q.breakable()
6756 q.text("xid = ");
6757 if self.xid != None:
6758 q.text("%#x" % self.xid)
6759 else:
6760 q.text('None')
6761 q.text(","); q.breakable()
6762 q.text("flags = ");
6763 q.text("%#x" % self.flags)
6764 q.text(","); q.breakable()
6765 q.text("entries = ");
6766 q.pp(self.entries)
6767 q.breakable()
6768 q.text('}')
6769
Rich Lane7dcdf022013-12-11 14:45:27 -08006770stats_reply.subtypes[3] = table_stats_reply
6771
6772class table_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07006773 version = 2
6774 type = 18
6775 stats_type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07006776
6777 def __init__(self, xid=None, flags=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006778 if xid != None:
6779 self.xid = xid
6780 else:
6781 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006782 if flags != None:
6783 self.flags = flags
6784 else:
6785 self.flags = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08006786 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006787
6788 def pack(self):
6789 packed = []
6790 packed.append(struct.pack("!B", self.version))
6791 packed.append(struct.pack("!B", self.type))
6792 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6793 packed.append(struct.pack("!L", self.xid))
6794 packed.append(struct.pack("!H", self.stats_type))
6795 packed.append(struct.pack("!H", self.flags))
6796 packed.append('\x00' * 4)
6797 length = sum([len(x) for x in packed])
6798 packed[2] = struct.pack("!H", length)
6799 return ''.join(packed)
6800
6801 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006802 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006803 obj = table_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07006804 _version = reader.read("!B")[0]
6805 assert(_version == 2)
6806 _type = reader.read("!B")[0]
6807 assert(_type == 18)
6808 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006809 orig_reader = reader
6810 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07006811 obj.xid = reader.read("!L")[0]
6812 _stats_type = reader.read("!H")[0]
6813 assert(_stats_type == 3)
6814 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006815 reader.skip(4)
6816 return obj
6817
6818 def __eq__(self, other):
6819 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006820 if self.xid != other.xid: return False
6821 if self.flags != other.flags: return False
6822 return True
6823
Rich Lanec2ee4b82013-04-24 17:12:38 -07006824 def pretty_print(self, q):
6825 q.text("table_stats_request {")
6826 with q.group():
6827 with q.indent(2):
6828 q.breakable()
6829 q.text("xid = ");
6830 if self.xid != None:
6831 q.text("%#x" % self.xid)
6832 else:
6833 q.text('None')
6834 q.text(","); q.breakable()
6835 q.text("flags = ");
6836 q.text("%#x" % self.flags)
6837 q.breakable()
6838 q.text('}')
6839
Rich Lane7dcdf022013-12-11 14:45:27 -08006840stats_request.subtypes[3] = table_stats_request
6841
Rich Lanec2ee4b82013-04-24 17:12:38 -07006842
6843def parse_header(buf):
6844 if len(buf) < 8:
6845 raise loxi.ProtocolError("too short to be an OpenFlow message")
6846 return struct.unpack_from("!BBHL", buf)
6847
6848def parse_message(buf):
6849 msg_ver, msg_type, msg_len, msg_xid = parse_header(buf)
Rich Lanefe600f52013-07-09 13:22:32 -07006850 if msg_ver != const.OFP_VERSION and msg_type != const.OFPT_HELLO:
6851 raise loxi.ProtocolError("wrong OpenFlow version (expected %d, got %d)" % (const.OFP_VERSION, msg_ver))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006852 if len(buf) != msg_len:
6853 raise loxi.ProtocolError("incorrect message size")
Rich Lane7dcdf022013-12-11 14:45:27 -08006854 return message.unpack(loxi.generic_util.OFReader(buf))