blob: 77ab08089f9a6901906017eb480a399b5d1138b4 [file] [log] [blame]
Matteo Scandoloa229eca2017-08-08 13:05:28 -07001
2# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
Rich Lanec2ee4b82013-04-24 17:12:38 -070017# Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
18# Copyright (c) 2011, 2012 Open Networking Foundation
19# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
Dan Talaycof6202252013-07-02 01:00:29 -070020# See the file LICENSE.pyloxi which should have been included in the source distribution
Rich Lanec2ee4b82013-04-24 17:12:38 -070021
Rich Lane7dcdf022013-12-11 14:45:27 -080022# Automatically generated by LOXI from template module.py
Rich Lanec2ee4b82013-04-24 17:12:38 -070023# Do not modify
24
25import struct
26import loxi
Rich Lanec2ee4b82013-04-24 17:12:38 -070027import util
28import loxi.generic_util
29
Rich Lanee2567702015-01-26 15:04:35 -080030import sys
31ofp = sys.modules['loxi.of11']
32
Rich Lane7dcdf022013-12-11 14:45:27 -080033class message(loxi.OFObject):
34 subtypes = {}
Rich Lanec2ee4b82013-04-24 17:12:38 -070035
Rich Lane95f7fc92014-01-27 17:08:16 -080036 version = 2
37
38 def __init__(self, type=None, xid=None):
39 if type != None:
40 self.type = type
41 else:
42 self.type = 0
43 if xid != None:
44 self.xid = xid
45 else:
46 self.xid = None
47 return
48
49 def pack(self):
50 packed = []
51 packed.append(struct.pack("!B", self.version))
52 packed.append(struct.pack("!B", self.type))
53 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
54 packed.append(struct.pack("!L", self.xid))
55 length = sum([len(x) for x in packed])
56 packed[2] = struct.pack("!H", length)
57 return ''.join(packed)
58
Rich Lane7dcdf022013-12-11 14:45:27 -080059 @staticmethod
60 def unpack(reader):
61 subtype, = reader.peek('B', 1)
Rich Lane95f7fc92014-01-27 17:08:16 -080062 subclass = message.subtypes.get(subtype)
63 if subclass:
64 return subclass.unpack(reader)
65
66 obj = message()
67 _version = reader.read("!B")[0]
68 assert(_version == 2)
69 obj.type = reader.read("!B")[0]
70 _length = reader.read("!H")[0]
71 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -080072 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -080073 obj.xid = reader.read("!L")[0]
74 return obj
75
76 def __eq__(self, other):
77 if type(self) != type(other): return False
78 if self.type != other.type: return False
79 if self.xid != other.xid: return False
80 return True
81
82 def pretty_print(self, q):
83 q.text("message {")
84 with q.group():
85 with q.indent(2):
86 q.breakable()
87 q.text("xid = ");
88 if self.xid != None:
89 q.text("%#x" % self.xid)
90 else:
91 q.text('None')
92 q.breakable()
93 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -080094
95
96class stats_reply(message):
97 subtypes = {}
98
Rich Lane95f7fc92014-01-27 17:08:16 -080099 version = 2
100 type = 19
101
102 def __init__(self, xid=None, stats_type=None, flags=None):
103 if xid != None:
104 self.xid = xid
105 else:
106 self.xid = None
107 if stats_type != None:
108 self.stats_type = stats_type
109 else:
110 self.stats_type = 0
111 if flags != None:
112 self.flags = flags
113 else:
114 self.flags = 0
115 return
116
117 def pack(self):
118 packed = []
119 packed.append(struct.pack("!B", self.version))
120 packed.append(struct.pack("!B", self.type))
121 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
122 packed.append(struct.pack("!L", self.xid))
123 packed.append(struct.pack("!H", self.stats_type))
124 packed.append(struct.pack("!H", self.flags))
125 packed.append('\x00' * 4)
126 length = sum([len(x) for x in packed])
127 packed[2] = struct.pack("!H", length)
128 return ''.join(packed)
129
Rich Lane7dcdf022013-12-11 14:45:27 -0800130 @staticmethod
131 def unpack(reader):
132 subtype, = reader.peek('!H', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800133 subclass = stats_reply.subtypes.get(subtype)
134 if subclass:
135 return subclass.unpack(reader)
136
137 obj = stats_reply()
138 _version = reader.read("!B")[0]
139 assert(_version == 2)
140 _type = reader.read("!B")[0]
141 assert(_type == 19)
142 _length = reader.read("!H")[0]
143 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800144 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800145 obj.xid = reader.read("!L")[0]
146 obj.stats_type = reader.read("!H")[0]
147 obj.flags = reader.read("!H")[0]
148 reader.skip(4)
149 return obj
150
151 def __eq__(self, other):
152 if type(self) != type(other): return False
153 if self.xid != other.xid: return False
154 if self.stats_type != other.stats_type: return False
155 if self.flags != other.flags: return False
156 return True
157
158 def pretty_print(self, q):
159 q.text("stats_reply {")
160 with q.group():
161 with q.indent(2):
162 q.breakable()
163 q.text("xid = ");
164 if self.xid != None:
165 q.text("%#x" % self.xid)
166 else:
167 q.text('None')
168 q.text(","); q.breakable()
169 q.text("flags = ");
170 q.text("%#x" % self.flags)
171 q.breakable()
172 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800173
174message.subtypes[19] = stats_reply
175
176class aggregate_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -0700177 version = 2
178 type = 19
179 stats_type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -0700180
181 def __init__(self, xid=None, flags=None, packet_count=None, byte_count=None, flow_count=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800182 if xid != None:
183 self.xid = xid
184 else:
185 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -0700186 if flags != None:
187 self.flags = flags
188 else:
189 self.flags = 0
190 if packet_count != None:
191 self.packet_count = packet_count
192 else:
193 self.packet_count = 0
194 if byte_count != None:
195 self.byte_count = byte_count
196 else:
197 self.byte_count = 0
198 if flow_count != None:
199 self.flow_count = flow_count
200 else:
201 self.flow_count = 0
Rich Lane7dcdf022013-12-11 14:45:27 -0800202 return
Rich Lanec2ee4b82013-04-24 17:12:38 -0700203
204 def pack(self):
205 packed = []
206 packed.append(struct.pack("!B", self.version))
207 packed.append(struct.pack("!B", self.type))
208 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
209 packed.append(struct.pack("!L", self.xid))
210 packed.append(struct.pack("!H", self.stats_type))
211 packed.append(struct.pack("!H", self.flags))
212 packed.append('\x00' * 4)
213 packed.append(struct.pack("!Q", self.packet_count))
214 packed.append(struct.pack("!Q", self.byte_count))
215 packed.append(struct.pack("!L", self.flow_count))
216 packed.append('\x00' * 4)
217 length = sum([len(x) for x in packed])
218 packed[2] = struct.pack("!H", length)
219 return ''.join(packed)
220
221 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800222 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700223 obj = aggregate_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -0700224 _version = reader.read("!B")[0]
225 assert(_version == 2)
226 _type = reader.read("!B")[0]
227 assert(_type == 19)
228 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800229 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800230 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700231 obj.xid = reader.read("!L")[0]
232 _stats_type = reader.read("!H")[0]
233 assert(_stats_type == 2)
234 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700235 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -0700236 obj.packet_count = reader.read("!Q")[0]
237 obj.byte_count = reader.read("!Q")[0]
238 obj.flow_count = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700239 reader.skip(4)
240 return obj
241
242 def __eq__(self, other):
243 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700244 if self.xid != other.xid: return False
245 if self.flags != other.flags: return False
246 if self.packet_count != other.packet_count: return False
247 if self.byte_count != other.byte_count: return False
248 if self.flow_count != other.flow_count: return False
249 return True
250
Rich Lanec2ee4b82013-04-24 17:12:38 -0700251 def pretty_print(self, q):
252 q.text("aggregate_stats_reply {")
253 with q.group():
254 with q.indent(2):
255 q.breakable()
256 q.text("xid = ");
257 if self.xid != None:
258 q.text("%#x" % self.xid)
259 else:
260 q.text('None')
261 q.text(","); q.breakable()
262 q.text("flags = ");
263 q.text("%#x" % self.flags)
264 q.text(","); q.breakable()
265 q.text("packet_count = ");
266 q.text("%#x" % self.packet_count)
267 q.text(","); q.breakable()
268 q.text("byte_count = ");
269 q.text("%#x" % self.byte_count)
270 q.text(","); q.breakable()
271 q.text("flow_count = ");
272 q.text("%#x" % self.flow_count)
273 q.breakable()
274 q.text('}')
275
Rich Lane7dcdf022013-12-11 14:45:27 -0800276stats_reply.subtypes[2] = aggregate_stats_reply
277
278class stats_request(message):
279 subtypes = {}
280
Rich Lane95f7fc92014-01-27 17:08:16 -0800281 version = 2
282 type = 18
283
284 def __init__(self, xid=None, stats_type=None, flags=None):
285 if xid != None:
286 self.xid = xid
287 else:
288 self.xid = None
289 if stats_type != None:
290 self.stats_type = stats_type
291 else:
292 self.stats_type = 0
293 if flags != None:
294 self.flags = flags
295 else:
296 self.flags = 0
297 return
298
299 def pack(self):
300 packed = []
301 packed.append(struct.pack("!B", self.version))
302 packed.append(struct.pack("!B", self.type))
303 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
304 packed.append(struct.pack("!L", self.xid))
305 packed.append(struct.pack("!H", self.stats_type))
306 packed.append(struct.pack("!H", self.flags))
307 packed.append('\x00' * 4)
308 length = sum([len(x) for x in packed])
309 packed[2] = struct.pack("!H", length)
310 return ''.join(packed)
311
Rich Lane7dcdf022013-12-11 14:45:27 -0800312 @staticmethod
313 def unpack(reader):
314 subtype, = reader.peek('!H', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800315 subclass = stats_request.subtypes.get(subtype)
316 if subclass:
317 return subclass.unpack(reader)
318
319 obj = stats_request()
320 _version = reader.read("!B")[0]
321 assert(_version == 2)
322 _type = reader.read("!B")[0]
323 assert(_type == 18)
324 _length = reader.read("!H")[0]
325 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800326 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800327 obj.xid = reader.read("!L")[0]
328 obj.stats_type = reader.read("!H")[0]
329 obj.flags = reader.read("!H")[0]
330 reader.skip(4)
331 return obj
332
333 def __eq__(self, other):
334 if type(self) != type(other): return False
335 if self.xid != other.xid: return False
336 if self.stats_type != other.stats_type: return False
337 if self.flags != other.flags: return False
338 return True
339
340 def pretty_print(self, q):
341 q.text("stats_request {")
342 with q.group():
343 with q.indent(2):
344 q.breakable()
345 q.text("xid = ");
346 if self.xid != None:
347 q.text("%#x" % self.xid)
348 else:
349 q.text('None')
350 q.text(","); q.breakable()
351 q.text("flags = ");
352 q.text("%#x" % self.flags)
353 q.breakable()
354 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800355
356message.subtypes[18] = stats_request
357
358class aggregate_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -0700359 version = 2
360 type = 18
361 stats_type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -0700362
363 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 -0800364 if xid != None:
365 self.xid = xid
366 else:
367 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -0700368 if flags != None:
369 self.flags = flags
370 else:
371 self.flags = 0
372 if table_id != None:
373 self.table_id = table_id
374 else:
375 self.table_id = 0
376 if out_port != None:
377 self.out_port = out_port
378 else:
379 self.out_port = 0
380 if out_group != None:
381 self.out_group = out_group
382 else:
383 self.out_group = 0
384 if cookie != None:
385 self.cookie = cookie
386 else:
387 self.cookie = 0
388 if cookie_mask != None:
389 self.cookie_mask = cookie_mask
390 else:
391 self.cookie_mask = 0
392 if match != None:
393 self.match = match
394 else:
Rich Lanee2567702015-01-26 15:04:35 -0800395 self.match = ofp.match()
Rich Lane7dcdf022013-12-11 14:45:27 -0800396 return
Rich Lanec2ee4b82013-04-24 17:12:38 -0700397
398 def pack(self):
399 packed = []
400 packed.append(struct.pack("!B", self.version))
401 packed.append(struct.pack("!B", self.type))
402 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
403 packed.append(struct.pack("!L", self.xid))
404 packed.append(struct.pack("!H", self.stats_type))
405 packed.append(struct.pack("!H", self.flags))
406 packed.append('\x00' * 4)
407 packed.append(struct.pack("!B", self.table_id))
408 packed.append('\x00' * 3)
Dan Talaycof6202252013-07-02 01:00:29 -0700409 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700410 packed.append(struct.pack("!L", self.out_group))
411 packed.append('\x00' * 4)
412 packed.append(struct.pack("!Q", self.cookie))
413 packed.append(struct.pack("!Q", self.cookie_mask))
414 packed.append(self.match.pack())
415 length = sum([len(x) for x in packed])
416 packed[2] = struct.pack("!H", length)
417 return ''.join(packed)
418
419 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800420 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700421 obj = aggregate_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -0700422 _version = reader.read("!B")[0]
423 assert(_version == 2)
424 _type = reader.read("!B")[0]
425 assert(_type == 18)
426 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800427 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800428 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700429 obj.xid = reader.read("!L")[0]
430 _stats_type = reader.read("!H")[0]
431 assert(_stats_type == 2)
432 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700433 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -0700434 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700435 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -0700436 obj.out_port = util.unpack_port_no(reader)
437 obj.out_group = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700438 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -0700439 obj.cookie = reader.read("!Q")[0]
440 obj.cookie_mask = reader.read("!Q")[0]
Rich Lanee2567702015-01-26 15:04:35 -0800441 obj.match = ofp.match.unpack(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700442 return obj
443
444 def __eq__(self, other):
445 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700446 if self.xid != other.xid: return False
447 if self.flags != other.flags: return False
448 if self.table_id != other.table_id: return False
449 if self.out_port != other.out_port: return False
450 if self.out_group != other.out_group: return False
451 if self.cookie != other.cookie: return False
452 if self.cookie_mask != other.cookie_mask: return False
453 if self.match != other.match: return False
454 return True
455
Rich Lanec2ee4b82013-04-24 17:12:38 -0700456 def pretty_print(self, q):
457 q.text("aggregate_stats_request {")
458 with q.group():
459 with q.indent(2):
460 q.breakable()
461 q.text("xid = ");
462 if self.xid != None:
463 q.text("%#x" % self.xid)
464 else:
465 q.text('None')
466 q.text(","); q.breakable()
467 q.text("flags = ");
468 q.text("%#x" % self.flags)
469 q.text(","); q.breakable()
470 q.text("table_id = ");
471 q.text("%#x" % self.table_id)
472 q.text(","); q.breakable()
473 q.text("out_port = ");
474 q.text(util.pretty_port(self.out_port))
475 q.text(","); q.breakable()
476 q.text("out_group = ");
477 q.text("%#x" % self.out_group)
478 q.text(","); q.breakable()
479 q.text("cookie = ");
480 q.text("%#x" % self.cookie)
481 q.text(","); q.breakable()
482 q.text("cookie_mask = ");
483 q.text("%#x" % self.cookie_mask)
484 q.text(","); q.breakable()
485 q.text("match = ");
486 q.pp(self.match)
487 q.breakable()
488 q.text('}')
489
Rich Lane7dcdf022013-12-11 14:45:27 -0800490stats_request.subtypes[2] = aggregate_stats_request
491
492class error_msg(message):
493 subtypes = {}
494
Rich Lane95f7fc92014-01-27 17:08:16 -0800495 version = 2
496 type = 1
497
498 def __init__(self, xid=None, err_type=None):
499 if xid != None:
500 self.xid = xid
501 else:
502 self.xid = None
503 if err_type != None:
504 self.err_type = err_type
505 else:
506 self.err_type = 0
507 return
508
509 def pack(self):
510 packed = []
511 packed.append(struct.pack("!B", self.version))
512 packed.append(struct.pack("!B", self.type))
513 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
514 packed.append(struct.pack("!L", self.xid))
515 packed.append(struct.pack("!H", self.err_type))
516 length = sum([len(x) for x in packed])
517 packed[2] = struct.pack("!H", length)
518 return ''.join(packed)
519
Rich Lane7dcdf022013-12-11 14:45:27 -0800520 @staticmethod
521 def unpack(reader):
522 subtype, = reader.peek('!H', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800523 subclass = error_msg.subtypes.get(subtype)
524 if subclass:
525 return subclass.unpack(reader)
526
527 obj = error_msg()
528 _version = reader.read("!B")[0]
529 assert(_version == 2)
530 _type = reader.read("!B")[0]
531 assert(_type == 1)
532 _length = reader.read("!H")[0]
533 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800534 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800535 obj.xid = reader.read("!L")[0]
536 obj.err_type = reader.read("!H")[0]
537 return obj
538
539 def __eq__(self, other):
540 if type(self) != type(other): return False
541 if self.xid != other.xid: return False
542 if self.err_type != other.err_type: return False
543 return True
544
545 def pretty_print(self, q):
546 q.text("error_msg {")
547 with q.group():
548 with q.indent(2):
549 q.breakable()
550 q.text("xid = ");
551 if self.xid != None:
552 q.text("%#x" % self.xid)
553 else:
554 q.text('None')
555 q.breakable()
556 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800557
558message.subtypes[1] = error_msg
559
560class bad_action_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -0700561 version = 2
562 type = 1
563 err_type = 2
564
565 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800566 if xid != None:
567 self.xid = xid
568 else:
569 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -0700570 if code != None:
571 self.code = code
572 else:
573 self.code = 0
574 if data != None:
575 self.data = data
576 else:
577 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -0800578 return
Rich Lane6f4978c2013-10-20 21:33:52 -0700579
580 def pack(self):
581 packed = []
582 packed.append(struct.pack("!B", self.version))
583 packed.append(struct.pack("!B", self.type))
584 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
585 packed.append(struct.pack("!L", self.xid))
586 packed.append(struct.pack("!H", self.err_type))
587 packed.append(struct.pack("!H", self.code))
588 packed.append(self.data)
589 length = sum([len(x) for x in packed])
590 packed[2] = struct.pack("!H", length)
591 return ''.join(packed)
592
593 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800594 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -0700595 obj = bad_action_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -0700596 _version = reader.read("!B")[0]
597 assert(_version == 2)
598 _type = reader.read("!B")[0]
599 assert(_type == 1)
600 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800601 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800602 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -0700603 obj.xid = reader.read("!L")[0]
604 _err_type = reader.read("!H")[0]
605 assert(_err_type == 2)
606 obj.code = reader.read("!H")[0]
607 obj.data = str(reader.read_all())
608 return obj
609
610 def __eq__(self, other):
611 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -0700612 if self.xid != other.xid: return False
613 if self.code != other.code: return False
614 if self.data != other.data: return False
615 return True
616
Rich Lane6f4978c2013-10-20 21:33:52 -0700617 def pretty_print(self, q):
618 q.text("bad_action_error_msg {")
619 with q.group():
620 with q.indent(2):
621 q.breakable()
622 q.text("xid = ");
623 if self.xid != None:
624 q.text("%#x" % self.xid)
625 else:
626 q.text('None')
627 q.text(","); q.breakable()
628 q.text("code = ");
629 q.text("%#x" % self.code)
630 q.text(","); q.breakable()
631 q.text("data = ");
632 q.pp(self.data)
633 q.breakable()
634 q.text('}')
635
Rich Lane7dcdf022013-12-11 14:45:27 -0800636error_msg.subtypes[2] = bad_action_error_msg
637
638class bad_instruction_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -0700639 version = 2
640 type = 1
641 err_type = 3
642
643 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800644 if xid != None:
645 self.xid = xid
646 else:
647 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -0700648 if code != None:
649 self.code = code
650 else:
651 self.code = 0
652 if data != None:
653 self.data = data
654 else:
655 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -0800656 return
Rich Lane6f4978c2013-10-20 21:33:52 -0700657
658 def pack(self):
659 packed = []
660 packed.append(struct.pack("!B", self.version))
661 packed.append(struct.pack("!B", self.type))
662 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
663 packed.append(struct.pack("!L", self.xid))
664 packed.append(struct.pack("!H", self.err_type))
665 packed.append(struct.pack("!H", self.code))
666 packed.append(self.data)
667 length = sum([len(x) for x in packed])
668 packed[2] = struct.pack("!H", length)
669 return ''.join(packed)
670
671 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800672 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -0700673 obj = bad_instruction_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -0700674 _version = reader.read("!B")[0]
675 assert(_version == 2)
676 _type = reader.read("!B")[0]
677 assert(_type == 1)
678 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800679 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800680 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -0700681 obj.xid = reader.read("!L")[0]
682 _err_type = reader.read("!H")[0]
683 assert(_err_type == 3)
684 obj.code = reader.read("!H")[0]
685 obj.data = str(reader.read_all())
686 return obj
687
688 def __eq__(self, other):
689 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -0700690 if self.xid != other.xid: return False
691 if self.code != other.code: return False
692 if self.data != other.data: return False
693 return True
694
Rich Lane6f4978c2013-10-20 21:33:52 -0700695 def pretty_print(self, q):
696 q.text("bad_instruction_error_msg {")
697 with q.group():
698 with q.indent(2):
699 q.breakable()
700 q.text("xid = ");
701 if self.xid != None:
702 q.text("%#x" % self.xid)
703 else:
704 q.text('None')
705 q.text(","); q.breakable()
706 q.text("code = ");
707 q.text("%#x" % self.code)
708 q.text(","); q.breakable()
709 q.text("data = ");
710 q.pp(self.data)
711 q.breakable()
712 q.text('}')
713
Rich Lane7dcdf022013-12-11 14:45:27 -0800714error_msg.subtypes[3] = bad_instruction_error_msg
715
716class bad_match_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -0700717 version = 2
718 type = 1
719 err_type = 4
720
721 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800722 if xid != None:
723 self.xid = xid
724 else:
725 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -0700726 if code != None:
727 self.code = code
728 else:
729 self.code = 0
730 if data != None:
731 self.data = data
732 else:
733 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -0800734 return
Rich Lane6f4978c2013-10-20 21:33:52 -0700735
736 def pack(self):
737 packed = []
738 packed.append(struct.pack("!B", self.version))
739 packed.append(struct.pack("!B", self.type))
740 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
741 packed.append(struct.pack("!L", self.xid))
742 packed.append(struct.pack("!H", self.err_type))
743 packed.append(struct.pack("!H", self.code))
744 packed.append(self.data)
745 length = sum([len(x) for x in packed])
746 packed[2] = struct.pack("!H", length)
747 return ''.join(packed)
748
749 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800750 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -0700751 obj = bad_match_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -0700752 _version = reader.read("!B")[0]
753 assert(_version == 2)
754 _type = reader.read("!B")[0]
755 assert(_type == 1)
756 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800757 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800758 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -0700759 obj.xid = reader.read("!L")[0]
760 _err_type = reader.read("!H")[0]
761 assert(_err_type == 4)
762 obj.code = reader.read("!H")[0]
763 obj.data = str(reader.read_all())
764 return obj
765
766 def __eq__(self, other):
767 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -0700768 if self.xid != other.xid: return False
769 if self.code != other.code: return False
770 if self.data != other.data: return False
771 return True
772
Rich Lane6f4978c2013-10-20 21:33:52 -0700773 def pretty_print(self, q):
774 q.text("bad_match_error_msg {")
775 with q.group():
776 with q.indent(2):
777 q.breakable()
778 q.text("xid = ");
779 if self.xid != None:
780 q.text("%#x" % self.xid)
781 else:
782 q.text('None')
783 q.text(","); q.breakable()
784 q.text("code = ");
785 q.text("%#x" % self.code)
786 q.text(","); q.breakable()
787 q.text("data = ");
788 q.pp(self.data)
789 q.breakable()
790 q.text('}')
791
Rich Lane7dcdf022013-12-11 14:45:27 -0800792error_msg.subtypes[4] = bad_match_error_msg
793
794class bad_request_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -0700795 version = 2
796 type = 1
797 err_type = 1
798
799 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800800 if xid != None:
801 self.xid = xid
802 else:
803 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -0700804 if code != None:
805 self.code = code
806 else:
807 self.code = 0
808 if data != None:
809 self.data = data
810 else:
811 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -0800812 return
Rich Lane6f4978c2013-10-20 21:33:52 -0700813
814 def pack(self):
815 packed = []
816 packed.append(struct.pack("!B", self.version))
817 packed.append(struct.pack("!B", self.type))
818 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
819 packed.append(struct.pack("!L", self.xid))
820 packed.append(struct.pack("!H", self.err_type))
821 packed.append(struct.pack("!H", self.code))
822 packed.append(self.data)
823 length = sum([len(x) for x in packed])
824 packed[2] = struct.pack("!H", length)
825 return ''.join(packed)
826
827 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800828 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -0700829 obj = bad_request_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -0700830 _version = reader.read("!B")[0]
831 assert(_version == 2)
832 _type = reader.read("!B")[0]
833 assert(_type == 1)
834 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800835 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800836 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -0700837 obj.xid = reader.read("!L")[0]
838 _err_type = reader.read("!H")[0]
839 assert(_err_type == 1)
840 obj.code = reader.read("!H")[0]
841 obj.data = str(reader.read_all())
842 return obj
843
844 def __eq__(self, other):
845 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -0700846 if self.xid != other.xid: return False
847 if self.code != other.code: return False
848 if self.data != other.data: return False
849 return True
850
Rich Lane6f4978c2013-10-20 21:33:52 -0700851 def pretty_print(self, q):
852 q.text("bad_request_error_msg {")
853 with q.group():
854 with q.indent(2):
855 q.breakable()
856 q.text("xid = ");
857 if self.xid != None:
858 q.text("%#x" % self.xid)
859 else:
860 q.text('None')
861 q.text(","); q.breakable()
862 q.text("code = ");
863 q.text("%#x" % self.code)
864 q.text(","); q.breakable()
865 q.text("data = ");
866 q.pp(self.data)
867 q.breakable()
868 q.text('}')
869
Rich Lane7dcdf022013-12-11 14:45:27 -0800870error_msg.subtypes[1] = bad_request_error_msg
871
872class barrier_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -0700873 version = 2
874 type = 21
Rich Lanec2ee4b82013-04-24 17:12:38 -0700875
876 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800877 if xid != None:
878 self.xid = xid
879 else:
880 self.xid = None
881 return
Rich Lanec2ee4b82013-04-24 17:12:38 -0700882
883 def pack(self):
884 packed = []
885 packed.append(struct.pack("!B", self.version))
886 packed.append(struct.pack("!B", self.type))
887 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
888 packed.append(struct.pack("!L", self.xid))
889 length = sum([len(x) for x in packed])
890 packed[2] = struct.pack("!H", length)
891 return ''.join(packed)
892
893 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800894 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700895 obj = barrier_reply()
Dan Talaycof6202252013-07-02 01:00:29 -0700896 _version = reader.read("!B")[0]
897 assert(_version == 2)
898 _type = reader.read("!B")[0]
899 assert(_type == 21)
900 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800901 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800902 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700903 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700904 return obj
905
906 def __eq__(self, other):
907 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700908 if self.xid != other.xid: return False
909 return True
910
Rich Lanec2ee4b82013-04-24 17:12:38 -0700911 def pretty_print(self, q):
912 q.text("barrier_reply {")
913 with q.group():
914 with q.indent(2):
915 q.breakable()
916 q.text("xid = ");
917 if self.xid != None:
918 q.text("%#x" % self.xid)
919 else:
920 q.text('None')
921 q.breakable()
922 q.text('}')
923
Rich Lane7dcdf022013-12-11 14:45:27 -0800924message.subtypes[21] = barrier_reply
925
926class barrier_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -0700927 version = 2
928 type = 20
Rich Lanec2ee4b82013-04-24 17:12:38 -0700929
930 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -0800931 if xid != None:
932 self.xid = xid
933 else:
934 self.xid = None
935 return
Rich Lanec2ee4b82013-04-24 17:12:38 -0700936
937 def pack(self):
938 packed = []
939 packed.append(struct.pack("!B", self.version))
940 packed.append(struct.pack("!B", self.type))
941 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
942 packed.append(struct.pack("!L", self.xid))
943 length = sum([len(x) for x in packed])
944 packed[2] = struct.pack("!H", length)
945 return ''.join(packed)
946
947 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800948 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700949 obj = barrier_request()
Dan Talaycof6202252013-07-02 01:00:29 -0700950 _version = reader.read("!B")[0]
951 assert(_version == 2)
952 _type = reader.read("!B")[0]
953 assert(_type == 20)
954 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800955 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800956 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700957 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700958 return obj
959
960 def __eq__(self, other):
961 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700962 if self.xid != other.xid: return False
963 return True
964
Rich Lanec2ee4b82013-04-24 17:12:38 -0700965 def pretty_print(self, q):
966 q.text("barrier_request {")
967 with q.group():
968 with q.indent(2):
969 q.breakable()
970 q.text("xid = ");
971 if self.xid != None:
972 q.text("%#x" % self.xid)
973 else:
974 q.text('None')
975 q.breakable()
976 q.text('}')
977
Rich Lane7dcdf022013-12-11 14:45:27 -0800978message.subtypes[20] = barrier_request
979
980class experimenter(message):
981 subtypes = {}
982
Rich Lane95f7fc92014-01-27 17:08:16 -0800983 version = 2
984 type = 4
985
Harshmeet Singhc0378a92014-07-22 17:09:36 -0700986 def __init__(self, xid=None, experimenter=None, data=None):
Rich Lane95f7fc92014-01-27 17:08:16 -0800987 if xid != None:
988 self.xid = xid
989 else:
990 self.xid = None
991 if experimenter != None:
992 self.experimenter = experimenter
993 else:
994 self.experimenter = 0
Rich Lane95f7fc92014-01-27 17:08:16 -0800995 if data != None:
996 self.data = data
997 else:
998 self.data = ''
999 return
1000
1001 def pack(self):
1002 packed = []
1003 packed.append(struct.pack("!B", self.version))
1004 packed.append(struct.pack("!B", self.type))
1005 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1006 packed.append(struct.pack("!L", self.xid))
1007 packed.append(struct.pack("!L", self.experimenter))
Rich Lane95f7fc92014-01-27 17:08:16 -08001008 packed.append(self.data)
1009 length = sum([len(x) for x in packed])
1010 packed[2] = struct.pack("!H", length)
1011 return ''.join(packed)
1012
Rich Lane7dcdf022013-12-11 14:45:27 -08001013 @staticmethod
1014 def unpack(reader):
1015 subtype, = reader.peek('!L', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -08001016 subclass = experimenter.subtypes.get(subtype)
1017 if subclass:
1018 return subclass.unpack(reader)
1019
1020 obj = experimenter()
1021 _version = reader.read("!B")[0]
1022 assert(_version == 2)
1023 _type = reader.read("!B")[0]
1024 assert(_type == 4)
1025 _length = reader.read("!H")[0]
1026 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001027 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -08001028 obj.xid = reader.read("!L")[0]
1029 obj.experimenter = reader.read("!L")[0]
Rich Lane95f7fc92014-01-27 17:08:16 -08001030 obj.data = str(reader.read_all())
1031 return obj
1032
1033 def __eq__(self, other):
1034 if type(self) != type(other): return False
1035 if self.xid != other.xid: return False
1036 if self.experimenter != other.experimenter: return False
Rich Lane95f7fc92014-01-27 17:08:16 -08001037 if self.data != other.data: return False
1038 return True
1039
1040 def pretty_print(self, q):
1041 q.text("experimenter {")
1042 with q.group():
1043 with q.indent(2):
1044 q.breakable()
1045 q.text("xid = ");
1046 if self.xid != None:
1047 q.text("%#x" % self.xid)
1048 else:
1049 q.text('None')
1050 q.text(","); q.breakable()
Rich Lane95f7fc92014-01-27 17:08:16 -08001051 q.text("data = ");
1052 q.pp(self.data)
1053 q.breakable()
1054 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08001055
1056message.subtypes[4] = experimenter
1057
1058class bsn_header(experimenter):
1059 subtypes = {}
1060
Rich Lane95f7fc92014-01-27 17:08:16 -08001061 version = 2
1062 type = 4
1063 experimenter = 6035143
1064
1065 def __init__(self, xid=None, subtype=None):
1066 if xid != None:
1067 self.xid = xid
1068 else:
1069 self.xid = None
1070 if subtype != None:
1071 self.subtype = subtype
1072 else:
1073 self.subtype = 0
1074 return
1075
1076 def pack(self):
1077 packed = []
1078 packed.append(struct.pack("!B", self.version))
1079 packed.append(struct.pack("!B", self.type))
1080 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1081 packed.append(struct.pack("!L", self.xid))
1082 packed.append(struct.pack("!L", self.experimenter))
1083 packed.append(struct.pack("!L", self.subtype))
1084 length = sum([len(x) for x in packed])
1085 packed[2] = struct.pack("!H", length)
1086 return ''.join(packed)
1087
Rich Lane7dcdf022013-12-11 14:45:27 -08001088 @staticmethod
1089 def unpack(reader):
1090 subtype, = reader.peek('!L', 12)
Rich Lane95f7fc92014-01-27 17:08:16 -08001091 subclass = bsn_header.subtypes.get(subtype)
1092 if subclass:
1093 return subclass.unpack(reader)
1094
1095 obj = bsn_header()
1096 _version = reader.read("!B")[0]
1097 assert(_version == 2)
1098 _type = reader.read("!B")[0]
1099 assert(_type == 4)
1100 _length = reader.read("!H")[0]
1101 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001102 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -08001103 obj.xid = reader.read("!L")[0]
1104 _experimenter = reader.read("!L")[0]
1105 assert(_experimenter == 6035143)
1106 obj.subtype = reader.read("!L")[0]
1107 return obj
1108
1109 def __eq__(self, other):
1110 if type(self) != type(other): return False
1111 if self.xid != other.xid: return False
1112 if self.subtype != other.subtype: return False
1113 return True
1114
1115 def pretty_print(self, q):
1116 q.text("bsn_header {")
1117 with q.group():
1118 with q.indent(2):
1119 q.breakable()
1120 q.text("xid = ");
1121 if self.xid != None:
1122 q.text("%#x" % self.xid)
1123 else:
1124 q.text('None')
1125 q.breakable()
1126 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08001127
1128experimenter.subtypes[6035143] = bsn_header
1129
1130class bsn_bw_clear_data_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001131 version = 2
1132 type = 4
1133 experimenter = 6035143
1134 subtype = 22
1135
1136 def __init__(self, xid=None, status=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001137 if xid != None:
1138 self.xid = xid
1139 else:
1140 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07001141 if status != None:
1142 self.status = status
1143 else:
1144 self.status = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001145 return
Dan Talaycof6202252013-07-02 01:00:29 -07001146
1147 def pack(self):
1148 packed = []
1149 packed.append(struct.pack("!B", self.version))
1150 packed.append(struct.pack("!B", self.type))
1151 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1152 packed.append(struct.pack("!L", self.xid))
1153 packed.append(struct.pack("!L", self.experimenter))
1154 packed.append(struct.pack("!L", self.subtype))
1155 packed.append(struct.pack("!L", self.status))
1156 length = sum([len(x) for x in packed])
1157 packed[2] = struct.pack("!H", length)
1158 return ''.join(packed)
1159
1160 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001161 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001162 obj = bsn_bw_clear_data_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07001163 _version = reader.read("!B")[0]
1164 assert(_version == 2)
1165 _type = reader.read("!B")[0]
1166 assert(_type == 4)
1167 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001168 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001169 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001170 obj.xid = reader.read("!L")[0]
1171 _experimenter = reader.read("!L")[0]
1172 assert(_experimenter == 6035143)
1173 _subtype = reader.read("!L")[0]
1174 assert(_subtype == 22)
1175 obj.status = reader.read("!L")[0]
1176 return obj
1177
1178 def __eq__(self, other):
1179 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07001180 if self.xid != other.xid: return False
1181 if self.status != other.status: return False
1182 return True
1183
Dan Talaycof6202252013-07-02 01:00:29 -07001184 def pretty_print(self, q):
1185 q.text("bsn_bw_clear_data_reply {")
1186 with q.group():
1187 with q.indent(2):
1188 q.breakable()
1189 q.text("xid = ");
1190 if self.xid != None:
1191 q.text("%#x" % self.xid)
1192 else:
1193 q.text('None')
1194 q.text(","); q.breakable()
1195 q.text("status = ");
1196 q.text("%#x" % self.status)
1197 q.breakable()
1198 q.text('}')
1199
Rich Lane7dcdf022013-12-11 14:45:27 -08001200bsn_header.subtypes[22] = bsn_bw_clear_data_reply
1201
1202class bsn_bw_clear_data_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001203 version = 2
1204 type = 4
1205 experimenter = 6035143
1206 subtype = 21
1207
1208 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001209 if xid != None:
1210 self.xid = xid
1211 else:
1212 self.xid = None
1213 return
Dan Talaycof6202252013-07-02 01:00:29 -07001214
1215 def pack(self):
1216 packed = []
1217 packed.append(struct.pack("!B", self.version))
1218 packed.append(struct.pack("!B", self.type))
1219 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1220 packed.append(struct.pack("!L", self.xid))
1221 packed.append(struct.pack("!L", self.experimenter))
1222 packed.append(struct.pack("!L", self.subtype))
1223 length = sum([len(x) for x in packed])
1224 packed[2] = struct.pack("!H", length)
1225 return ''.join(packed)
1226
1227 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001228 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001229 obj = bsn_bw_clear_data_request()
Dan Talaycof6202252013-07-02 01:00:29 -07001230 _version = reader.read("!B")[0]
1231 assert(_version == 2)
1232 _type = reader.read("!B")[0]
1233 assert(_type == 4)
1234 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001235 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001236 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001237 obj.xid = reader.read("!L")[0]
1238 _experimenter = reader.read("!L")[0]
1239 assert(_experimenter == 6035143)
1240 _subtype = reader.read("!L")[0]
1241 assert(_subtype == 21)
1242 return obj
1243
1244 def __eq__(self, other):
1245 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07001246 if self.xid != other.xid: return False
1247 return True
1248
Dan Talaycof6202252013-07-02 01:00:29 -07001249 def pretty_print(self, q):
1250 q.text("bsn_bw_clear_data_request {")
1251 with q.group():
1252 with q.indent(2):
1253 q.breakable()
1254 q.text("xid = ");
1255 if self.xid != None:
1256 q.text("%#x" % self.xid)
1257 else:
1258 q.text('None')
1259 q.breakable()
1260 q.text('}')
1261
Rich Lane7dcdf022013-12-11 14:45:27 -08001262bsn_header.subtypes[21] = bsn_bw_clear_data_request
1263
1264class bsn_bw_enable_get_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001265 version = 2
1266 type = 4
1267 experimenter = 6035143
1268 subtype = 20
1269
1270 def __init__(self, xid=None, enabled=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001271 if xid != None:
1272 self.xid = xid
1273 else:
1274 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07001275 if enabled != None:
1276 self.enabled = enabled
1277 else:
1278 self.enabled = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001279 return
Dan Talaycof6202252013-07-02 01:00:29 -07001280
1281 def pack(self):
1282 packed = []
1283 packed.append(struct.pack("!B", self.version))
1284 packed.append(struct.pack("!B", self.type))
1285 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1286 packed.append(struct.pack("!L", self.xid))
1287 packed.append(struct.pack("!L", self.experimenter))
1288 packed.append(struct.pack("!L", self.subtype))
1289 packed.append(struct.pack("!L", self.enabled))
1290 length = sum([len(x) for x in packed])
1291 packed[2] = struct.pack("!H", length)
1292 return ''.join(packed)
1293
1294 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001295 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001296 obj = bsn_bw_enable_get_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07001297 _version = reader.read("!B")[0]
1298 assert(_version == 2)
1299 _type = reader.read("!B")[0]
1300 assert(_type == 4)
1301 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001302 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001303 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001304 obj.xid = reader.read("!L")[0]
1305 _experimenter = reader.read("!L")[0]
1306 assert(_experimenter == 6035143)
1307 _subtype = reader.read("!L")[0]
1308 assert(_subtype == 20)
1309 obj.enabled = reader.read("!L")[0]
1310 return obj
1311
1312 def __eq__(self, other):
1313 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07001314 if self.xid != other.xid: return False
1315 if self.enabled != other.enabled: return False
1316 return True
1317
Dan Talaycof6202252013-07-02 01:00:29 -07001318 def pretty_print(self, q):
1319 q.text("bsn_bw_enable_get_reply {")
1320 with q.group():
1321 with q.indent(2):
1322 q.breakable()
1323 q.text("xid = ");
1324 if self.xid != None:
1325 q.text("%#x" % self.xid)
1326 else:
1327 q.text('None')
1328 q.text(","); q.breakable()
1329 q.text("enabled = ");
1330 q.text("%#x" % self.enabled)
1331 q.breakable()
1332 q.text('}')
1333
Rich Lane7dcdf022013-12-11 14:45:27 -08001334bsn_header.subtypes[20] = bsn_bw_enable_get_reply
1335
1336class bsn_bw_enable_get_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001337 version = 2
1338 type = 4
1339 experimenter = 6035143
1340 subtype = 19
1341
1342 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001343 if xid != None:
1344 self.xid = xid
1345 else:
1346 self.xid = None
1347 return
Dan Talaycof6202252013-07-02 01:00:29 -07001348
1349 def pack(self):
1350 packed = []
1351 packed.append(struct.pack("!B", self.version))
1352 packed.append(struct.pack("!B", self.type))
1353 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1354 packed.append(struct.pack("!L", self.xid))
1355 packed.append(struct.pack("!L", self.experimenter))
1356 packed.append(struct.pack("!L", self.subtype))
1357 length = sum([len(x) for x in packed])
1358 packed[2] = struct.pack("!H", length)
1359 return ''.join(packed)
1360
1361 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001362 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001363 obj = bsn_bw_enable_get_request()
Dan Talaycof6202252013-07-02 01:00:29 -07001364 _version = reader.read("!B")[0]
1365 assert(_version == 2)
1366 _type = reader.read("!B")[0]
1367 assert(_type == 4)
1368 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001369 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001370 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001371 obj.xid = reader.read("!L")[0]
1372 _experimenter = reader.read("!L")[0]
1373 assert(_experimenter == 6035143)
1374 _subtype = reader.read("!L")[0]
1375 assert(_subtype == 19)
1376 return obj
1377
1378 def __eq__(self, other):
1379 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07001380 if self.xid != other.xid: return False
1381 return True
1382
Dan Talaycof6202252013-07-02 01:00:29 -07001383 def pretty_print(self, q):
1384 q.text("bsn_bw_enable_get_request {")
1385 with q.group():
1386 with q.indent(2):
1387 q.breakable()
1388 q.text("xid = ");
1389 if self.xid != None:
1390 q.text("%#x" % self.xid)
1391 else:
1392 q.text('None')
1393 q.breakable()
1394 q.text('}')
1395
Rich Lane7dcdf022013-12-11 14:45:27 -08001396bsn_header.subtypes[19] = bsn_bw_enable_get_request
1397
1398class bsn_bw_enable_set_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001399 version = 2
1400 type = 4
1401 experimenter = 6035143
1402 subtype = 23
1403
1404 def __init__(self, xid=None, enable=None, status=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001405 if xid != None:
1406 self.xid = xid
1407 else:
1408 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07001409 if enable != None:
1410 self.enable = enable
1411 else:
1412 self.enable = 0
1413 if status != None:
1414 self.status = status
1415 else:
1416 self.status = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001417 return
Dan Talaycof6202252013-07-02 01:00:29 -07001418
1419 def pack(self):
1420 packed = []
1421 packed.append(struct.pack("!B", self.version))
1422 packed.append(struct.pack("!B", self.type))
1423 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1424 packed.append(struct.pack("!L", self.xid))
1425 packed.append(struct.pack("!L", self.experimenter))
1426 packed.append(struct.pack("!L", self.subtype))
1427 packed.append(struct.pack("!L", self.enable))
1428 packed.append(struct.pack("!L", self.status))
1429 length = sum([len(x) for x in packed])
1430 packed[2] = struct.pack("!H", length)
1431 return ''.join(packed)
1432
1433 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001434 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001435 obj = bsn_bw_enable_set_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07001436 _version = reader.read("!B")[0]
1437 assert(_version == 2)
1438 _type = reader.read("!B")[0]
1439 assert(_type == 4)
1440 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001441 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001442 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001443 obj.xid = reader.read("!L")[0]
1444 _experimenter = reader.read("!L")[0]
1445 assert(_experimenter == 6035143)
1446 _subtype = reader.read("!L")[0]
1447 assert(_subtype == 23)
1448 obj.enable = reader.read("!L")[0]
1449 obj.status = reader.read("!L")[0]
1450 return obj
1451
1452 def __eq__(self, other):
1453 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07001454 if self.xid != other.xid: return False
1455 if self.enable != other.enable: return False
1456 if self.status != other.status: return False
1457 return True
1458
Dan Talaycof6202252013-07-02 01:00:29 -07001459 def pretty_print(self, q):
1460 q.text("bsn_bw_enable_set_reply {")
1461 with q.group():
1462 with q.indent(2):
1463 q.breakable()
1464 q.text("xid = ");
1465 if self.xid != None:
1466 q.text("%#x" % self.xid)
1467 else:
1468 q.text('None')
1469 q.text(","); q.breakable()
1470 q.text("enable = ");
1471 q.text("%#x" % self.enable)
1472 q.text(","); q.breakable()
1473 q.text("status = ");
1474 q.text("%#x" % self.status)
1475 q.breakable()
1476 q.text('}')
1477
Rich Lane7dcdf022013-12-11 14:45:27 -08001478bsn_header.subtypes[23] = bsn_bw_enable_set_reply
1479
1480class bsn_bw_enable_set_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001481 version = 2
1482 type = 4
1483 experimenter = 6035143
1484 subtype = 18
1485
1486 def __init__(self, xid=None, enable=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001487 if xid != None:
1488 self.xid = xid
1489 else:
1490 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07001491 if enable != None:
1492 self.enable = enable
1493 else:
1494 self.enable = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001495 return
Dan Talaycof6202252013-07-02 01:00:29 -07001496
1497 def pack(self):
1498 packed = []
1499 packed.append(struct.pack("!B", self.version))
1500 packed.append(struct.pack("!B", self.type))
1501 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1502 packed.append(struct.pack("!L", self.xid))
1503 packed.append(struct.pack("!L", self.experimenter))
1504 packed.append(struct.pack("!L", self.subtype))
1505 packed.append(struct.pack("!L", self.enable))
1506 length = sum([len(x) for x in packed])
1507 packed[2] = struct.pack("!H", length)
1508 return ''.join(packed)
1509
1510 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001511 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001512 obj = bsn_bw_enable_set_request()
Dan Talaycof6202252013-07-02 01:00:29 -07001513 _version = reader.read("!B")[0]
1514 assert(_version == 2)
1515 _type = reader.read("!B")[0]
1516 assert(_type == 4)
1517 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001518 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001519 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001520 obj.xid = reader.read("!L")[0]
1521 _experimenter = reader.read("!L")[0]
1522 assert(_experimenter == 6035143)
1523 _subtype = reader.read("!L")[0]
1524 assert(_subtype == 18)
1525 obj.enable = reader.read("!L")[0]
1526 return obj
1527
1528 def __eq__(self, other):
1529 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07001530 if self.xid != other.xid: return False
1531 if self.enable != other.enable: return False
1532 return True
1533
Dan Talaycof6202252013-07-02 01:00:29 -07001534 def pretty_print(self, q):
1535 q.text("bsn_bw_enable_set_request {")
1536 with q.group():
1537 with q.indent(2):
1538 q.breakable()
1539 q.text("xid = ");
1540 if self.xid != None:
1541 q.text("%#x" % self.xid)
1542 else:
1543 q.text('None')
1544 q.text(","); q.breakable()
1545 q.text("enable = ");
1546 q.text("%#x" % self.enable)
1547 q.breakable()
1548 q.text('}')
1549
Rich Lane7dcdf022013-12-11 14:45:27 -08001550bsn_header.subtypes[18] = bsn_bw_enable_set_request
1551
1552class bsn_get_interfaces_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001553 version = 2
1554 type = 4
1555 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07001556 subtype = 10
1557
1558 def __init__(self, xid=None, interfaces=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001559 if xid != None:
1560 self.xid = xid
1561 else:
1562 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07001563 if interfaces != None:
1564 self.interfaces = interfaces
1565 else:
1566 self.interfaces = []
Rich Lane7dcdf022013-12-11 14:45:27 -08001567 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07001568
1569 def pack(self):
1570 packed = []
1571 packed.append(struct.pack("!B", self.version))
1572 packed.append(struct.pack("!B", self.type))
1573 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1574 packed.append(struct.pack("!L", self.xid))
1575 packed.append(struct.pack("!L", self.experimenter))
1576 packed.append(struct.pack("!L", self.subtype))
Rich Lane7dcdf022013-12-11 14:45:27 -08001577 packed.append(loxi.generic_util.pack_list(self.interfaces))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001578 length = sum([len(x) for x in packed])
1579 packed[2] = struct.pack("!H", length)
1580 return ''.join(packed)
1581
1582 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001583 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001584 obj = bsn_get_interfaces_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07001585 _version = reader.read("!B")[0]
1586 assert(_version == 2)
1587 _type = reader.read("!B")[0]
1588 assert(_type == 4)
1589 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001590 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001591 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001592 obj.xid = reader.read("!L")[0]
1593 _experimenter = reader.read("!L")[0]
1594 assert(_experimenter == 6035143)
1595 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001596 assert(_subtype == 10)
Rich Lanee2567702015-01-26 15:04:35 -08001597 obj.interfaces = loxi.generic_util.unpack_list(reader, ofp.common.bsn_interface.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001598 return obj
1599
1600 def __eq__(self, other):
1601 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001602 if self.xid != other.xid: return False
1603 if self.interfaces != other.interfaces: return False
1604 return True
1605
Rich Lanec2ee4b82013-04-24 17:12:38 -07001606 def pretty_print(self, q):
1607 q.text("bsn_get_interfaces_reply {")
1608 with q.group():
1609 with q.indent(2):
1610 q.breakable()
1611 q.text("xid = ");
1612 if self.xid != None:
1613 q.text("%#x" % self.xid)
1614 else:
1615 q.text('None')
1616 q.text(","); q.breakable()
1617 q.text("interfaces = ");
1618 q.pp(self.interfaces)
1619 q.breakable()
1620 q.text('}')
1621
Rich Lane7dcdf022013-12-11 14:45:27 -08001622bsn_header.subtypes[10] = bsn_get_interfaces_reply
1623
1624class bsn_get_interfaces_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001625 version = 2
1626 type = 4
1627 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07001628 subtype = 9
1629
1630 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001631 if xid != None:
1632 self.xid = xid
1633 else:
1634 self.xid = None
1635 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07001636
1637 def pack(self):
1638 packed = []
1639 packed.append(struct.pack("!B", self.version))
1640 packed.append(struct.pack("!B", self.type))
1641 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1642 packed.append(struct.pack("!L", self.xid))
1643 packed.append(struct.pack("!L", self.experimenter))
1644 packed.append(struct.pack("!L", self.subtype))
1645 length = sum([len(x) for x in packed])
1646 packed[2] = struct.pack("!H", length)
1647 return ''.join(packed)
1648
1649 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001650 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001651 obj = bsn_get_interfaces_request()
Dan Talaycof6202252013-07-02 01:00:29 -07001652 _version = reader.read("!B")[0]
1653 assert(_version == 2)
1654 _type = reader.read("!B")[0]
1655 assert(_type == 4)
1656 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001657 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001658 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001659 obj.xid = reader.read("!L")[0]
1660 _experimenter = reader.read("!L")[0]
1661 assert(_experimenter == 6035143)
1662 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001663 assert(_subtype == 9)
1664 return obj
1665
1666 def __eq__(self, other):
1667 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001668 if self.xid != other.xid: return False
1669 return True
1670
Rich Lanec2ee4b82013-04-24 17:12:38 -07001671 def pretty_print(self, q):
1672 q.text("bsn_get_interfaces_request {")
1673 with q.group():
1674 with q.indent(2):
1675 q.breakable()
1676 q.text("xid = ");
1677 if self.xid != None:
1678 q.text("%#x" % self.xid)
1679 else:
1680 q.text('None')
1681 q.breakable()
1682 q.text('}')
1683
Rich Lane7dcdf022013-12-11 14:45:27 -08001684bsn_header.subtypes[9] = bsn_get_interfaces_request
1685
1686class bsn_get_mirroring_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001687 version = 2
1688 type = 4
1689 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07001690 subtype = 5
1691
1692 def __init__(self, xid=None, report_mirror_ports=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001693 if xid != None:
1694 self.xid = xid
1695 else:
1696 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07001697 if report_mirror_ports != None:
1698 self.report_mirror_ports = report_mirror_ports
1699 else:
1700 self.report_mirror_ports = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001701 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07001702
1703 def pack(self):
1704 packed = []
1705 packed.append(struct.pack("!B", self.version))
1706 packed.append(struct.pack("!B", self.type))
1707 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1708 packed.append(struct.pack("!L", self.xid))
1709 packed.append(struct.pack("!L", self.experimenter))
1710 packed.append(struct.pack("!L", self.subtype))
1711 packed.append(struct.pack("!B", self.report_mirror_ports))
1712 packed.append('\x00' * 3)
1713 length = sum([len(x) for x in packed])
1714 packed[2] = struct.pack("!H", length)
1715 return ''.join(packed)
1716
1717 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001718 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001719 obj = bsn_get_mirroring_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07001720 _version = reader.read("!B")[0]
1721 assert(_version == 2)
1722 _type = reader.read("!B")[0]
1723 assert(_type == 4)
1724 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001725 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001726 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001727 obj.xid = reader.read("!L")[0]
1728 _experimenter = reader.read("!L")[0]
1729 assert(_experimenter == 6035143)
1730 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001731 assert(_subtype == 5)
Dan Talaycof6202252013-07-02 01:00:29 -07001732 obj.report_mirror_ports = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001733 reader.skip(3)
1734 return obj
1735
1736 def __eq__(self, other):
1737 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001738 if self.xid != other.xid: return False
1739 if self.report_mirror_ports != other.report_mirror_ports: return False
1740 return True
1741
Rich Lanec2ee4b82013-04-24 17:12:38 -07001742 def pretty_print(self, q):
1743 q.text("bsn_get_mirroring_reply {")
1744 with q.group():
1745 with q.indent(2):
1746 q.breakable()
1747 q.text("xid = ");
1748 if self.xid != None:
1749 q.text("%#x" % self.xid)
1750 else:
1751 q.text('None')
1752 q.text(","); q.breakable()
1753 q.text("report_mirror_ports = ");
1754 q.text("%#x" % self.report_mirror_ports)
1755 q.breakable()
1756 q.text('}')
1757
Rich Lane7dcdf022013-12-11 14:45:27 -08001758bsn_header.subtypes[5] = bsn_get_mirroring_reply
1759
1760class bsn_get_mirroring_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07001761 version = 2
1762 type = 4
1763 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07001764 subtype = 4
1765
1766 def __init__(self, xid=None, report_mirror_ports=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001767 if xid != None:
1768 self.xid = xid
1769 else:
1770 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07001771 if report_mirror_ports != None:
1772 self.report_mirror_ports = report_mirror_ports
1773 else:
1774 self.report_mirror_ports = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001775 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07001776
1777 def pack(self):
1778 packed = []
1779 packed.append(struct.pack("!B", self.version))
1780 packed.append(struct.pack("!B", self.type))
1781 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1782 packed.append(struct.pack("!L", self.xid))
1783 packed.append(struct.pack("!L", self.experimenter))
1784 packed.append(struct.pack("!L", self.subtype))
1785 packed.append(struct.pack("!B", self.report_mirror_ports))
1786 packed.append('\x00' * 3)
1787 length = sum([len(x) for x in packed])
1788 packed[2] = struct.pack("!H", length)
1789 return ''.join(packed)
1790
1791 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001792 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001793 obj = bsn_get_mirroring_request()
Dan Talaycof6202252013-07-02 01:00:29 -07001794 _version = reader.read("!B")[0]
1795 assert(_version == 2)
1796 _type = reader.read("!B")[0]
1797 assert(_type == 4)
1798 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001799 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001800 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001801 obj.xid = reader.read("!L")[0]
1802 _experimenter = reader.read("!L")[0]
1803 assert(_experimenter == 6035143)
1804 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001805 assert(_subtype == 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001806 obj.report_mirror_ports = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001807 reader.skip(3)
1808 return obj
1809
1810 def __eq__(self, other):
1811 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001812 if self.xid != other.xid: return False
1813 if self.report_mirror_ports != other.report_mirror_ports: return False
1814 return True
1815
Rich Lanec2ee4b82013-04-24 17:12:38 -07001816 def pretty_print(self, q):
1817 q.text("bsn_get_mirroring_request {")
1818 with q.group():
1819 with q.indent(2):
1820 q.breakable()
1821 q.text("xid = ");
1822 if self.xid != None:
1823 q.text("%#x" % self.xid)
1824 else:
1825 q.text('None')
1826 q.text(","); q.breakable()
1827 q.text("report_mirror_ports = ");
1828 q.text("%#x" % self.report_mirror_ports)
1829 q.breakable()
1830 q.text('}')
1831
Rich Lane7dcdf022013-12-11 14:45:27 -08001832bsn_header.subtypes[4] = bsn_get_mirroring_request
1833
1834class bsn_pdu_rx_reply(bsn_header):
Rich Lane6f4978c2013-10-20 21:33:52 -07001835 version = 2
1836 type = 4
1837 experimenter = 6035143
1838 subtype = 34
1839
Rich Lane7b0f2012013-11-22 14:15:26 -08001840 def __init__(self, xid=None, status=None, port_no=None, slot_num=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001841 if xid != None:
1842 self.xid = xid
1843 else:
1844 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07001845 if status != None:
1846 self.status = status
1847 else:
1848 self.status = 0
Rich Lane7b0f2012013-11-22 14:15:26 -08001849 if port_no != None:
1850 self.port_no = port_no
1851 else:
1852 self.port_no = 0
1853 if slot_num != None:
1854 self.slot_num = slot_num
1855 else:
1856 self.slot_num = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08001857 return
Rich Lane6f4978c2013-10-20 21:33:52 -07001858
1859 def pack(self):
1860 packed = []
1861 packed.append(struct.pack("!B", self.version))
1862 packed.append(struct.pack("!B", self.type))
1863 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1864 packed.append(struct.pack("!L", self.xid))
1865 packed.append(struct.pack("!L", self.experimenter))
1866 packed.append(struct.pack("!L", self.subtype))
1867 packed.append(struct.pack("!L", self.status))
Rich Lane7b0f2012013-11-22 14:15:26 -08001868 packed.append(util.pack_port_no(self.port_no))
1869 packed.append(struct.pack("!B", self.slot_num))
Rich Lane6f4978c2013-10-20 21:33:52 -07001870 length = sum([len(x) for x in packed])
1871 packed[2] = struct.pack("!H", length)
1872 return ''.join(packed)
1873
1874 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001875 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07001876 obj = bsn_pdu_rx_reply()
Rich Lane6f4978c2013-10-20 21:33:52 -07001877 _version = reader.read("!B")[0]
1878 assert(_version == 2)
1879 _type = reader.read("!B")[0]
1880 assert(_type == 4)
1881 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001882 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001883 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -07001884 obj.xid = reader.read("!L")[0]
1885 _experimenter = reader.read("!L")[0]
1886 assert(_experimenter == 6035143)
1887 _subtype = reader.read("!L")[0]
1888 assert(_subtype == 34)
1889 obj.status = reader.read("!L")[0]
Rich Lane7b0f2012013-11-22 14:15:26 -08001890 obj.port_no = util.unpack_port_no(reader)
1891 obj.slot_num = reader.read("!B")[0]
Rich Lane6f4978c2013-10-20 21:33:52 -07001892 return obj
1893
1894 def __eq__(self, other):
1895 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001896 if self.xid != other.xid: return False
1897 if self.status != other.status: return False
Rich Lane7b0f2012013-11-22 14:15:26 -08001898 if self.port_no != other.port_no: return False
1899 if self.slot_num != other.slot_num: return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001900 return True
1901
Rich Lane6f4978c2013-10-20 21:33:52 -07001902 def pretty_print(self, q):
1903 q.text("bsn_pdu_rx_reply {")
1904 with q.group():
1905 with q.indent(2):
1906 q.breakable()
1907 q.text("xid = ");
1908 if self.xid != None:
1909 q.text("%#x" % self.xid)
1910 else:
1911 q.text('None')
1912 q.text(","); q.breakable()
1913 q.text("status = ");
1914 q.text("%#x" % self.status)
Rich Lane7b0f2012013-11-22 14:15:26 -08001915 q.text(","); q.breakable()
1916 q.text("port_no = ");
1917 q.text(util.pretty_port(self.port_no))
1918 q.text(","); q.breakable()
1919 q.text("slot_num = ");
1920 q.text("%#x" % self.slot_num)
Rich Lane6f4978c2013-10-20 21:33:52 -07001921 q.breakable()
1922 q.text('}')
1923
Rich Lane7dcdf022013-12-11 14:45:27 -08001924bsn_header.subtypes[34] = bsn_pdu_rx_reply
1925
1926class bsn_pdu_rx_request(bsn_header):
Rich Lane6f4978c2013-10-20 21:33:52 -07001927 version = 2
1928 type = 4
1929 experimenter = 6035143
1930 subtype = 33
1931
1932 def __init__(self, xid=None, timeout_ms=None, port_no=None, slot_num=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08001933 if xid != None:
1934 self.xid = xid
1935 else:
1936 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07001937 if timeout_ms != None:
1938 self.timeout_ms = timeout_ms
1939 else:
1940 self.timeout_ms = 0
1941 if port_no != None:
1942 self.port_no = port_no
1943 else:
1944 self.port_no = 0
1945 if slot_num != None:
1946 self.slot_num = slot_num
1947 else:
1948 self.slot_num = 0
1949 if data != None:
1950 self.data = data
1951 else:
1952 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08001953 return
Rich Lane6f4978c2013-10-20 21:33:52 -07001954
1955 def pack(self):
1956 packed = []
1957 packed.append(struct.pack("!B", self.version))
1958 packed.append(struct.pack("!B", self.type))
1959 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
1960 packed.append(struct.pack("!L", self.xid))
1961 packed.append(struct.pack("!L", self.experimenter))
1962 packed.append(struct.pack("!L", self.subtype))
1963 packed.append(struct.pack("!L", self.timeout_ms))
1964 packed.append(util.pack_port_no(self.port_no))
1965 packed.append(struct.pack("!B", self.slot_num))
1966 packed.append('\x00' * 3)
1967 packed.append(self.data)
1968 length = sum([len(x) for x in packed])
1969 packed[2] = struct.pack("!H", length)
1970 return ''.join(packed)
1971
1972 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001973 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07001974 obj = bsn_pdu_rx_request()
Rich Lane6f4978c2013-10-20 21:33:52 -07001975 _version = reader.read("!B")[0]
1976 assert(_version == 2)
1977 _type = reader.read("!B")[0]
1978 assert(_type == 4)
1979 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001980 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001981 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -07001982 obj.xid = reader.read("!L")[0]
1983 _experimenter = reader.read("!L")[0]
1984 assert(_experimenter == 6035143)
1985 _subtype = reader.read("!L")[0]
1986 assert(_subtype == 33)
1987 obj.timeout_ms = reader.read("!L")[0]
1988 obj.port_no = util.unpack_port_no(reader)
1989 obj.slot_num = reader.read("!B")[0]
1990 reader.skip(3)
1991 obj.data = str(reader.read_all())
1992 return obj
1993
1994 def __eq__(self, other):
1995 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001996 if self.xid != other.xid: return False
1997 if self.timeout_ms != other.timeout_ms: return False
1998 if self.port_no != other.port_no: return False
1999 if self.slot_num != other.slot_num: return False
2000 if self.data != other.data: return False
2001 return True
2002
Rich Lane6f4978c2013-10-20 21:33:52 -07002003 def pretty_print(self, q):
2004 q.text("bsn_pdu_rx_request {")
2005 with q.group():
2006 with q.indent(2):
2007 q.breakable()
2008 q.text("xid = ");
2009 if self.xid != None:
2010 q.text("%#x" % self.xid)
2011 else:
2012 q.text('None')
2013 q.text(","); q.breakable()
2014 q.text("timeout_ms = ");
2015 q.text("%#x" % self.timeout_ms)
2016 q.text(","); q.breakable()
2017 q.text("port_no = ");
2018 q.text(util.pretty_port(self.port_no))
2019 q.text(","); q.breakable()
2020 q.text("slot_num = ");
2021 q.text("%#x" % self.slot_num)
2022 q.text(","); q.breakable()
2023 q.text("data = ");
2024 q.pp(self.data)
2025 q.breakable()
2026 q.text('}')
2027
Rich Lane7dcdf022013-12-11 14:45:27 -08002028bsn_header.subtypes[33] = bsn_pdu_rx_request
2029
2030class bsn_pdu_rx_timeout(bsn_header):
Rich Lane6f4978c2013-10-20 21:33:52 -07002031 version = 2
2032 type = 4
2033 experimenter = 6035143
2034 subtype = 35
2035
2036 def __init__(self, xid=None, port_no=None, slot_num=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002037 if xid != None:
2038 self.xid = xid
2039 else:
2040 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07002041 if port_no != None:
2042 self.port_no = port_no
2043 else:
2044 self.port_no = 0
2045 if slot_num != None:
2046 self.slot_num = slot_num
2047 else:
2048 self.slot_num = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002049 return
Rich Lane6f4978c2013-10-20 21:33:52 -07002050
2051 def pack(self):
2052 packed = []
2053 packed.append(struct.pack("!B", self.version))
2054 packed.append(struct.pack("!B", self.type))
2055 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2056 packed.append(struct.pack("!L", self.xid))
2057 packed.append(struct.pack("!L", self.experimenter))
2058 packed.append(struct.pack("!L", self.subtype))
2059 packed.append(util.pack_port_no(self.port_no))
2060 packed.append(struct.pack("!B", self.slot_num))
2061 length = sum([len(x) for x in packed])
2062 packed[2] = struct.pack("!H", length)
2063 return ''.join(packed)
2064
2065 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002066 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07002067 obj = bsn_pdu_rx_timeout()
Rich Lane6f4978c2013-10-20 21:33:52 -07002068 _version = reader.read("!B")[0]
2069 assert(_version == 2)
2070 _type = reader.read("!B")[0]
2071 assert(_type == 4)
2072 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002073 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002074 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -07002075 obj.xid = reader.read("!L")[0]
2076 _experimenter = reader.read("!L")[0]
2077 assert(_experimenter == 6035143)
2078 _subtype = reader.read("!L")[0]
2079 assert(_subtype == 35)
2080 obj.port_no = util.unpack_port_no(reader)
2081 obj.slot_num = reader.read("!B")[0]
2082 return obj
2083
2084 def __eq__(self, other):
2085 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07002086 if self.xid != other.xid: return False
2087 if self.port_no != other.port_no: return False
2088 if self.slot_num != other.slot_num: return False
2089 return True
2090
Rich Lane6f4978c2013-10-20 21:33:52 -07002091 def pretty_print(self, q):
2092 q.text("bsn_pdu_rx_timeout {")
2093 with q.group():
2094 with q.indent(2):
2095 q.breakable()
2096 q.text("xid = ");
2097 if self.xid != None:
2098 q.text("%#x" % self.xid)
2099 else:
2100 q.text('None')
2101 q.text(","); q.breakable()
2102 q.text("port_no = ");
2103 q.text(util.pretty_port(self.port_no))
2104 q.text(","); q.breakable()
2105 q.text("slot_num = ");
2106 q.text("%#x" % self.slot_num)
2107 q.breakable()
2108 q.text('}')
2109
Rich Lane7dcdf022013-12-11 14:45:27 -08002110bsn_header.subtypes[35] = bsn_pdu_rx_timeout
2111
2112class bsn_pdu_tx_reply(bsn_header):
Rich Lane6f4978c2013-10-20 21:33:52 -07002113 version = 2
2114 type = 4
2115 experimenter = 6035143
2116 subtype = 32
2117
Rich Lane7b0f2012013-11-22 14:15:26 -08002118 def __init__(self, xid=None, status=None, port_no=None, slot_num=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002119 if xid != None:
2120 self.xid = xid
2121 else:
2122 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07002123 if status != None:
2124 self.status = status
2125 else:
2126 self.status = 0
Rich Lane7b0f2012013-11-22 14:15:26 -08002127 if port_no != None:
2128 self.port_no = port_no
2129 else:
2130 self.port_no = 0
2131 if slot_num != None:
2132 self.slot_num = slot_num
2133 else:
2134 self.slot_num = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002135 return
Rich Lane6f4978c2013-10-20 21:33:52 -07002136
2137 def pack(self):
2138 packed = []
2139 packed.append(struct.pack("!B", self.version))
2140 packed.append(struct.pack("!B", self.type))
2141 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2142 packed.append(struct.pack("!L", self.xid))
2143 packed.append(struct.pack("!L", self.experimenter))
2144 packed.append(struct.pack("!L", self.subtype))
2145 packed.append(struct.pack("!L", self.status))
Rich Lane7b0f2012013-11-22 14:15:26 -08002146 packed.append(util.pack_port_no(self.port_no))
2147 packed.append(struct.pack("!B", self.slot_num))
Rich Lane6f4978c2013-10-20 21:33:52 -07002148 length = sum([len(x) for x in packed])
2149 packed[2] = struct.pack("!H", length)
2150 return ''.join(packed)
2151
2152 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002153 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07002154 obj = bsn_pdu_tx_reply()
Rich Lane6f4978c2013-10-20 21:33:52 -07002155 _version = reader.read("!B")[0]
2156 assert(_version == 2)
2157 _type = reader.read("!B")[0]
2158 assert(_type == 4)
2159 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002160 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002161 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -07002162 obj.xid = reader.read("!L")[0]
2163 _experimenter = reader.read("!L")[0]
2164 assert(_experimenter == 6035143)
2165 _subtype = reader.read("!L")[0]
2166 assert(_subtype == 32)
2167 obj.status = reader.read("!L")[0]
Rich Lane7b0f2012013-11-22 14:15:26 -08002168 obj.port_no = util.unpack_port_no(reader)
2169 obj.slot_num = reader.read("!B")[0]
Rich Lane6f4978c2013-10-20 21:33:52 -07002170 return obj
2171
2172 def __eq__(self, other):
2173 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07002174 if self.xid != other.xid: return False
2175 if self.status != other.status: return False
Rich Lane7b0f2012013-11-22 14:15:26 -08002176 if self.port_no != other.port_no: return False
2177 if self.slot_num != other.slot_num: return False
Rich Lane6f4978c2013-10-20 21:33:52 -07002178 return True
2179
Rich Lane6f4978c2013-10-20 21:33:52 -07002180 def pretty_print(self, q):
2181 q.text("bsn_pdu_tx_reply {")
2182 with q.group():
2183 with q.indent(2):
2184 q.breakable()
2185 q.text("xid = ");
2186 if self.xid != None:
2187 q.text("%#x" % self.xid)
2188 else:
2189 q.text('None')
2190 q.text(","); q.breakable()
2191 q.text("status = ");
2192 q.text("%#x" % self.status)
Rich Lane7b0f2012013-11-22 14:15:26 -08002193 q.text(","); q.breakable()
2194 q.text("port_no = ");
2195 q.text(util.pretty_port(self.port_no))
2196 q.text(","); q.breakable()
2197 q.text("slot_num = ");
2198 q.text("%#x" % self.slot_num)
Rich Lane6f4978c2013-10-20 21:33:52 -07002199 q.breakable()
2200 q.text('}')
2201
Rich Lane7dcdf022013-12-11 14:45:27 -08002202bsn_header.subtypes[32] = bsn_pdu_tx_reply
2203
2204class bsn_pdu_tx_request(bsn_header):
Rich Lane6f4978c2013-10-20 21:33:52 -07002205 version = 2
2206 type = 4
2207 experimenter = 6035143
2208 subtype = 31
2209
2210 def __init__(self, xid=None, tx_interval_ms=None, port_no=None, slot_num=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002211 if xid != None:
2212 self.xid = xid
2213 else:
2214 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07002215 if tx_interval_ms != None:
2216 self.tx_interval_ms = tx_interval_ms
2217 else:
2218 self.tx_interval_ms = 0
2219 if port_no != None:
2220 self.port_no = port_no
2221 else:
2222 self.port_no = 0
2223 if slot_num != None:
2224 self.slot_num = slot_num
2225 else:
2226 self.slot_num = 0
2227 if data != None:
2228 self.data = data
2229 else:
2230 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08002231 return
Rich Lane6f4978c2013-10-20 21:33:52 -07002232
2233 def pack(self):
2234 packed = []
2235 packed.append(struct.pack("!B", self.version))
2236 packed.append(struct.pack("!B", self.type))
2237 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2238 packed.append(struct.pack("!L", self.xid))
2239 packed.append(struct.pack("!L", self.experimenter))
2240 packed.append(struct.pack("!L", self.subtype))
2241 packed.append(struct.pack("!L", self.tx_interval_ms))
2242 packed.append(util.pack_port_no(self.port_no))
2243 packed.append(struct.pack("!B", self.slot_num))
2244 packed.append('\x00' * 3)
2245 packed.append(self.data)
2246 length = sum([len(x) for x in packed])
2247 packed[2] = struct.pack("!H", length)
2248 return ''.join(packed)
2249
2250 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002251 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07002252 obj = bsn_pdu_tx_request()
Rich Lane6f4978c2013-10-20 21:33:52 -07002253 _version = reader.read("!B")[0]
2254 assert(_version == 2)
2255 _type = reader.read("!B")[0]
2256 assert(_type == 4)
2257 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002258 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002259 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -07002260 obj.xid = reader.read("!L")[0]
2261 _experimenter = reader.read("!L")[0]
2262 assert(_experimenter == 6035143)
2263 _subtype = reader.read("!L")[0]
2264 assert(_subtype == 31)
2265 obj.tx_interval_ms = reader.read("!L")[0]
2266 obj.port_no = util.unpack_port_no(reader)
2267 obj.slot_num = reader.read("!B")[0]
2268 reader.skip(3)
2269 obj.data = str(reader.read_all())
2270 return obj
2271
2272 def __eq__(self, other):
2273 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07002274 if self.xid != other.xid: return False
2275 if self.tx_interval_ms != other.tx_interval_ms: return False
2276 if self.port_no != other.port_no: return False
2277 if self.slot_num != other.slot_num: return False
2278 if self.data != other.data: return False
2279 return True
2280
Rich Lane6f4978c2013-10-20 21:33:52 -07002281 def pretty_print(self, q):
2282 q.text("bsn_pdu_tx_request {")
2283 with q.group():
2284 with q.indent(2):
2285 q.breakable()
2286 q.text("xid = ");
2287 if self.xid != None:
2288 q.text("%#x" % self.xid)
2289 else:
2290 q.text('None')
2291 q.text(","); q.breakable()
2292 q.text("tx_interval_ms = ");
2293 q.text("%#x" % self.tx_interval_ms)
2294 q.text(","); q.breakable()
2295 q.text("port_no = ");
2296 q.text(util.pretty_port(self.port_no))
2297 q.text(","); q.breakable()
2298 q.text("slot_num = ");
2299 q.text("%#x" % self.slot_num)
2300 q.text(","); q.breakable()
2301 q.text("data = ");
2302 q.pp(self.data)
2303 q.breakable()
2304 q.text('}')
2305
Rich Lane7dcdf022013-12-11 14:45:27 -08002306bsn_header.subtypes[31] = bsn_pdu_tx_request
2307
2308class bsn_set_mirroring(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07002309 version = 2
2310 type = 4
2311 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07002312 subtype = 3
2313
2314 def __init__(self, xid=None, report_mirror_ports=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002315 if xid != None:
2316 self.xid = xid
2317 else:
2318 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07002319 if report_mirror_ports != None:
2320 self.report_mirror_ports = report_mirror_ports
2321 else:
2322 self.report_mirror_ports = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002323 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07002324
2325 def pack(self):
2326 packed = []
2327 packed.append(struct.pack("!B", self.version))
2328 packed.append(struct.pack("!B", self.type))
2329 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2330 packed.append(struct.pack("!L", self.xid))
2331 packed.append(struct.pack("!L", self.experimenter))
2332 packed.append(struct.pack("!L", self.subtype))
2333 packed.append(struct.pack("!B", self.report_mirror_ports))
2334 packed.append('\x00' * 3)
2335 length = sum([len(x) for x in packed])
2336 packed[2] = struct.pack("!H", length)
2337 return ''.join(packed)
2338
2339 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002340 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002341 obj = bsn_set_mirroring()
Dan Talaycof6202252013-07-02 01:00:29 -07002342 _version = reader.read("!B")[0]
2343 assert(_version == 2)
2344 _type = reader.read("!B")[0]
2345 assert(_type == 4)
2346 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002347 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002348 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07002349 obj.xid = reader.read("!L")[0]
2350 _experimenter = reader.read("!L")[0]
2351 assert(_experimenter == 6035143)
2352 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002353 assert(_subtype == 3)
Dan Talaycof6202252013-07-02 01:00:29 -07002354 obj.report_mirror_ports = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002355 reader.skip(3)
2356 return obj
2357
2358 def __eq__(self, other):
2359 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002360 if self.xid != other.xid: return False
2361 if self.report_mirror_ports != other.report_mirror_ports: return False
2362 return True
2363
Rich Lanec2ee4b82013-04-24 17:12:38 -07002364 def pretty_print(self, q):
2365 q.text("bsn_set_mirroring {")
2366 with q.group():
2367 with q.indent(2):
2368 q.breakable()
2369 q.text("xid = ");
2370 if self.xid != None:
2371 q.text("%#x" % self.xid)
2372 else:
2373 q.text('None')
2374 q.text(","); q.breakable()
2375 q.text("report_mirror_ports = ");
2376 q.text("%#x" % self.report_mirror_ports)
2377 q.breakable()
2378 q.text('}')
2379
Rich Lane7dcdf022013-12-11 14:45:27 -08002380bsn_header.subtypes[3] = bsn_set_mirroring
2381
2382class bsn_set_pktin_suppression_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07002383 version = 2
2384 type = 4
2385 experimenter = 6035143
2386 subtype = 25
2387
2388 def __init__(self, xid=None, status=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002389 if xid != None:
2390 self.xid = xid
2391 else:
2392 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07002393 if status != None:
2394 self.status = status
2395 else:
2396 self.status = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002397 return
Dan Talaycof6202252013-07-02 01:00:29 -07002398
2399 def pack(self):
2400 packed = []
2401 packed.append(struct.pack("!B", self.version))
2402 packed.append(struct.pack("!B", self.type))
2403 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2404 packed.append(struct.pack("!L", self.xid))
2405 packed.append(struct.pack("!L", self.experimenter))
2406 packed.append(struct.pack("!L", self.subtype))
2407 packed.append(struct.pack("!L", self.status))
2408 length = sum([len(x) for x in packed])
2409 packed[2] = struct.pack("!H", length)
2410 return ''.join(packed)
2411
2412 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002413 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07002414 obj = bsn_set_pktin_suppression_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07002415 _version = reader.read("!B")[0]
2416 assert(_version == 2)
2417 _type = reader.read("!B")[0]
2418 assert(_type == 4)
2419 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002420 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002421 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07002422 obj.xid = reader.read("!L")[0]
2423 _experimenter = reader.read("!L")[0]
2424 assert(_experimenter == 6035143)
2425 _subtype = reader.read("!L")[0]
2426 assert(_subtype == 25)
2427 obj.status = reader.read("!L")[0]
2428 return obj
2429
2430 def __eq__(self, other):
2431 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07002432 if self.xid != other.xid: return False
2433 if self.status != other.status: return False
2434 return True
2435
Dan Talaycof6202252013-07-02 01:00:29 -07002436 def pretty_print(self, q):
2437 q.text("bsn_set_pktin_suppression_reply {")
2438 with q.group():
2439 with q.indent(2):
2440 q.breakable()
2441 q.text("xid = ");
2442 if self.xid != None:
2443 q.text("%#x" % self.xid)
2444 else:
2445 q.text('None')
2446 q.text(","); q.breakable()
2447 q.text("status = ");
2448 q.text("%#x" % self.status)
2449 q.breakable()
2450 q.text('}')
2451
Rich Lane7dcdf022013-12-11 14:45:27 -08002452bsn_header.subtypes[25] = bsn_set_pktin_suppression_reply
2453
2454class bsn_set_pktin_suppression_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07002455 version = 2
2456 type = 4
2457 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -07002458 subtype = 11
2459
2460 def __init__(self, xid=None, enabled=None, idle_timeout=None, hard_timeout=None, priority=None, cookie=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002461 if xid != None:
2462 self.xid = xid
2463 else:
2464 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07002465 if enabled != None:
2466 self.enabled = enabled
2467 else:
2468 self.enabled = 0
2469 if idle_timeout != None:
2470 self.idle_timeout = idle_timeout
2471 else:
2472 self.idle_timeout = 0
2473 if hard_timeout != None:
2474 self.hard_timeout = hard_timeout
2475 else:
2476 self.hard_timeout = 0
2477 if priority != None:
2478 self.priority = priority
2479 else:
2480 self.priority = 0
2481 if cookie != None:
2482 self.cookie = cookie
2483 else:
2484 self.cookie = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002485 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07002486
2487 def pack(self):
2488 packed = []
2489 packed.append(struct.pack("!B", self.version))
2490 packed.append(struct.pack("!B", self.type))
2491 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2492 packed.append(struct.pack("!L", self.xid))
2493 packed.append(struct.pack("!L", self.experimenter))
2494 packed.append(struct.pack("!L", self.subtype))
2495 packed.append(struct.pack("!B", self.enabled))
2496 packed.append('\x00' * 1)
2497 packed.append(struct.pack("!H", self.idle_timeout))
2498 packed.append(struct.pack("!H", self.hard_timeout))
2499 packed.append(struct.pack("!H", self.priority))
2500 packed.append(struct.pack("!Q", self.cookie))
2501 length = sum([len(x) for x in packed])
2502 packed[2] = struct.pack("!H", length)
2503 return ''.join(packed)
2504
2505 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002506 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07002507 obj = bsn_set_pktin_suppression_request()
Dan Talaycof6202252013-07-02 01:00:29 -07002508 _version = reader.read("!B")[0]
2509 assert(_version == 2)
2510 _type = reader.read("!B")[0]
2511 assert(_type == 4)
2512 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002513 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002514 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07002515 obj.xid = reader.read("!L")[0]
2516 _experimenter = reader.read("!L")[0]
2517 assert(_experimenter == 6035143)
2518 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002519 assert(_subtype == 11)
Dan Talaycof6202252013-07-02 01:00:29 -07002520 obj.enabled = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002521 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -07002522 obj.idle_timeout = reader.read("!H")[0]
2523 obj.hard_timeout = reader.read("!H")[0]
2524 obj.priority = reader.read("!H")[0]
2525 obj.cookie = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002526 return obj
2527
2528 def __eq__(self, other):
2529 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002530 if self.xid != other.xid: return False
2531 if self.enabled != other.enabled: return False
2532 if self.idle_timeout != other.idle_timeout: return False
2533 if self.hard_timeout != other.hard_timeout: return False
2534 if self.priority != other.priority: return False
2535 if self.cookie != other.cookie: return False
2536 return True
2537
Rich Lanec2ee4b82013-04-24 17:12:38 -07002538 def pretty_print(self, q):
Dan Talaycof6202252013-07-02 01:00:29 -07002539 q.text("bsn_set_pktin_suppression_request {")
Rich Lanec2ee4b82013-04-24 17:12:38 -07002540 with q.group():
2541 with q.indent(2):
2542 q.breakable()
2543 q.text("xid = ");
2544 if self.xid != None:
2545 q.text("%#x" % self.xid)
2546 else:
2547 q.text('None')
2548 q.text(","); q.breakable()
2549 q.text("enabled = ");
2550 q.text("%#x" % self.enabled)
2551 q.text(","); q.breakable()
2552 q.text("idle_timeout = ");
2553 q.text("%#x" % self.idle_timeout)
2554 q.text(","); q.breakable()
2555 q.text("hard_timeout = ");
2556 q.text("%#x" % self.hard_timeout)
2557 q.text(","); q.breakable()
2558 q.text("priority = ");
2559 q.text("%#x" % self.priority)
2560 q.text(","); q.breakable()
2561 q.text("cookie = ");
2562 q.text("%#x" % self.cookie)
2563 q.breakable()
2564 q.text('}')
2565
Rich Lane7dcdf022013-12-11 14:45:27 -08002566bsn_header.subtypes[11] = bsn_set_pktin_suppression_request
2567
2568class experimenter_stats_reply(stats_reply):
2569 subtypes = {}
2570
Rich Lane95f7fc92014-01-27 17:08:16 -08002571 version = 2
2572 type = 19
2573 stats_type = 65535
2574
2575 def __init__(self, xid=None, flags=None, experimenter=None, data=None):
2576 if xid != None:
2577 self.xid = xid
2578 else:
2579 self.xid = None
2580 if flags != None:
2581 self.flags = flags
2582 else:
2583 self.flags = 0
2584 if experimenter != None:
2585 self.experimenter = experimenter
2586 else:
2587 self.experimenter = 0
2588 if data != None:
2589 self.data = data
2590 else:
2591 self.data = ''
2592 return
2593
2594 def pack(self):
2595 packed = []
2596 packed.append(struct.pack("!B", self.version))
2597 packed.append(struct.pack("!B", self.type))
2598 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2599 packed.append(struct.pack("!L", self.xid))
2600 packed.append(struct.pack("!H", self.stats_type))
2601 packed.append(struct.pack("!H", self.flags))
2602 packed.append('\x00' * 4)
2603 packed.append(struct.pack("!L", self.experimenter))
2604 packed.append('\x00' * 4)
2605 packed.append(self.data)
2606 length = sum([len(x) for x in packed])
2607 packed[2] = struct.pack("!H", length)
2608 return ''.join(packed)
2609
Rich Lane7dcdf022013-12-11 14:45:27 -08002610 @staticmethod
2611 def unpack(reader):
2612 subtype, = reader.peek('!L', 16)
Rich Lane95f7fc92014-01-27 17:08:16 -08002613 subclass = experimenter_stats_reply.subtypes.get(subtype)
2614 if subclass:
2615 return subclass.unpack(reader)
2616
2617 obj = experimenter_stats_reply()
2618 _version = reader.read("!B")[0]
2619 assert(_version == 2)
2620 _type = reader.read("!B")[0]
2621 assert(_type == 19)
2622 _length = reader.read("!H")[0]
2623 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002624 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -08002625 obj.xid = reader.read("!L")[0]
2626 _stats_type = reader.read("!H")[0]
2627 assert(_stats_type == 65535)
2628 obj.flags = reader.read("!H")[0]
2629 reader.skip(4)
2630 obj.experimenter = reader.read("!L")[0]
2631 reader.skip(4)
2632 obj.data = str(reader.read_all())
2633 return obj
2634
2635 def __eq__(self, other):
2636 if type(self) != type(other): return False
2637 if self.xid != other.xid: return False
2638 if self.flags != other.flags: return False
2639 if self.experimenter != other.experimenter: return False
2640 if self.data != other.data: return False
2641 return True
2642
2643 def pretty_print(self, q):
2644 q.text("experimenter_stats_reply {")
2645 with q.group():
2646 with q.indent(2):
2647 q.breakable()
2648 q.text("xid = ");
2649 if self.xid != None:
2650 q.text("%#x" % self.xid)
2651 else:
2652 q.text('None')
2653 q.text(","); q.breakable()
2654 q.text("flags = ");
2655 q.text("%#x" % self.flags)
2656 q.text(","); q.breakable()
2657 q.text("data = ");
2658 q.pp(self.data)
2659 q.breakable()
2660 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002661
2662stats_reply.subtypes[65535] = experimenter_stats_reply
2663
2664class bsn_stats_reply(experimenter_stats_reply):
2665 subtypes = {}
2666
Rich Lane95f7fc92014-01-27 17:08:16 -08002667 version = 2
2668 type = 19
2669 stats_type = 65535
2670 experimenter = 6035143
2671
2672 def __init__(self, xid=None, flags=None, subtype=None):
2673 if xid != None:
2674 self.xid = xid
2675 else:
2676 self.xid = None
2677 if flags != None:
2678 self.flags = flags
2679 else:
2680 self.flags = 0
2681 if subtype != None:
2682 self.subtype = subtype
2683 else:
2684 self.subtype = 0
2685 return
2686
2687 def pack(self):
2688 packed = []
2689 packed.append(struct.pack("!B", self.version))
2690 packed.append(struct.pack("!B", self.type))
2691 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2692 packed.append(struct.pack("!L", self.xid))
2693 packed.append(struct.pack("!H", self.stats_type))
2694 packed.append(struct.pack("!H", self.flags))
2695 packed.append('\x00' * 4)
2696 packed.append(struct.pack("!L", self.experimenter))
2697 packed.append(struct.pack("!L", self.subtype))
2698 length = sum([len(x) for x in packed])
2699 packed[2] = struct.pack("!H", length)
2700 return ''.join(packed)
2701
Rich Lane7dcdf022013-12-11 14:45:27 -08002702 @staticmethod
2703 def unpack(reader):
2704 subtype, = reader.peek('!L', 20)
Rich Lane95f7fc92014-01-27 17:08:16 -08002705 subclass = bsn_stats_reply.subtypes.get(subtype)
2706 if subclass:
2707 return subclass.unpack(reader)
2708
2709 obj = bsn_stats_reply()
2710 _version = reader.read("!B")[0]
2711 assert(_version == 2)
2712 _type = reader.read("!B")[0]
2713 assert(_type == 19)
2714 _length = reader.read("!H")[0]
2715 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002716 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -08002717 obj.xid = reader.read("!L")[0]
2718 _stats_type = reader.read("!H")[0]
2719 assert(_stats_type == 65535)
2720 obj.flags = reader.read("!H")[0]
2721 reader.skip(4)
2722 _experimenter = reader.read("!L")[0]
2723 assert(_experimenter == 6035143)
2724 obj.subtype = reader.read("!L")[0]
2725 return obj
2726
2727 def __eq__(self, other):
2728 if type(self) != type(other): return False
2729 if self.xid != other.xid: return False
2730 if self.flags != other.flags: return False
2731 if self.subtype != other.subtype: return False
2732 return True
2733
2734 def pretty_print(self, q):
2735 q.text("bsn_stats_reply {")
2736 with q.group():
2737 with q.indent(2):
2738 q.breakable()
2739 q.text("xid = ");
2740 if self.xid != None:
2741 q.text("%#x" % self.xid)
2742 else:
2743 q.text('None')
2744 q.text(","); q.breakable()
2745 q.text("flags = ");
2746 q.text("%#x" % self.flags)
2747 q.breakable()
2748 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002749
2750experimenter_stats_reply.subtypes[6035143] = bsn_stats_reply
2751
2752class experimenter_stats_request(stats_request):
2753 subtypes = {}
2754
Rich Lane95f7fc92014-01-27 17:08:16 -08002755 version = 2
2756 type = 18
2757 stats_type = 65535
2758
2759 def __init__(self, xid=None, flags=None, experimenter=None, data=None):
2760 if xid != None:
2761 self.xid = xid
2762 else:
2763 self.xid = None
2764 if flags != None:
2765 self.flags = flags
2766 else:
2767 self.flags = 0
2768 if experimenter != None:
2769 self.experimenter = experimenter
2770 else:
2771 self.experimenter = 0
2772 if data != None:
2773 self.data = data
2774 else:
2775 self.data = ''
2776 return
2777
2778 def pack(self):
2779 packed = []
2780 packed.append(struct.pack("!B", self.version))
2781 packed.append(struct.pack("!B", self.type))
2782 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2783 packed.append(struct.pack("!L", self.xid))
2784 packed.append(struct.pack("!H", self.stats_type))
2785 packed.append(struct.pack("!H", self.flags))
2786 packed.append('\x00' * 4)
2787 packed.append(struct.pack("!L", self.experimenter))
2788 packed.append('\x00' * 4)
2789 packed.append(self.data)
2790 length = sum([len(x) for x in packed])
2791 packed[2] = struct.pack("!H", length)
2792 return ''.join(packed)
2793
Rich Lane7dcdf022013-12-11 14:45:27 -08002794 @staticmethod
2795 def unpack(reader):
2796 subtype, = reader.peek('!L', 16)
Rich Lane95f7fc92014-01-27 17:08:16 -08002797 subclass = experimenter_stats_request.subtypes.get(subtype)
2798 if subclass:
2799 return subclass.unpack(reader)
2800
2801 obj = experimenter_stats_request()
2802 _version = reader.read("!B")[0]
2803 assert(_version == 2)
2804 _type = reader.read("!B")[0]
2805 assert(_type == 18)
2806 _length = reader.read("!H")[0]
2807 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002808 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -08002809 obj.xid = reader.read("!L")[0]
2810 _stats_type = reader.read("!H")[0]
2811 assert(_stats_type == 65535)
2812 obj.flags = reader.read("!H")[0]
2813 reader.skip(4)
2814 obj.experimenter = reader.read("!L")[0]
2815 reader.skip(4)
2816 obj.data = str(reader.read_all())
2817 return obj
2818
2819 def __eq__(self, other):
2820 if type(self) != type(other): return False
2821 if self.xid != other.xid: return False
2822 if self.flags != other.flags: return False
2823 if self.experimenter != other.experimenter: return False
2824 if self.data != other.data: return False
2825 return True
2826
2827 def pretty_print(self, q):
2828 q.text("experimenter_stats_request {")
2829 with q.group():
2830 with q.indent(2):
2831 q.breakable()
2832 q.text("xid = ");
2833 if self.xid != None:
2834 q.text("%#x" % self.xid)
2835 else:
2836 q.text('None')
2837 q.text(","); q.breakable()
2838 q.text("flags = ");
2839 q.text("%#x" % self.flags)
2840 q.text(","); q.breakable()
2841 q.text("data = ");
2842 q.pp(self.data)
2843 q.breakable()
2844 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002845
2846stats_request.subtypes[65535] = experimenter_stats_request
2847
2848class bsn_stats_request(experimenter_stats_request):
2849 subtypes = {}
2850
Rich Lane95f7fc92014-01-27 17:08:16 -08002851 version = 2
2852 type = 18
2853 stats_type = 65535
2854 experimenter = 6035143
2855
2856 def __init__(self, xid=None, flags=None, subtype=None):
2857 if xid != None:
2858 self.xid = xid
2859 else:
2860 self.xid = None
2861 if flags != None:
2862 self.flags = flags
2863 else:
2864 self.flags = 0
2865 if subtype != None:
2866 self.subtype = subtype
2867 else:
2868 self.subtype = 0
2869 return
2870
2871 def pack(self):
2872 packed = []
2873 packed.append(struct.pack("!B", self.version))
2874 packed.append(struct.pack("!B", self.type))
2875 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2876 packed.append(struct.pack("!L", self.xid))
2877 packed.append(struct.pack("!H", self.stats_type))
2878 packed.append(struct.pack("!H", self.flags))
2879 packed.append('\x00' * 4)
2880 packed.append(struct.pack("!L", self.experimenter))
2881 packed.append(struct.pack("!L", self.subtype))
2882 length = sum([len(x) for x in packed])
2883 packed[2] = struct.pack("!H", length)
2884 return ''.join(packed)
2885
Rich Lane7dcdf022013-12-11 14:45:27 -08002886 @staticmethod
2887 def unpack(reader):
2888 subtype, = reader.peek('!L', 20)
Rich Lane95f7fc92014-01-27 17:08:16 -08002889 subclass = bsn_stats_request.subtypes.get(subtype)
2890 if subclass:
2891 return subclass.unpack(reader)
2892
2893 obj = bsn_stats_request()
2894 _version = reader.read("!B")[0]
2895 assert(_version == 2)
2896 _type = reader.read("!B")[0]
2897 assert(_type == 18)
2898 _length = reader.read("!H")[0]
2899 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002900 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -08002901 obj.xid = reader.read("!L")[0]
2902 _stats_type = reader.read("!H")[0]
2903 assert(_stats_type == 65535)
2904 obj.flags = reader.read("!H")[0]
2905 reader.skip(4)
2906 _experimenter = reader.read("!L")[0]
2907 assert(_experimenter == 6035143)
2908 obj.subtype = reader.read("!L")[0]
2909 return obj
2910
2911 def __eq__(self, other):
2912 if type(self) != type(other): return False
2913 if self.xid != other.xid: return False
2914 if self.flags != other.flags: return False
2915 if self.subtype != other.subtype: return False
2916 return True
2917
2918 def pretty_print(self, q):
2919 q.text("bsn_stats_request {")
2920 with q.group():
2921 with q.indent(2):
2922 q.breakable()
2923 q.text("xid = ");
2924 if self.xid != None:
2925 q.text("%#x" % self.xid)
2926 else:
2927 q.text('None')
2928 q.text(","); q.breakable()
2929 q.text("flags = ");
2930 q.text("%#x" % self.flags)
2931 q.breakable()
2932 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002933
2934experimenter_stats_request.subtypes[6035143] = bsn_stats_request
2935
2936class bsn_virtual_port_create_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07002937 version = 2
2938 type = 4
2939 experimenter = 6035143
2940 subtype = 16
2941
2942 def __init__(self, xid=None, status=None, vport_no=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08002943 if xid != None:
2944 self.xid = xid
2945 else:
2946 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07002947 if status != None:
2948 self.status = status
2949 else:
2950 self.status = 0
2951 if vport_no != None:
2952 self.vport_no = vport_no
2953 else:
2954 self.vport_no = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08002955 return
Dan Talaycof6202252013-07-02 01:00:29 -07002956
2957 def pack(self):
2958 packed = []
2959 packed.append(struct.pack("!B", self.version))
2960 packed.append(struct.pack("!B", self.type))
2961 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
2962 packed.append(struct.pack("!L", self.xid))
2963 packed.append(struct.pack("!L", self.experimenter))
2964 packed.append(struct.pack("!L", self.subtype))
2965 packed.append(struct.pack("!L", self.status))
2966 packed.append(struct.pack("!L", self.vport_no))
2967 length = sum([len(x) for x in packed])
2968 packed[2] = struct.pack("!H", length)
2969 return ''.join(packed)
2970
2971 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002972 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07002973 obj = bsn_virtual_port_create_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07002974 _version = reader.read("!B")[0]
2975 assert(_version == 2)
2976 _type = reader.read("!B")[0]
2977 assert(_type == 4)
2978 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002979 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002980 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07002981 obj.xid = reader.read("!L")[0]
2982 _experimenter = reader.read("!L")[0]
2983 assert(_experimenter == 6035143)
2984 _subtype = reader.read("!L")[0]
2985 assert(_subtype == 16)
2986 obj.status = reader.read("!L")[0]
2987 obj.vport_no = reader.read("!L")[0]
2988 return obj
2989
2990 def __eq__(self, other):
2991 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07002992 if self.xid != other.xid: return False
2993 if self.status != other.status: return False
2994 if self.vport_no != other.vport_no: return False
2995 return True
2996
Dan Talaycof6202252013-07-02 01:00:29 -07002997 def pretty_print(self, q):
2998 q.text("bsn_virtual_port_create_reply {")
2999 with q.group():
3000 with q.indent(2):
3001 q.breakable()
3002 q.text("xid = ");
3003 if self.xid != None:
3004 q.text("%#x" % self.xid)
3005 else:
3006 q.text('None')
3007 q.text(","); q.breakable()
3008 q.text("status = ");
3009 q.text("%#x" % self.status)
3010 q.text(","); q.breakable()
3011 q.text("vport_no = ");
3012 q.text("%#x" % self.vport_no)
3013 q.breakable()
3014 q.text('}')
3015
Rich Lane7dcdf022013-12-11 14:45:27 -08003016bsn_header.subtypes[16] = bsn_virtual_port_create_reply
3017
3018class bsn_virtual_port_create_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07003019 version = 2
3020 type = 4
3021 experimenter = 6035143
3022 subtype = 15
3023
3024 def __init__(self, xid=None, vport=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003025 if xid != None:
3026 self.xid = xid
3027 else:
3028 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07003029 if vport != None:
3030 self.vport = vport
3031 else:
Rich Lanee2567702015-01-26 15:04:35 -08003032 self.vport = ofp.bsn_vport()
Rich Lane7dcdf022013-12-11 14:45:27 -08003033 return
Dan Talaycof6202252013-07-02 01:00:29 -07003034
3035 def pack(self):
3036 packed = []
3037 packed.append(struct.pack("!B", self.version))
3038 packed.append(struct.pack("!B", self.type))
3039 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3040 packed.append(struct.pack("!L", self.xid))
3041 packed.append(struct.pack("!L", self.experimenter))
3042 packed.append(struct.pack("!L", self.subtype))
3043 packed.append(self.vport.pack())
3044 length = sum([len(x) for x in packed])
3045 packed[2] = struct.pack("!H", length)
3046 return ''.join(packed)
3047
3048 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003049 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07003050 obj = bsn_virtual_port_create_request()
Dan Talaycof6202252013-07-02 01:00:29 -07003051 _version = reader.read("!B")[0]
3052 assert(_version == 2)
3053 _type = reader.read("!B")[0]
3054 assert(_type == 4)
3055 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003056 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003057 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07003058 obj.xid = reader.read("!L")[0]
3059 _experimenter = reader.read("!L")[0]
3060 assert(_experimenter == 6035143)
3061 _subtype = reader.read("!L")[0]
3062 assert(_subtype == 15)
Rich Lanee2567702015-01-26 15:04:35 -08003063 obj.vport = ofp.bsn_vport.unpack(reader)
Dan Talaycof6202252013-07-02 01:00:29 -07003064 return obj
3065
3066 def __eq__(self, other):
3067 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07003068 if self.xid != other.xid: return False
3069 if self.vport != other.vport: return False
3070 return True
3071
Dan Talaycof6202252013-07-02 01:00:29 -07003072 def pretty_print(self, q):
3073 q.text("bsn_virtual_port_create_request {")
3074 with q.group():
3075 with q.indent(2):
3076 q.breakable()
3077 q.text("xid = ");
3078 if self.xid != None:
3079 q.text("%#x" % self.xid)
3080 else:
3081 q.text('None')
3082 q.text(","); q.breakable()
3083 q.text("vport = ");
3084 q.pp(self.vport)
3085 q.breakable()
3086 q.text('}')
3087
Rich Lane7dcdf022013-12-11 14:45:27 -08003088bsn_header.subtypes[15] = bsn_virtual_port_create_request
3089
3090class bsn_virtual_port_remove_reply(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07003091 version = 2
3092 type = 4
3093 experimenter = 6035143
3094 subtype = 26
3095
3096 def __init__(self, xid=None, status=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003097 if xid != None:
3098 self.xid = xid
3099 else:
3100 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07003101 if status != None:
3102 self.status = status
3103 else:
3104 self.status = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08003105 return
Dan Talaycof6202252013-07-02 01:00:29 -07003106
3107 def pack(self):
3108 packed = []
3109 packed.append(struct.pack("!B", self.version))
3110 packed.append(struct.pack("!B", self.type))
3111 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3112 packed.append(struct.pack("!L", self.xid))
3113 packed.append(struct.pack("!L", self.experimenter))
3114 packed.append(struct.pack("!L", self.subtype))
3115 packed.append(struct.pack("!L", self.status))
3116 length = sum([len(x) for x in packed])
3117 packed[2] = struct.pack("!H", length)
3118 return ''.join(packed)
3119
3120 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003121 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07003122 obj = bsn_virtual_port_remove_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07003123 _version = reader.read("!B")[0]
3124 assert(_version == 2)
3125 _type = reader.read("!B")[0]
3126 assert(_type == 4)
3127 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003128 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003129 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07003130 obj.xid = reader.read("!L")[0]
3131 _experimenter = reader.read("!L")[0]
3132 assert(_experimenter == 6035143)
3133 _subtype = reader.read("!L")[0]
3134 assert(_subtype == 26)
3135 obj.status = reader.read("!L")[0]
3136 return obj
3137
3138 def __eq__(self, other):
3139 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07003140 if self.xid != other.xid: return False
3141 if self.status != other.status: return False
3142 return True
3143
Dan Talaycof6202252013-07-02 01:00:29 -07003144 def pretty_print(self, q):
3145 q.text("bsn_virtual_port_remove_reply {")
3146 with q.group():
3147 with q.indent(2):
3148 q.breakable()
3149 q.text("xid = ");
3150 if self.xid != None:
3151 q.text("%#x" % self.xid)
3152 else:
3153 q.text('None')
3154 q.text(","); q.breakable()
3155 q.text("status = ");
3156 q.text("%#x" % self.status)
3157 q.breakable()
3158 q.text('}')
3159
Rich Lane7dcdf022013-12-11 14:45:27 -08003160bsn_header.subtypes[26] = bsn_virtual_port_remove_reply
3161
3162class bsn_virtual_port_remove_request(bsn_header):
Dan Talaycof6202252013-07-02 01:00:29 -07003163 version = 2
3164 type = 4
3165 experimenter = 6035143
3166 subtype = 17
3167
3168 def __init__(self, xid=None, vport_no=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003169 if xid != None:
3170 self.xid = xid
3171 else:
3172 self.xid = None
Dan Talaycof6202252013-07-02 01:00:29 -07003173 if vport_no != None:
3174 self.vport_no = vport_no
3175 else:
3176 self.vport_no = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08003177 return
Dan Talaycof6202252013-07-02 01:00:29 -07003178
3179 def pack(self):
3180 packed = []
3181 packed.append(struct.pack("!B", self.version))
3182 packed.append(struct.pack("!B", self.type))
3183 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3184 packed.append(struct.pack("!L", self.xid))
3185 packed.append(struct.pack("!L", self.experimenter))
3186 packed.append(struct.pack("!L", self.subtype))
3187 packed.append(struct.pack("!L", self.vport_no))
3188 length = sum([len(x) for x in packed])
3189 packed[2] = struct.pack("!H", length)
3190 return ''.join(packed)
3191
3192 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003193 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07003194 obj = bsn_virtual_port_remove_request()
Dan Talaycof6202252013-07-02 01:00:29 -07003195 _version = reader.read("!B")[0]
3196 assert(_version == 2)
3197 _type = reader.read("!B")[0]
3198 assert(_type == 4)
3199 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003200 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003201 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07003202 obj.xid = reader.read("!L")[0]
3203 _experimenter = reader.read("!L")[0]
3204 assert(_experimenter == 6035143)
3205 _subtype = reader.read("!L")[0]
3206 assert(_subtype == 17)
3207 obj.vport_no = reader.read("!L")[0]
3208 return obj
3209
3210 def __eq__(self, other):
3211 if type(self) != type(other): return False
Dan Talaycof6202252013-07-02 01:00:29 -07003212 if self.xid != other.xid: return False
3213 if self.vport_no != other.vport_no: return False
3214 return True
3215
Dan Talaycof6202252013-07-02 01:00:29 -07003216 def pretty_print(self, q):
3217 q.text("bsn_virtual_port_remove_request {")
3218 with q.group():
3219 with q.indent(2):
3220 q.breakable()
3221 q.text("xid = ");
3222 if self.xid != None:
3223 q.text("%#x" % self.xid)
3224 else:
3225 q.text('None')
3226 q.text(","); q.breakable()
3227 q.text("vport_no = ");
3228 q.text("%#x" % self.vport_no)
3229 q.breakable()
3230 q.text('}')
3231
Rich Lane7dcdf022013-12-11 14:45:27 -08003232bsn_header.subtypes[17] = bsn_virtual_port_remove_request
3233
3234class desc_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07003235 version = 2
3236 type = 19
3237 stats_type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07003238
3239 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 -08003240 if xid != None:
3241 self.xid = xid
3242 else:
3243 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003244 if flags != None:
3245 self.flags = flags
3246 else:
3247 self.flags = 0
3248 if mfr_desc != None:
3249 self.mfr_desc = mfr_desc
3250 else:
3251 self.mfr_desc = ""
3252 if hw_desc != None:
3253 self.hw_desc = hw_desc
3254 else:
3255 self.hw_desc = ""
3256 if sw_desc != None:
3257 self.sw_desc = sw_desc
3258 else:
3259 self.sw_desc = ""
3260 if serial_num != None:
3261 self.serial_num = serial_num
3262 else:
3263 self.serial_num = ""
3264 if dp_desc != None:
3265 self.dp_desc = dp_desc
3266 else:
3267 self.dp_desc = ""
Rich Lane7dcdf022013-12-11 14:45:27 -08003268 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003269
3270 def pack(self):
3271 packed = []
3272 packed.append(struct.pack("!B", self.version))
3273 packed.append(struct.pack("!B", self.type))
3274 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3275 packed.append(struct.pack("!L", self.xid))
3276 packed.append(struct.pack("!H", self.stats_type))
3277 packed.append(struct.pack("!H", self.flags))
3278 packed.append('\x00' * 4)
3279 packed.append(struct.pack("!256s", self.mfr_desc))
3280 packed.append(struct.pack("!256s", self.hw_desc))
3281 packed.append(struct.pack("!256s", self.sw_desc))
3282 packed.append(struct.pack("!32s", self.serial_num))
3283 packed.append(struct.pack("!256s", self.dp_desc))
3284 length = sum([len(x) for x in packed])
3285 packed[2] = struct.pack("!H", length)
3286 return ''.join(packed)
3287
3288 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003289 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003290 obj = desc_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07003291 _version = reader.read("!B")[0]
3292 assert(_version == 2)
3293 _type = reader.read("!B")[0]
3294 assert(_type == 19)
3295 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003296 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003297 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07003298 obj.xid = reader.read("!L")[0]
3299 _stats_type = reader.read("!H")[0]
3300 assert(_stats_type == 0)
3301 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003302 reader.skip(4)
3303 obj.mfr_desc = reader.read("!256s")[0].rstrip("\x00")
3304 obj.hw_desc = reader.read("!256s")[0].rstrip("\x00")
3305 obj.sw_desc = reader.read("!256s")[0].rstrip("\x00")
3306 obj.serial_num = reader.read("!32s")[0].rstrip("\x00")
3307 obj.dp_desc = reader.read("!256s")[0].rstrip("\x00")
3308 return obj
3309
3310 def __eq__(self, other):
3311 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003312 if self.xid != other.xid: return False
3313 if self.flags != other.flags: return False
3314 if self.mfr_desc != other.mfr_desc: return False
3315 if self.hw_desc != other.hw_desc: return False
3316 if self.sw_desc != other.sw_desc: return False
3317 if self.serial_num != other.serial_num: return False
3318 if self.dp_desc != other.dp_desc: return False
3319 return True
3320
Rich Lanec2ee4b82013-04-24 17:12:38 -07003321 def pretty_print(self, q):
3322 q.text("desc_stats_reply {")
3323 with q.group():
3324 with q.indent(2):
3325 q.breakable()
3326 q.text("xid = ");
3327 if self.xid != None:
3328 q.text("%#x" % self.xid)
3329 else:
3330 q.text('None')
3331 q.text(","); q.breakable()
3332 q.text("flags = ");
3333 q.text("%#x" % self.flags)
3334 q.text(","); q.breakable()
3335 q.text("mfr_desc = ");
3336 q.pp(self.mfr_desc)
3337 q.text(","); q.breakable()
3338 q.text("hw_desc = ");
3339 q.pp(self.hw_desc)
3340 q.text(","); q.breakable()
3341 q.text("sw_desc = ");
3342 q.pp(self.sw_desc)
3343 q.text(","); q.breakable()
3344 q.text("serial_num = ");
3345 q.pp(self.serial_num)
3346 q.text(","); q.breakable()
3347 q.text("dp_desc = ");
3348 q.pp(self.dp_desc)
3349 q.breakable()
3350 q.text('}')
3351
Rich Lane7dcdf022013-12-11 14:45:27 -08003352stats_reply.subtypes[0] = desc_stats_reply
3353
3354class desc_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07003355 version = 2
3356 type = 18
3357 stats_type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07003358
3359 def __init__(self, xid=None, flags=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003360 if xid != None:
3361 self.xid = xid
3362 else:
3363 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003364 if flags != None:
3365 self.flags = flags
3366 else:
3367 self.flags = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08003368 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003369
3370 def pack(self):
3371 packed = []
3372 packed.append(struct.pack("!B", self.version))
3373 packed.append(struct.pack("!B", self.type))
3374 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3375 packed.append(struct.pack("!L", self.xid))
3376 packed.append(struct.pack("!H", self.stats_type))
3377 packed.append(struct.pack("!H", self.flags))
3378 packed.append('\x00' * 4)
3379 length = sum([len(x) for x in packed])
3380 packed[2] = struct.pack("!H", length)
3381 return ''.join(packed)
3382
3383 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003384 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003385 obj = desc_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07003386 _version = reader.read("!B")[0]
3387 assert(_version == 2)
3388 _type = reader.read("!B")[0]
3389 assert(_type == 18)
3390 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003391 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003392 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07003393 obj.xid = reader.read("!L")[0]
3394 _stats_type = reader.read("!H")[0]
3395 assert(_stats_type == 0)
3396 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003397 reader.skip(4)
3398 return obj
3399
3400 def __eq__(self, other):
3401 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003402 if self.xid != other.xid: return False
3403 if self.flags != other.flags: return False
3404 return True
3405
Rich Lanec2ee4b82013-04-24 17:12:38 -07003406 def pretty_print(self, q):
3407 q.text("desc_stats_request {")
3408 with q.group():
3409 with q.indent(2):
3410 q.breakable()
3411 q.text("xid = ");
3412 if self.xid != None:
3413 q.text("%#x" % self.xid)
3414 else:
3415 q.text('None')
3416 q.text(","); q.breakable()
3417 q.text("flags = ");
3418 q.text("%#x" % self.flags)
3419 q.breakable()
3420 q.text('}')
3421
Rich Lane7dcdf022013-12-11 14:45:27 -08003422stats_request.subtypes[0] = desc_stats_request
3423
3424class echo_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -07003425 version = 2
3426 type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07003427
3428 def __init__(self, xid=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003429 if xid != None:
3430 self.xid = xid
3431 else:
3432 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003433 if data != None:
3434 self.data = data
3435 else:
Dan Talaycof6202252013-07-02 01:00:29 -07003436 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08003437 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003438
3439 def pack(self):
3440 packed = []
3441 packed.append(struct.pack("!B", self.version))
3442 packed.append(struct.pack("!B", self.type))
3443 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3444 packed.append(struct.pack("!L", self.xid))
3445 packed.append(self.data)
3446 length = sum([len(x) for x in packed])
3447 packed[2] = struct.pack("!H", length)
3448 return ''.join(packed)
3449
3450 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003451 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003452 obj = echo_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07003453 _version = reader.read("!B")[0]
3454 assert(_version == 2)
3455 _type = reader.read("!B")[0]
3456 assert(_type == 3)
3457 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003458 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003459 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07003460 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003461 obj.data = str(reader.read_all())
3462 return obj
3463
3464 def __eq__(self, other):
3465 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003466 if self.xid != other.xid: return False
3467 if self.data != other.data: return False
3468 return True
3469
Rich Lanec2ee4b82013-04-24 17:12:38 -07003470 def pretty_print(self, q):
3471 q.text("echo_reply {")
3472 with q.group():
3473 with q.indent(2):
3474 q.breakable()
3475 q.text("xid = ");
3476 if self.xid != None:
3477 q.text("%#x" % self.xid)
3478 else:
3479 q.text('None')
3480 q.text(","); q.breakable()
3481 q.text("data = ");
3482 q.pp(self.data)
3483 q.breakable()
3484 q.text('}')
3485
Rich Lane7dcdf022013-12-11 14:45:27 -08003486message.subtypes[3] = echo_reply
3487
3488class echo_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -07003489 version = 2
3490 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07003491
3492 def __init__(self, xid=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003493 if xid != None:
3494 self.xid = xid
3495 else:
3496 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003497 if data != None:
3498 self.data = data
3499 else:
Dan Talaycof6202252013-07-02 01:00:29 -07003500 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08003501 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003502
3503 def pack(self):
3504 packed = []
3505 packed.append(struct.pack("!B", self.version))
3506 packed.append(struct.pack("!B", self.type))
3507 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3508 packed.append(struct.pack("!L", self.xid))
3509 packed.append(self.data)
3510 length = sum([len(x) for x in packed])
3511 packed[2] = struct.pack("!H", length)
3512 return ''.join(packed)
3513
3514 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003515 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003516 obj = echo_request()
Dan Talaycof6202252013-07-02 01:00:29 -07003517 _version = reader.read("!B")[0]
3518 assert(_version == 2)
3519 _type = reader.read("!B")[0]
3520 assert(_type == 2)
3521 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003522 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003523 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07003524 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003525 obj.data = str(reader.read_all())
3526 return obj
3527
3528 def __eq__(self, other):
3529 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003530 if self.xid != other.xid: return False
3531 if self.data != other.data: return False
3532 return True
3533
Rich Lanec2ee4b82013-04-24 17:12:38 -07003534 def pretty_print(self, q):
3535 q.text("echo_request {")
3536 with q.group():
3537 with q.indent(2):
3538 q.breakable()
3539 q.text("xid = ");
3540 if self.xid != None:
3541 q.text("%#x" % self.xid)
3542 else:
3543 q.text('None')
3544 q.text(","); q.breakable()
3545 q.text("data = ");
3546 q.pp(self.data)
3547 q.breakable()
3548 q.text('}')
3549
Rich Lane7dcdf022013-12-11 14:45:27 -08003550message.subtypes[2] = echo_request
3551
3552class features_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -07003553 version = 2
3554 type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07003555
3556 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 -08003557 if xid != None:
3558 self.xid = xid
3559 else:
3560 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003561 if datapath_id != None:
3562 self.datapath_id = datapath_id
3563 else:
3564 self.datapath_id = 0
3565 if n_buffers != None:
3566 self.n_buffers = n_buffers
3567 else:
3568 self.n_buffers = 0
3569 if n_tables != None:
3570 self.n_tables = n_tables
3571 else:
3572 self.n_tables = 0
3573 if capabilities != None:
3574 self.capabilities = capabilities
3575 else:
3576 self.capabilities = 0
3577 if reserved != None:
3578 self.reserved = reserved
3579 else:
3580 self.reserved = 0
3581 if ports != None:
3582 self.ports = ports
3583 else:
3584 self.ports = []
Rich Lane7dcdf022013-12-11 14:45:27 -08003585 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003586
3587 def pack(self):
3588 packed = []
3589 packed.append(struct.pack("!B", self.version))
3590 packed.append(struct.pack("!B", self.type))
3591 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3592 packed.append(struct.pack("!L", self.xid))
3593 packed.append(struct.pack("!Q", self.datapath_id))
3594 packed.append(struct.pack("!L", self.n_buffers))
3595 packed.append(struct.pack("!B", self.n_tables))
3596 packed.append('\x00' * 3)
3597 packed.append(struct.pack("!L", self.capabilities))
3598 packed.append(struct.pack("!L", self.reserved))
Rich Lane7dcdf022013-12-11 14:45:27 -08003599 packed.append(loxi.generic_util.pack_list(self.ports))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003600 length = sum([len(x) for x in packed])
3601 packed[2] = struct.pack("!H", length)
3602 return ''.join(packed)
3603
3604 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003605 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003606 obj = features_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07003607 _version = reader.read("!B")[0]
3608 assert(_version == 2)
3609 _type = reader.read("!B")[0]
3610 assert(_type == 6)
3611 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003612 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003613 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07003614 obj.xid = reader.read("!L")[0]
3615 obj.datapath_id = reader.read("!Q")[0]
3616 obj.n_buffers = reader.read("!L")[0]
3617 obj.n_tables = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003618 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07003619 obj.capabilities = reader.read("!L")[0]
3620 obj.reserved = reader.read("!L")[0]
Rich Lanee2567702015-01-26 15:04:35 -08003621 obj.ports = loxi.generic_util.unpack_list(reader, ofp.common.port_desc.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003622 return obj
3623
3624 def __eq__(self, other):
3625 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003626 if self.xid != other.xid: return False
3627 if self.datapath_id != other.datapath_id: return False
3628 if self.n_buffers != other.n_buffers: return False
3629 if self.n_tables != other.n_tables: return False
3630 if self.capabilities != other.capabilities: return False
3631 if self.reserved != other.reserved: return False
3632 if self.ports != other.ports: return False
3633 return True
3634
Rich Lanec2ee4b82013-04-24 17:12:38 -07003635 def pretty_print(self, q):
3636 q.text("features_reply {")
3637 with q.group():
3638 with q.indent(2):
3639 q.breakable()
3640 q.text("xid = ");
3641 if self.xid != None:
3642 q.text("%#x" % self.xid)
3643 else:
3644 q.text('None')
3645 q.text(","); q.breakable()
3646 q.text("datapath_id = ");
3647 q.text("%#x" % self.datapath_id)
3648 q.text(","); q.breakable()
3649 q.text("n_buffers = ");
3650 q.text("%#x" % self.n_buffers)
3651 q.text(","); q.breakable()
3652 q.text("n_tables = ");
3653 q.text("%#x" % self.n_tables)
3654 q.text(","); q.breakable()
3655 q.text("capabilities = ");
3656 q.text("%#x" % self.capabilities)
3657 q.text(","); q.breakable()
3658 q.text("reserved = ");
3659 q.text("%#x" % self.reserved)
3660 q.text(","); q.breakable()
3661 q.text("ports = ");
3662 q.pp(self.ports)
3663 q.breakable()
3664 q.text('}')
3665
Rich Lane7dcdf022013-12-11 14:45:27 -08003666message.subtypes[6] = features_reply
3667
3668class features_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -07003669 version = 2
3670 type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07003671
3672 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08003673 if xid != None:
3674 self.xid = xid
3675 else:
3676 self.xid = None
3677 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003678
3679 def pack(self):
3680 packed = []
3681 packed.append(struct.pack("!B", self.version))
3682 packed.append(struct.pack("!B", self.type))
3683 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3684 packed.append(struct.pack("!L", self.xid))
3685 length = sum([len(x) for x in packed])
3686 packed[2] = struct.pack("!H", length)
3687 return ''.join(packed)
3688
3689 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003690 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003691 obj = features_request()
Dan Talaycof6202252013-07-02 01:00:29 -07003692 _version = reader.read("!B")[0]
3693 assert(_version == 2)
3694 _type = reader.read("!B")[0]
3695 assert(_type == 5)
3696 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003697 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003698 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07003699 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003700 return obj
3701
3702 def __eq__(self, other):
3703 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003704 if self.xid != other.xid: return False
3705 return True
3706
Rich Lanec2ee4b82013-04-24 17:12:38 -07003707 def pretty_print(self, q):
3708 q.text("features_request {")
3709 with q.group():
3710 with q.indent(2):
3711 q.breakable()
3712 q.text("xid = ");
3713 if self.xid != None:
3714 q.text("%#x" % self.xid)
3715 else:
3716 q.text('None')
3717 q.breakable()
3718 q.text('}')
3719
Rich Lane7dcdf022013-12-11 14:45:27 -08003720message.subtypes[5] = features_request
3721
3722class flow_mod(message):
3723 subtypes = {}
3724
Rich Lane95f7fc92014-01-27 17:08:16 -08003725 version = 2
3726 type = 14
3727
3728 def __init__(self, xid=None, cookie=None, cookie_mask=None, table_id=None, _command=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, out_group=None, flags=None, match=None, instructions=None):
3729 if xid != None:
3730 self.xid = xid
3731 else:
3732 self.xid = None
3733 if cookie != None:
3734 self.cookie = cookie
3735 else:
3736 self.cookie = 0
3737 if cookie_mask != None:
3738 self.cookie_mask = cookie_mask
3739 else:
3740 self.cookie_mask = 0
3741 if table_id != None:
3742 self.table_id = table_id
3743 else:
3744 self.table_id = 0
3745 if _command != None:
3746 self._command = _command
3747 else:
3748 self._command = 0
3749 if idle_timeout != None:
3750 self.idle_timeout = idle_timeout
3751 else:
3752 self.idle_timeout = 0
3753 if hard_timeout != None:
3754 self.hard_timeout = hard_timeout
3755 else:
3756 self.hard_timeout = 0
3757 if priority != None:
3758 self.priority = priority
3759 else:
3760 self.priority = 0
3761 if buffer_id != None:
3762 self.buffer_id = buffer_id
3763 else:
3764 self.buffer_id = 0
3765 if out_port != None:
3766 self.out_port = out_port
3767 else:
3768 self.out_port = 0
3769 if out_group != None:
3770 self.out_group = out_group
3771 else:
3772 self.out_group = 0
3773 if flags != None:
3774 self.flags = flags
3775 else:
3776 self.flags = 0
3777 if match != None:
3778 self.match = match
3779 else:
Rich Lanee2567702015-01-26 15:04:35 -08003780 self.match = ofp.match()
Rich Lane95f7fc92014-01-27 17:08:16 -08003781 if instructions != None:
3782 self.instructions = instructions
3783 else:
3784 self.instructions = []
3785 return
3786
3787 def pack(self):
3788 packed = []
3789 packed.append(struct.pack("!B", self.version))
3790 packed.append(struct.pack("!B", self.type))
3791 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3792 packed.append(struct.pack("!L", self.xid))
3793 packed.append(struct.pack("!Q", self.cookie))
3794 packed.append(struct.pack("!Q", self.cookie_mask))
3795 packed.append(struct.pack("!B", self.table_id))
3796 packed.append(util.pack_fm_cmd(self._command))
3797 packed.append(struct.pack("!H", self.idle_timeout))
3798 packed.append(struct.pack("!H", self.hard_timeout))
3799 packed.append(struct.pack("!H", self.priority))
3800 packed.append(struct.pack("!L", self.buffer_id))
3801 packed.append(util.pack_port_no(self.out_port))
3802 packed.append(struct.pack("!L", self.out_group))
3803 packed.append(struct.pack("!H", self.flags))
3804 packed.append('\x00' * 2)
3805 packed.append(self.match.pack())
3806 packed.append(loxi.generic_util.pack_list(self.instructions))
3807 length = sum([len(x) for x in packed])
3808 packed[2] = struct.pack("!H", length)
3809 return ''.join(packed)
3810
Rich Lane7dcdf022013-12-11 14:45:27 -08003811 @staticmethod
3812 def unpack(reader):
3813 subtype, = reader.peek('B', 25)
Rich Lane95f7fc92014-01-27 17:08:16 -08003814 subclass = flow_mod.subtypes.get(subtype)
3815 if subclass:
3816 return subclass.unpack(reader)
3817
3818 obj = flow_mod()
3819 _version = reader.read("!B")[0]
3820 assert(_version == 2)
3821 _type = reader.read("!B")[0]
3822 assert(_type == 14)
3823 _length = reader.read("!H")[0]
3824 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003825 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -08003826 obj.xid = reader.read("!L")[0]
3827 obj.cookie = reader.read("!Q")[0]
3828 obj.cookie_mask = reader.read("!Q")[0]
3829 obj.table_id = reader.read("!B")[0]
3830 obj._command = util.unpack_fm_cmd(reader)
3831 obj.idle_timeout = reader.read("!H")[0]
3832 obj.hard_timeout = reader.read("!H")[0]
3833 obj.priority = reader.read("!H")[0]
3834 obj.buffer_id = reader.read("!L")[0]
3835 obj.out_port = util.unpack_port_no(reader)
3836 obj.out_group = reader.read("!L")[0]
3837 obj.flags = reader.read("!H")[0]
3838 reader.skip(2)
Rich Lanee2567702015-01-26 15:04:35 -08003839 obj.match = ofp.match.unpack(reader)
3840 obj.instructions = loxi.generic_util.unpack_list(reader, ofp.instruction.instruction.unpack)
Rich Lane95f7fc92014-01-27 17:08:16 -08003841 return obj
3842
3843 def __eq__(self, other):
3844 if type(self) != type(other): return False
3845 if self.xid != other.xid: return False
3846 if self.cookie != other.cookie: return False
3847 if self.cookie_mask != other.cookie_mask: return False
3848 if self.table_id != other.table_id: return False
3849 if self._command != other._command: return False
3850 if self.idle_timeout != other.idle_timeout: return False
3851 if self.hard_timeout != other.hard_timeout: return False
3852 if self.priority != other.priority: return False
3853 if self.buffer_id != other.buffer_id: return False
3854 if self.out_port != other.out_port: return False
3855 if self.out_group != other.out_group: return False
3856 if self.flags != other.flags: return False
3857 if self.match != other.match: return False
3858 if self.instructions != other.instructions: return False
3859 return True
3860
3861 def pretty_print(self, q):
3862 q.text("flow_mod {")
3863 with q.group():
3864 with q.indent(2):
3865 q.breakable()
3866 q.text("xid = ");
3867 if self.xid != None:
3868 q.text("%#x" % self.xid)
3869 else:
3870 q.text('None')
3871 q.text(","); q.breakable()
3872 q.text("cookie = ");
3873 q.text("%#x" % self.cookie)
3874 q.text(","); q.breakable()
3875 q.text("cookie_mask = ");
3876 q.text("%#x" % self.cookie_mask)
3877 q.text(","); q.breakable()
3878 q.text("table_id = ");
3879 q.text("%#x" % self.table_id)
3880 q.text(","); q.breakable()
3881 q.text("idle_timeout = ");
3882 q.text("%#x" % self.idle_timeout)
3883 q.text(","); q.breakable()
3884 q.text("hard_timeout = ");
3885 q.text("%#x" % self.hard_timeout)
3886 q.text(","); q.breakable()
3887 q.text("priority = ");
3888 q.text("%#x" % self.priority)
3889 q.text(","); q.breakable()
3890 q.text("buffer_id = ");
3891 q.text("%#x" % self.buffer_id)
3892 q.text(","); q.breakable()
3893 q.text("out_port = ");
3894 q.text(util.pretty_port(self.out_port))
3895 q.text(","); q.breakable()
3896 q.text("out_group = ");
3897 q.text("%#x" % self.out_group)
3898 q.text(","); q.breakable()
3899 q.text("flags = ");
3900 q.text("%#x" % self.flags)
3901 q.text(","); q.breakable()
3902 q.text("match = ");
3903 q.pp(self.match)
3904 q.text(","); q.breakable()
3905 q.text("instructions = ");
3906 q.pp(self.instructions)
3907 q.breakable()
3908 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08003909
3910message.subtypes[14] = flow_mod
3911
3912class flow_add(flow_mod):
Dan Talaycof6202252013-07-02 01:00:29 -07003913 version = 2
3914 type = 14
3915 _command = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07003916
3917 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 -08003918 if xid != None:
3919 self.xid = xid
3920 else:
3921 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07003922 if cookie != None:
3923 self.cookie = cookie
3924 else:
3925 self.cookie = 0
3926 if cookie_mask != None:
3927 self.cookie_mask = cookie_mask
3928 else:
3929 self.cookie_mask = 0
3930 if table_id != None:
3931 self.table_id = table_id
3932 else:
3933 self.table_id = 0
3934 if idle_timeout != None:
3935 self.idle_timeout = idle_timeout
3936 else:
3937 self.idle_timeout = 0
3938 if hard_timeout != None:
3939 self.hard_timeout = hard_timeout
3940 else:
3941 self.hard_timeout = 0
3942 if priority != None:
3943 self.priority = priority
3944 else:
3945 self.priority = 0
3946 if buffer_id != None:
3947 self.buffer_id = buffer_id
3948 else:
3949 self.buffer_id = 0
3950 if out_port != None:
3951 self.out_port = out_port
3952 else:
3953 self.out_port = 0
3954 if out_group != None:
3955 self.out_group = out_group
3956 else:
3957 self.out_group = 0
3958 if flags != None:
3959 self.flags = flags
3960 else:
3961 self.flags = 0
3962 if match != None:
3963 self.match = match
3964 else:
Rich Lanee2567702015-01-26 15:04:35 -08003965 self.match = ofp.match()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003966 if instructions != None:
3967 self.instructions = instructions
3968 else:
3969 self.instructions = []
Rich Lane7dcdf022013-12-11 14:45:27 -08003970 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07003971
3972 def pack(self):
3973 packed = []
3974 packed.append(struct.pack("!B", self.version))
3975 packed.append(struct.pack("!B", self.type))
3976 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
3977 packed.append(struct.pack("!L", self.xid))
3978 packed.append(struct.pack("!Q", self.cookie))
3979 packed.append(struct.pack("!Q", self.cookie_mask))
3980 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003981 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003982 packed.append(struct.pack("!H", self.idle_timeout))
3983 packed.append(struct.pack("!H", self.hard_timeout))
3984 packed.append(struct.pack("!H", self.priority))
3985 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07003986 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003987 packed.append(struct.pack("!L", self.out_group))
3988 packed.append(struct.pack("!H", self.flags))
3989 packed.append('\x00' * 2)
3990 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08003991 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003992 length = sum([len(x) for x in packed])
3993 packed[2] = struct.pack("!H", length)
3994 return ''.join(packed)
3995
3996 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003997 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003998 obj = flow_add()
Dan Talaycof6202252013-07-02 01:00:29 -07003999 _version = reader.read("!B")[0]
4000 assert(_version == 2)
4001 _type = reader.read("!B")[0]
4002 assert(_type == 14)
4003 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004004 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08004005 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07004006 obj.xid = reader.read("!L")[0]
4007 obj.cookie = reader.read("!Q")[0]
4008 obj.cookie_mask = reader.read("!Q")[0]
4009 obj.table_id = reader.read("!B")[0]
4010 __command = util.unpack_fm_cmd(reader)
4011 assert(__command == 0)
4012 obj.idle_timeout = reader.read("!H")[0]
4013 obj.hard_timeout = reader.read("!H")[0]
4014 obj.priority = reader.read("!H")[0]
4015 obj.buffer_id = reader.read("!L")[0]
4016 obj.out_port = util.unpack_port_no(reader)
4017 obj.out_group = reader.read("!L")[0]
4018 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004019 reader.skip(2)
Rich Lanee2567702015-01-26 15:04:35 -08004020 obj.match = ofp.match.unpack(reader)
4021 obj.instructions = loxi.generic_util.unpack_list(reader, ofp.instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07004022 return obj
4023
4024 def __eq__(self, other):
4025 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004026 if self.xid != other.xid: return False
4027 if self.cookie != other.cookie: return False
4028 if self.cookie_mask != other.cookie_mask: return False
4029 if self.table_id != other.table_id: return False
4030 if self.idle_timeout != other.idle_timeout: return False
4031 if self.hard_timeout != other.hard_timeout: return False
4032 if self.priority != other.priority: return False
4033 if self.buffer_id != other.buffer_id: return False
4034 if self.out_port != other.out_port: return False
4035 if self.out_group != other.out_group: return False
4036 if self.flags != other.flags: return False
4037 if self.match != other.match: return False
4038 if self.instructions != other.instructions: return False
4039 return True
4040
Rich Lanec2ee4b82013-04-24 17:12:38 -07004041 def pretty_print(self, q):
4042 q.text("flow_add {")
4043 with q.group():
4044 with q.indent(2):
4045 q.breakable()
4046 q.text("xid = ");
4047 if self.xid != None:
4048 q.text("%#x" % self.xid)
4049 else:
4050 q.text('None')
4051 q.text(","); q.breakable()
4052 q.text("cookie = ");
4053 q.text("%#x" % self.cookie)
4054 q.text(","); q.breakable()
4055 q.text("cookie_mask = ");
4056 q.text("%#x" % self.cookie_mask)
4057 q.text(","); q.breakable()
4058 q.text("table_id = ");
4059 q.text("%#x" % self.table_id)
4060 q.text(","); q.breakable()
4061 q.text("idle_timeout = ");
4062 q.text("%#x" % self.idle_timeout)
4063 q.text(","); q.breakable()
4064 q.text("hard_timeout = ");
4065 q.text("%#x" % self.hard_timeout)
4066 q.text(","); q.breakable()
4067 q.text("priority = ");
4068 q.text("%#x" % self.priority)
4069 q.text(","); q.breakable()
4070 q.text("buffer_id = ");
4071 q.text("%#x" % self.buffer_id)
4072 q.text(","); q.breakable()
4073 q.text("out_port = ");
4074 q.text(util.pretty_port(self.out_port))
4075 q.text(","); q.breakable()
4076 q.text("out_group = ");
4077 q.text("%#x" % self.out_group)
4078 q.text(","); q.breakable()
4079 q.text("flags = ");
4080 q.text("%#x" % self.flags)
4081 q.text(","); q.breakable()
4082 q.text("match = ");
4083 q.pp(self.match)
4084 q.text(","); q.breakable()
4085 q.text("instructions = ");
4086 q.pp(self.instructions)
4087 q.breakable()
4088 q.text('}')
4089
Rich Lane7dcdf022013-12-11 14:45:27 -08004090flow_mod.subtypes[0] = flow_add
4091
4092class flow_delete(flow_mod):
Dan Talaycof6202252013-07-02 01:00:29 -07004093 version = 2
4094 type = 14
4095 _command = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07004096
4097 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 -08004098 if xid != None:
4099 self.xid = xid
4100 else:
4101 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004102 if cookie != None:
4103 self.cookie = cookie
4104 else:
4105 self.cookie = 0
4106 if cookie_mask != None:
4107 self.cookie_mask = cookie_mask
4108 else:
4109 self.cookie_mask = 0
4110 if table_id != None:
4111 self.table_id = table_id
4112 else:
4113 self.table_id = 0
4114 if idle_timeout != None:
4115 self.idle_timeout = idle_timeout
4116 else:
4117 self.idle_timeout = 0
4118 if hard_timeout != None:
4119 self.hard_timeout = hard_timeout
4120 else:
4121 self.hard_timeout = 0
4122 if priority != None:
4123 self.priority = priority
4124 else:
4125 self.priority = 0
4126 if buffer_id != None:
4127 self.buffer_id = buffer_id
4128 else:
4129 self.buffer_id = 0
4130 if out_port != None:
4131 self.out_port = out_port
4132 else:
4133 self.out_port = 0
4134 if out_group != None:
4135 self.out_group = out_group
4136 else:
4137 self.out_group = 0
4138 if flags != None:
4139 self.flags = flags
4140 else:
4141 self.flags = 0
4142 if match != None:
4143 self.match = match
4144 else:
Rich Lanee2567702015-01-26 15:04:35 -08004145 self.match = ofp.match()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004146 if instructions != None:
4147 self.instructions = instructions
4148 else:
4149 self.instructions = []
Rich Lane7dcdf022013-12-11 14:45:27 -08004150 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004151
4152 def pack(self):
4153 packed = []
4154 packed.append(struct.pack("!B", self.version))
4155 packed.append(struct.pack("!B", self.type))
4156 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4157 packed.append(struct.pack("!L", self.xid))
4158 packed.append(struct.pack("!Q", self.cookie))
4159 packed.append(struct.pack("!Q", self.cookie_mask))
4160 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004161 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004162 packed.append(struct.pack("!H", self.idle_timeout))
4163 packed.append(struct.pack("!H", self.hard_timeout))
4164 packed.append(struct.pack("!H", self.priority))
4165 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004166 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004167 packed.append(struct.pack("!L", self.out_group))
4168 packed.append(struct.pack("!H", self.flags))
4169 packed.append('\x00' * 2)
4170 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08004171 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004172 length = sum([len(x) for x in packed])
4173 packed[2] = struct.pack("!H", length)
4174 return ''.join(packed)
4175
4176 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004177 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004178 obj = flow_delete()
Dan Talaycof6202252013-07-02 01:00:29 -07004179 _version = reader.read("!B")[0]
4180 assert(_version == 2)
4181 _type = reader.read("!B")[0]
4182 assert(_type == 14)
4183 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004184 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08004185 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07004186 obj.xid = reader.read("!L")[0]
4187 obj.cookie = reader.read("!Q")[0]
4188 obj.cookie_mask = reader.read("!Q")[0]
4189 obj.table_id = reader.read("!B")[0]
4190 __command = util.unpack_fm_cmd(reader)
4191 assert(__command == 3)
4192 obj.idle_timeout = reader.read("!H")[0]
4193 obj.hard_timeout = reader.read("!H")[0]
4194 obj.priority = reader.read("!H")[0]
4195 obj.buffer_id = reader.read("!L")[0]
4196 obj.out_port = util.unpack_port_no(reader)
4197 obj.out_group = reader.read("!L")[0]
4198 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004199 reader.skip(2)
Rich Lanee2567702015-01-26 15:04:35 -08004200 obj.match = ofp.match.unpack(reader)
4201 obj.instructions = loxi.generic_util.unpack_list(reader, ofp.instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07004202 return obj
4203
4204 def __eq__(self, other):
4205 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004206 if self.xid != other.xid: return False
4207 if self.cookie != other.cookie: return False
4208 if self.cookie_mask != other.cookie_mask: return False
4209 if self.table_id != other.table_id: return False
4210 if self.idle_timeout != other.idle_timeout: return False
4211 if self.hard_timeout != other.hard_timeout: return False
4212 if self.priority != other.priority: return False
4213 if self.buffer_id != other.buffer_id: return False
4214 if self.out_port != other.out_port: return False
4215 if self.out_group != other.out_group: return False
4216 if self.flags != other.flags: return False
4217 if self.match != other.match: return False
4218 if self.instructions != other.instructions: return False
4219 return True
4220
Rich Lanec2ee4b82013-04-24 17:12:38 -07004221 def pretty_print(self, q):
4222 q.text("flow_delete {")
4223 with q.group():
4224 with q.indent(2):
4225 q.breakable()
4226 q.text("xid = ");
4227 if self.xid != None:
4228 q.text("%#x" % self.xid)
4229 else:
4230 q.text('None')
4231 q.text(","); q.breakable()
4232 q.text("cookie = ");
4233 q.text("%#x" % self.cookie)
4234 q.text(","); q.breakable()
4235 q.text("cookie_mask = ");
4236 q.text("%#x" % self.cookie_mask)
4237 q.text(","); q.breakable()
4238 q.text("table_id = ");
4239 q.text("%#x" % self.table_id)
4240 q.text(","); q.breakable()
4241 q.text("idle_timeout = ");
4242 q.text("%#x" % self.idle_timeout)
4243 q.text(","); q.breakable()
4244 q.text("hard_timeout = ");
4245 q.text("%#x" % self.hard_timeout)
4246 q.text(","); q.breakable()
4247 q.text("priority = ");
4248 q.text("%#x" % self.priority)
4249 q.text(","); q.breakable()
4250 q.text("buffer_id = ");
4251 q.text("%#x" % self.buffer_id)
4252 q.text(","); q.breakable()
4253 q.text("out_port = ");
4254 q.text(util.pretty_port(self.out_port))
4255 q.text(","); q.breakable()
4256 q.text("out_group = ");
4257 q.text("%#x" % self.out_group)
4258 q.text(","); q.breakable()
4259 q.text("flags = ");
4260 q.text("%#x" % self.flags)
4261 q.text(","); q.breakable()
4262 q.text("match = ");
4263 q.pp(self.match)
4264 q.text(","); q.breakable()
4265 q.text("instructions = ");
4266 q.pp(self.instructions)
4267 q.breakable()
4268 q.text('}')
4269
Rich Lane7dcdf022013-12-11 14:45:27 -08004270flow_mod.subtypes[3] = flow_delete
4271
4272class flow_delete_strict(flow_mod):
Dan Talaycof6202252013-07-02 01:00:29 -07004273 version = 2
4274 type = 14
4275 _command = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07004276
4277 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 -08004278 if xid != None:
4279 self.xid = xid
4280 else:
4281 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004282 if cookie != None:
4283 self.cookie = cookie
4284 else:
4285 self.cookie = 0
4286 if cookie_mask != None:
4287 self.cookie_mask = cookie_mask
4288 else:
4289 self.cookie_mask = 0
4290 if table_id != None:
4291 self.table_id = table_id
4292 else:
4293 self.table_id = 0
4294 if idle_timeout != None:
4295 self.idle_timeout = idle_timeout
4296 else:
4297 self.idle_timeout = 0
4298 if hard_timeout != None:
4299 self.hard_timeout = hard_timeout
4300 else:
4301 self.hard_timeout = 0
4302 if priority != None:
4303 self.priority = priority
4304 else:
4305 self.priority = 0
4306 if buffer_id != None:
4307 self.buffer_id = buffer_id
4308 else:
4309 self.buffer_id = 0
4310 if out_port != None:
4311 self.out_port = out_port
4312 else:
4313 self.out_port = 0
4314 if out_group != None:
4315 self.out_group = out_group
4316 else:
4317 self.out_group = 0
4318 if flags != None:
4319 self.flags = flags
4320 else:
4321 self.flags = 0
4322 if match != None:
4323 self.match = match
4324 else:
Rich Lanee2567702015-01-26 15:04:35 -08004325 self.match = ofp.match()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004326 if instructions != None:
4327 self.instructions = instructions
4328 else:
4329 self.instructions = []
Rich Lane7dcdf022013-12-11 14:45:27 -08004330 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004331
4332 def pack(self):
4333 packed = []
4334 packed.append(struct.pack("!B", self.version))
4335 packed.append(struct.pack("!B", self.type))
4336 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4337 packed.append(struct.pack("!L", self.xid))
4338 packed.append(struct.pack("!Q", self.cookie))
4339 packed.append(struct.pack("!Q", self.cookie_mask))
4340 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004341 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004342 packed.append(struct.pack("!H", self.idle_timeout))
4343 packed.append(struct.pack("!H", self.hard_timeout))
4344 packed.append(struct.pack("!H", self.priority))
4345 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004346 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004347 packed.append(struct.pack("!L", self.out_group))
4348 packed.append(struct.pack("!H", self.flags))
4349 packed.append('\x00' * 2)
4350 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08004351 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004352 length = sum([len(x) for x in packed])
4353 packed[2] = struct.pack("!H", length)
4354 return ''.join(packed)
4355
4356 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004357 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004358 obj = flow_delete_strict()
Dan Talaycof6202252013-07-02 01:00:29 -07004359 _version = reader.read("!B")[0]
4360 assert(_version == 2)
4361 _type = reader.read("!B")[0]
4362 assert(_type == 14)
4363 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004364 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08004365 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07004366 obj.xid = reader.read("!L")[0]
4367 obj.cookie = reader.read("!Q")[0]
4368 obj.cookie_mask = reader.read("!Q")[0]
4369 obj.table_id = reader.read("!B")[0]
4370 __command = util.unpack_fm_cmd(reader)
4371 assert(__command == 4)
4372 obj.idle_timeout = reader.read("!H")[0]
4373 obj.hard_timeout = reader.read("!H")[0]
4374 obj.priority = reader.read("!H")[0]
4375 obj.buffer_id = reader.read("!L")[0]
4376 obj.out_port = util.unpack_port_no(reader)
4377 obj.out_group = reader.read("!L")[0]
4378 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004379 reader.skip(2)
Rich Lanee2567702015-01-26 15:04:35 -08004380 obj.match = ofp.match.unpack(reader)
4381 obj.instructions = loxi.generic_util.unpack_list(reader, ofp.instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07004382 return obj
4383
4384 def __eq__(self, other):
4385 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004386 if self.xid != other.xid: return False
4387 if self.cookie != other.cookie: return False
4388 if self.cookie_mask != other.cookie_mask: return False
4389 if self.table_id != other.table_id: return False
4390 if self.idle_timeout != other.idle_timeout: return False
4391 if self.hard_timeout != other.hard_timeout: return False
4392 if self.priority != other.priority: return False
4393 if self.buffer_id != other.buffer_id: return False
4394 if self.out_port != other.out_port: return False
4395 if self.out_group != other.out_group: return False
4396 if self.flags != other.flags: return False
4397 if self.match != other.match: return False
4398 if self.instructions != other.instructions: return False
4399 return True
4400
Rich Lanec2ee4b82013-04-24 17:12:38 -07004401 def pretty_print(self, q):
4402 q.text("flow_delete_strict {")
4403 with q.group():
4404 with q.indent(2):
4405 q.breakable()
4406 q.text("xid = ");
4407 if self.xid != None:
4408 q.text("%#x" % self.xid)
4409 else:
4410 q.text('None')
4411 q.text(","); q.breakable()
4412 q.text("cookie = ");
4413 q.text("%#x" % self.cookie)
4414 q.text(","); q.breakable()
4415 q.text("cookie_mask = ");
4416 q.text("%#x" % self.cookie_mask)
4417 q.text(","); q.breakable()
4418 q.text("table_id = ");
4419 q.text("%#x" % self.table_id)
4420 q.text(","); q.breakable()
4421 q.text("idle_timeout = ");
4422 q.text("%#x" % self.idle_timeout)
4423 q.text(","); q.breakable()
4424 q.text("hard_timeout = ");
4425 q.text("%#x" % self.hard_timeout)
4426 q.text(","); q.breakable()
4427 q.text("priority = ");
4428 q.text("%#x" % self.priority)
4429 q.text(","); q.breakable()
4430 q.text("buffer_id = ");
4431 q.text("%#x" % self.buffer_id)
4432 q.text(","); q.breakable()
4433 q.text("out_port = ");
4434 q.text(util.pretty_port(self.out_port))
4435 q.text(","); q.breakable()
4436 q.text("out_group = ");
4437 q.text("%#x" % self.out_group)
4438 q.text(","); q.breakable()
4439 q.text("flags = ");
4440 q.text("%#x" % self.flags)
4441 q.text(","); q.breakable()
4442 q.text("match = ");
4443 q.pp(self.match)
4444 q.text(","); q.breakable()
4445 q.text("instructions = ");
4446 q.pp(self.instructions)
4447 q.breakable()
4448 q.text('}')
4449
Rich Lane7dcdf022013-12-11 14:45:27 -08004450flow_mod.subtypes[4] = flow_delete_strict
4451
4452class flow_mod_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07004453 version = 2
4454 type = 1
4455 err_type = 5
4456
4457 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08004458 if xid != None:
4459 self.xid = xid
4460 else:
4461 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07004462 if code != None:
4463 self.code = code
4464 else:
4465 self.code = 0
4466 if data != None:
4467 self.data = data
4468 else:
4469 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08004470 return
Rich Lane6f4978c2013-10-20 21:33:52 -07004471
4472 def pack(self):
4473 packed = []
4474 packed.append(struct.pack("!B", self.version))
4475 packed.append(struct.pack("!B", self.type))
4476 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4477 packed.append(struct.pack("!L", self.xid))
4478 packed.append(struct.pack("!H", self.err_type))
4479 packed.append(struct.pack("!H", self.code))
4480 packed.append(self.data)
4481 length = sum([len(x) for x in packed])
4482 packed[2] = struct.pack("!H", length)
4483 return ''.join(packed)
4484
4485 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004486 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07004487 obj = flow_mod_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07004488 _version = reader.read("!B")[0]
4489 assert(_version == 2)
4490 _type = reader.read("!B")[0]
4491 assert(_type == 1)
4492 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004493 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08004494 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -07004495 obj.xid = reader.read("!L")[0]
4496 _err_type = reader.read("!H")[0]
4497 assert(_err_type == 5)
4498 obj.code = reader.read("!H")[0]
4499 obj.data = str(reader.read_all())
4500 return obj
4501
4502 def __eq__(self, other):
4503 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07004504 if self.xid != other.xid: return False
4505 if self.code != other.code: return False
4506 if self.data != other.data: return False
4507 return True
4508
Rich Lane6f4978c2013-10-20 21:33:52 -07004509 def pretty_print(self, q):
4510 q.text("flow_mod_failed_error_msg {")
4511 with q.group():
4512 with q.indent(2):
4513 q.breakable()
4514 q.text("xid = ");
4515 if self.xid != None:
4516 q.text("%#x" % self.xid)
4517 else:
4518 q.text('None')
4519 q.text(","); q.breakable()
4520 q.text("code = ");
4521 q.text("%#x" % self.code)
4522 q.text(","); q.breakable()
4523 q.text("data = ");
4524 q.pp(self.data)
4525 q.breakable()
4526 q.text('}')
4527
Rich Lane7dcdf022013-12-11 14:45:27 -08004528error_msg.subtypes[5] = flow_mod_failed_error_msg
4529
4530class flow_modify(flow_mod):
Dan Talaycof6202252013-07-02 01:00:29 -07004531 version = 2
4532 type = 14
4533 _command = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07004534
4535 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 -08004536 if xid != None:
4537 self.xid = xid
4538 else:
4539 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004540 if cookie != None:
4541 self.cookie = cookie
4542 else:
4543 self.cookie = 0
4544 if cookie_mask != None:
4545 self.cookie_mask = cookie_mask
4546 else:
4547 self.cookie_mask = 0
4548 if table_id != None:
4549 self.table_id = table_id
4550 else:
4551 self.table_id = 0
4552 if idle_timeout != None:
4553 self.idle_timeout = idle_timeout
4554 else:
4555 self.idle_timeout = 0
4556 if hard_timeout != None:
4557 self.hard_timeout = hard_timeout
4558 else:
4559 self.hard_timeout = 0
4560 if priority != None:
4561 self.priority = priority
4562 else:
4563 self.priority = 0
4564 if buffer_id != None:
4565 self.buffer_id = buffer_id
4566 else:
4567 self.buffer_id = 0
4568 if out_port != None:
4569 self.out_port = out_port
4570 else:
4571 self.out_port = 0
4572 if out_group != None:
4573 self.out_group = out_group
4574 else:
4575 self.out_group = 0
4576 if flags != None:
4577 self.flags = flags
4578 else:
4579 self.flags = 0
4580 if match != None:
4581 self.match = match
4582 else:
Rich Lanee2567702015-01-26 15:04:35 -08004583 self.match = ofp.match()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004584 if instructions != None:
4585 self.instructions = instructions
4586 else:
4587 self.instructions = []
Rich Lane7dcdf022013-12-11 14:45:27 -08004588 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004589
4590 def pack(self):
4591 packed = []
4592 packed.append(struct.pack("!B", self.version))
4593 packed.append(struct.pack("!B", self.type))
4594 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4595 packed.append(struct.pack("!L", self.xid))
4596 packed.append(struct.pack("!Q", self.cookie))
4597 packed.append(struct.pack("!Q", self.cookie_mask))
4598 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004599 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004600 packed.append(struct.pack("!H", self.idle_timeout))
4601 packed.append(struct.pack("!H", self.hard_timeout))
4602 packed.append(struct.pack("!H", self.priority))
4603 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004604 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004605 packed.append(struct.pack("!L", self.out_group))
4606 packed.append(struct.pack("!H", self.flags))
4607 packed.append('\x00' * 2)
4608 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08004609 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004610 length = sum([len(x) for x in packed])
4611 packed[2] = struct.pack("!H", length)
4612 return ''.join(packed)
4613
4614 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004615 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004616 obj = flow_modify()
Dan Talaycof6202252013-07-02 01:00:29 -07004617 _version = reader.read("!B")[0]
4618 assert(_version == 2)
4619 _type = reader.read("!B")[0]
4620 assert(_type == 14)
4621 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004622 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08004623 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07004624 obj.xid = reader.read("!L")[0]
4625 obj.cookie = reader.read("!Q")[0]
4626 obj.cookie_mask = reader.read("!Q")[0]
4627 obj.table_id = reader.read("!B")[0]
4628 __command = util.unpack_fm_cmd(reader)
4629 assert(__command == 1)
4630 obj.idle_timeout = reader.read("!H")[0]
4631 obj.hard_timeout = reader.read("!H")[0]
4632 obj.priority = reader.read("!H")[0]
4633 obj.buffer_id = reader.read("!L")[0]
4634 obj.out_port = util.unpack_port_no(reader)
4635 obj.out_group = reader.read("!L")[0]
4636 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004637 reader.skip(2)
Rich Lanee2567702015-01-26 15:04:35 -08004638 obj.match = ofp.match.unpack(reader)
4639 obj.instructions = loxi.generic_util.unpack_list(reader, ofp.instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07004640 return obj
4641
4642 def __eq__(self, other):
4643 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004644 if self.xid != other.xid: return False
4645 if self.cookie != other.cookie: return False
4646 if self.cookie_mask != other.cookie_mask: return False
4647 if self.table_id != other.table_id: return False
4648 if self.idle_timeout != other.idle_timeout: return False
4649 if self.hard_timeout != other.hard_timeout: return False
4650 if self.priority != other.priority: return False
4651 if self.buffer_id != other.buffer_id: return False
4652 if self.out_port != other.out_port: return False
4653 if self.out_group != other.out_group: return False
4654 if self.flags != other.flags: return False
4655 if self.match != other.match: return False
4656 if self.instructions != other.instructions: return False
4657 return True
4658
Rich Lanec2ee4b82013-04-24 17:12:38 -07004659 def pretty_print(self, q):
4660 q.text("flow_modify {")
4661 with q.group():
4662 with q.indent(2):
4663 q.breakable()
4664 q.text("xid = ");
4665 if self.xid != None:
4666 q.text("%#x" % self.xid)
4667 else:
4668 q.text('None')
4669 q.text(","); q.breakable()
4670 q.text("cookie = ");
4671 q.text("%#x" % self.cookie)
4672 q.text(","); q.breakable()
4673 q.text("cookie_mask = ");
4674 q.text("%#x" % self.cookie_mask)
4675 q.text(","); q.breakable()
4676 q.text("table_id = ");
4677 q.text("%#x" % self.table_id)
4678 q.text(","); q.breakable()
4679 q.text("idle_timeout = ");
4680 q.text("%#x" % self.idle_timeout)
4681 q.text(","); q.breakable()
4682 q.text("hard_timeout = ");
4683 q.text("%#x" % self.hard_timeout)
4684 q.text(","); q.breakable()
4685 q.text("priority = ");
4686 q.text("%#x" % self.priority)
4687 q.text(","); q.breakable()
4688 q.text("buffer_id = ");
4689 q.text("%#x" % self.buffer_id)
4690 q.text(","); q.breakable()
4691 q.text("out_port = ");
4692 q.text(util.pretty_port(self.out_port))
4693 q.text(","); q.breakable()
4694 q.text("out_group = ");
4695 q.text("%#x" % self.out_group)
4696 q.text(","); q.breakable()
4697 q.text("flags = ");
4698 q.text("%#x" % self.flags)
4699 q.text(","); q.breakable()
4700 q.text("match = ");
4701 q.pp(self.match)
4702 q.text(","); q.breakable()
4703 q.text("instructions = ");
4704 q.pp(self.instructions)
4705 q.breakable()
4706 q.text('}')
4707
Rich Lane7dcdf022013-12-11 14:45:27 -08004708flow_mod.subtypes[1] = flow_modify
4709
4710class flow_modify_strict(flow_mod):
Dan Talaycof6202252013-07-02 01:00:29 -07004711 version = 2
4712 type = 14
4713 _command = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07004714
4715 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 -08004716 if xid != None:
4717 self.xid = xid
4718 else:
4719 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004720 if cookie != None:
4721 self.cookie = cookie
4722 else:
4723 self.cookie = 0
4724 if cookie_mask != None:
4725 self.cookie_mask = cookie_mask
4726 else:
4727 self.cookie_mask = 0
4728 if table_id != None:
4729 self.table_id = table_id
4730 else:
4731 self.table_id = 0
4732 if idle_timeout != None:
4733 self.idle_timeout = idle_timeout
4734 else:
4735 self.idle_timeout = 0
4736 if hard_timeout != None:
4737 self.hard_timeout = hard_timeout
4738 else:
4739 self.hard_timeout = 0
4740 if priority != None:
4741 self.priority = priority
4742 else:
4743 self.priority = 0
4744 if buffer_id != None:
4745 self.buffer_id = buffer_id
4746 else:
4747 self.buffer_id = 0
4748 if out_port != None:
4749 self.out_port = out_port
4750 else:
4751 self.out_port = 0
4752 if out_group != None:
4753 self.out_group = out_group
4754 else:
4755 self.out_group = 0
4756 if flags != None:
4757 self.flags = flags
4758 else:
4759 self.flags = 0
4760 if match != None:
4761 self.match = match
4762 else:
Rich Lanee2567702015-01-26 15:04:35 -08004763 self.match = ofp.match()
Rich Lanec2ee4b82013-04-24 17:12:38 -07004764 if instructions != None:
4765 self.instructions = instructions
4766 else:
4767 self.instructions = []
Rich Lane7dcdf022013-12-11 14:45:27 -08004768 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004769
4770 def pack(self):
4771 packed = []
4772 packed.append(struct.pack("!B", self.version))
4773 packed.append(struct.pack("!B", self.type))
4774 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4775 packed.append(struct.pack("!L", self.xid))
4776 packed.append(struct.pack("!Q", self.cookie))
4777 packed.append(struct.pack("!Q", self.cookie_mask))
4778 packed.append(struct.pack("!B", self.table_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004779 packed.append(util.pack_fm_cmd(self._command))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004780 packed.append(struct.pack("!H", self.idle_timeout))
4781 packed.append(struct.pack("!H", self.hard_timeout))
4782 packed.append(struct.pack("!H", self.priority))
4783 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07004784 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004785 packed.append(struct.pack("!L", self.out_group))
4786 packed.append(struct.pack("!H", self.flags))
4787 packed.append('\x00' * 2)
4788 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08004789 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07004790 length = sum([len(x) for x in packed])
4791 packed[2] = struct.pack("!H", length)
4792 return ''.join(packed)
4793
4794 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004795 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004796 obj = flow_modify_strict()
Dan Talaycof6202252013-07-02 01:00:29 -07004797 _version = reader.read("!B")[0]
4798 assert(_version == 2)
4799 _type = reader.read("!B")[0]
4800 assert(_type == 14)
4801 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004802 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08004803 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07004804 obj.xid = reader.read("!L")[0]
4805 obj.cookie = reader.read("!Q")[0]
4806 obj.cookie_mask = reader.read("!Q")[0]
4807 obj.table_id = reader.read("!B")[0]
4808 __command = util.unpack_fm_cmd(reader)
4809 assert(__command == 2)
4810 obj.idle_timeout = reader.read("!H")[0]
4811 obj.hard_timeout = reader.read("!H")[0]
4812 obj.priority = reader.read("!H")[0]
4813 obj.buffer_id = reader.read("!L")[0]
4814 obj.out_port = util.unpack_port_no(reader)
4815 obj.out_group = reader.read("!L")[0]
4816 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004817 reader.skip(2)
Rich Lanee2567702015-01-26 15:04:35 -08004818 obj.match = ofp.match.unpack(reader)
4819 obj.instructions = loxi.generic_util.unpack_list(reader, ofp.instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07004820 return obj
4821
4822 def __eq__(self, other):
4823 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004824 if self.xid != other.xid: return False
4825 if self.cookie != other.cookie: return False
4826 if self.cookie_mask != other.cookie_mask: return False
4827 if self.table_id != other.table_id: return False
4828 if self.idle_timeout != other.idle_timeout: return False
4829 if self.hard_timeout != other.hard_timeout: return False
4830 if self.priority != other.priority: return False
4831 if self.buffer_id != other.buffer_id: return False
4832 if self.out_port != other.out_port: return False
4833 if self.out_group != other.out_group: return False
4834 if self.flags != other.flags: return False
4835 if self.match != other.match: return False
4836 if self.instructions != other.instructions: return False
4837 return True
4838
Rich Lanec2ee4b82013-04-24 17:12:38 -07004839 def pretty_print(self, q):
4840 q.text("flow_modify_strict {")
4841 with q.group():
4842 with q.indent(2):
4843 q.breakable()
4844 q.text("xid = ");
4845 if self.xid != None:
4846 q.text("%#x" % self.xid)
4847 else:
4848 q.text('None')
4849 q.text(","); q.breakable()
4850 q.text("cookie = ");
4851 q.text("%#x" % self.cookie)
4852 q.text(","); q.breakable()
4853 q.text("cookie_mask = ");
4854 q.text("%#x" % self.cookie_mask)
4855 q.text(","); q.breakable()
4856 q.text("table_id = ");
4857 q.text("%#x" % self.table_id)
4858 q.text(","); q.breakable()
4859 q.text("idle_timeout = ");
4860 q.text("%#x" % self.idle_timeout)
4861 q.text(","); q.breakable()
4862 q.text("hard_timeout = ");
4863 q.text("%#x" % self.hard_timeout)
4864 q.text(","); q.breakable()
4865 q.text("priority = ");
4866 q.text("%#x" % self.priority)
4867 q.text(","); q.breakable()
4868 q.text("buffer_id = ");
4869 q.text("%#x" % self.buffer_id)
4870 q.text(","); q.breakable()
4871 q.text("out_port = ");
4872 q.text(util.pretty_port(self.out_port))
4873 q.text(","); q.breakable()
4874 q.text("out_group = ");
4875 q.text("%#x" % self.out_group)
4876 q.text(","); q.breakable()
4877 q.text("flags = ");
4878 q.text("%#x" % self.flags)
4879 q.text(","); q.breakable()
4880 q.text("match = ");
4881 q.pp(self.match)
4882 q.text(","); q.breakable()
4883 q.text("instructions = ");
4884 q.pp(self.instructions)
4885 q.breakable()
4886 q.text('}')
4887
Rich Lane7dcdf022013-12-11 14:45:27 -08004888flow_mod.subtypes[2] = flow_modify_strict
4889
4890class flow_removed(message):
Dan Talaycof6202252013-07-02 01:00:29 -07004891 version = 2
4892 type = 11
Rich Lanec2ee4b82013-04-24 17:12:38 -07004893
4894 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 -08004895 if xid != None:
4896 self.xid = xid
4897 else:
4898 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07004899 if cookie != None:
4900 self.cookie = cookie
4901 else:
4902 self.cookie = 0
4903 if priority != None:
4904 self.priority = priority
4905 else:
4906 self.priority = 0
4907 if reason != None:
4908 self.reason = reason
4909 else:
4910 self.reason = 0
4911 if table_id != None:
4912 self.table_id = table_id
4913 else:
4914 self.table_id = 0
4915 if duration_sec != None:
4916 self.duration_sec = duration_sec
4917 else:
4918 self.duration_sec = 0
4919 if duration_nsec != None:
4920 self.duration_nsec = duration_nsec
4921 else:
4922 self.duration_nsec = 0
4923 if idle_timeout != None:
4924 self.idle_timeout = idle_timeout
4925 else:
4926 self.idle_timeout = 0
4927 if packet_count != None:
4928 self.packet_count = packet_count
4929 else:
4930 self.packet_count = 0
4931 if byte_count != None:
4932 self.byte_count = byte_count
4933 else:
4934 self.byte_count = 0
4935 if match != None:
4936 self.match = match
4937 else:
Rich Lanee2567702015-01-26 15:04:35 -08004938 self.match = ofp.match()
Rich Lane7dcdf022013-12-11 14:45:27 -08004939 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07004940
4941 def pack(self):
4942 packed = []
4943 packed.append(struct.pack("!B", self.version))
4944 packed.append(struct.pack("!B", self.type))
4945 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
4946 packed.append(struct.pack("!L", self.xid))
4947 packed.append(struct.pack("!Q", self.cookie))
4948 packed.append(struct.pack("!H", self.priority))
4949 packed.append(struct.pack("!B", self.reason))
4950 packed.append(struct.pack("!B", self.table_id))
4951 packed.append(struct.pack("!L", self.duration_sec))
4952 packed.append(struct.pack("!L", self.duration_nsec))
4953 packed.append(struct.pack("!H", self.idle_timeout))
4954 packed.append('\x00' * 2)
4955 packed.append(struct.pack("!Q", self.packet_count))
4956 packed.append(struct.pack("!Q", self.byte_count))
4957 packed.append(self.match.pack())
4958 length = sum([len(x) for x in packed])
4959 packed[2] = struct.pack("!H", length)
4960 return ''.join(packed)
4961
4962 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004963 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004964 obj = flow_removed()
Dan Talaycof6202252013-07-02 01:00:29 -07004965 _version = reader.read("!B")[0]
4966 assert(_version == 2)
4967 _type = reader.read("!B")[0]
4968 assert(_type == 11)
4969 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08004970 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08004971 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07004972 obj.xid = reader.read("!L")[0]
4973 obj.cookie = reader.read("!Q")[0]
4974 obj.priority = reader.read("!H")[0]
4975 obj.reason = reader.read("!B")[0]
4976 obj.table_id = reader.read("!B")[0]
4977 obj.duration_sec = reader.read("!L")[0]
4978 obj.duration_nsec = reader.read("!L")[0]
4979 obj.idle_timeout = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004980 reader.skip(2)
Dan Talaycof6202252013-07-02 01:00:29 -07004981 obj.packet_count = reader.read("!Q")[0]
4982 obj.byte_count = reader.read("!Q")[0]
Rich Lanee2567702015-01-26 15:04:35 -08004983 obj.match = ofp.match.unpack(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07004984 return obj
4985
4986 def __eq__(self, other):
4987 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07004988 if self.xid != other.xid: return False
4989 if self.cookie != other.cookie: return False
4990 if self.priority != other.priority: return False
4991 if self.reason != other.reason: return False
4992 if self.table_id != other.table_id: return False
4993 if self.duration_sec != other.duration_sec: return False
4994 if self.duration_nsec != other.duration_nsec: return False
4995 if self.idle_timeout != other.idle_timeout: return False
4996 if self.packet_count != other.packet_count: return False
4997 if self.byte_count != other.byte_count: return False
4998 if self.match != other.match: return False
4999 return True
5000
Rich Lanec2ee4b82013-04-24 17:12:38 -07005001 def pretty_print(self, q):
5002 q.text("flow_removed {")
5003 with q.group():
5004 with q.indent(2):
5005 q.breakable()
5006 q.text("xid = ");
5007 if self.xid != None:
5008 q.text("%#x" % self.xid)
5009 else:
5010 q.text('None')
5011 q.text(","); q.breakable()
5012 q.text("cookie = ");
5013 q.text("%#x" % self.cookie)
5014 q.text(","); q.breakable()
5015 q.text("priority = ");
5016 q.text("%#x" % self.priority)
5017 q.text(","); q.breakable()
5018 q.text("reason = ");
5019 q.text("%#x" % self.reason)
5020 q.text(","); q.breakable()
5021 q.text("table_id = ");
5022 q.text("%#x" % self.table_id)
5023 q.text(","); q.breakable()
5024 q.text("duration_sec = ");
5025 q.text("%#x" % self.duration_sec)
5026 q.text(","); q.breakable()
5027 q.text("duration_nsec = ");
5028 q.text("%#x" % self.duration_nsec)
5029 q.text(","); q.breakable()
5030 q.text("idle_timeout = ");
5031 q.text("%#x" % self.idle_timeout)
5032 q.text(","); q.breakable()
5033 q.text("packet_count = ");
5034 q.text("%#x" % self.packet_count)
5035 q.text(","); q.breakable()
5036 q.text("byte_count = ");
5037 q.text("%#x" % self.byte_count)
5038 q.text(","); q.breakable()
5039 q.text("match = ");
5040 q.pp(self.match)
5041 q.breakable()
5042 q.text('}')
5043
Rich Lane7dcdf022013-12-11 14:45:27 -08005044message.subtypes[11] = flow_removed
5045
5046class flow_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07005047 version = 2
5048 type = 19
5049 stats_type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07005050
5051 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005052 if xid != None:
5053 self.xid = xid
5054 else:
5055 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005056 if flags != None:
5057 self.flags = flags
5058 else:
5059 self.flags = 0
5060 if entries != None:
5061 self.entries = entries
5062 else:
5063 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08005064 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005065
5066 def pack(self):
5067 packed = []
5068 packed.append(struct.pack("!B", self.version))
5069 packed.append(struct.pack("!B", self.type))
5070 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5071 packed.append(struct.pack("!L", self.xid))
5072 packed.append(struct.pack("!H", self.stats_type))
5073 packed.append(struct.pack("!H", self.flags))
5074 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08005075 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005076 length = sum([len(x) for x in packed])
5077 packed[2] = struct.pack("!H", length)
5078 return ''.join(packed)
5079
5080 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005081 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005082 obj = flow_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07005083 _version = reader.read("!B")[0]
5084 assert(_version == 2)
5085 _type = reader.read("!B")[0]
5086 assert(_type == 19)
5087 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005088 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08005089 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07005090 obj.xid = reader.read("!L")[0]
5091 _stats_type = reader.read("!H")[0]
5092 assert(_stats_type == 1)
5093 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005094 reader.skip(4)
Rich Lanee2567702015-01-26 15:04:35 -08005095 obj.entries = loxi.generic_util.unpack_list(reader, ofp.common.flow_stats_entry.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07005096 return obj
5097
5098 def __eq__(self, other):
5099 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005100 if self.xid != other.xid: return False
5101 if self.flags != other.flags: return False
5102 if self.entries != other.entries: return False
5103 return True
5104
Rich Lanec2ee4b82013-04-24 17:12:38 -07005105 def pretty_print(self, q):
5106 q.text("flow_stats_reply {")
5107 with q.group():
5108 with q.indent(2):
5109 q.breakable()
5110 q.text("xid = ");
5111 if self.xid != None:
5112 q.text("%#x" % self.xid)
5113 else:
5114 q.text('None')
5115 q.text(","); q.breakable()
5116 q.text("flags = ");
5117 q.text("%#x" % self.flags)
5118 q.text(","); q.breakable()
5119 q.text("entries = ");
5120 q.pp(self.entries)
5121 q.breakable()
5122 q.text('}')
5123
Rich Lane7dcdf022013-12-11 14:45:27 -08005124stats_reply.subtypes[1] = flow_stats_reply
5125
5126class flow_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07005127 version = 2
5128 type = 18
5129 stats_type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07005130
5131 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 -08005132 if xid != None:
5133 self.xid = xid
5134 else:
5135 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005136 if flags != None:
5137 self.flags = flags
5138 else:
5139 self.flags = 0
5140 if table_id != None:
5141 self.table_id = table_id
5142 else:
5143 self.table_id = 0
5144 if out_port != None:
5145 self.out_port = out_port
5146 else:
5147 self.out_port = 0
5148 if out_group != None:
5149 self.out_group = out_group
5150 else:
5151 self.out_group = 0
5152 if cookie != None:
5153 self.cookie = cookie
5154 else:
5155 self.cookie = 0
5156 if cookie_mask != None:
5157 self.cookie_mask = cookie_mask
5158 else:
5159 self.cookie_mask = 0
5160 if match != None:
5161 self.match = match
5162 else:
Rich Lanee2567702015-01-26 15:04:35 -08005163 self.match = ofp.match()
Rich Lane7dcdf022013-12-11 14:45:27 -08005164 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005165
5166 def pack(self):
5167 packed = []
5168 packed.append(struct.pack("!B", self.version))
5169 packed.append(struct.pack("!B", self.type))
5170 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5171 packed.append(struct.pack("!L", self.xid))
5172 packed.append(struct.pack("!H", self.stats_type))
5173 packed.append(struct.pack("!H", self.flags))
5174 packed.append('\x00' * 4)
5175 packed.append(struct.pack("!B", self.table_id))
5176 packed.append('\x00' * 3)
Dan Talaycof6202252013-07-02 01:00:29 -07005177 packed.append(util.pack_port_no(self.out_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005178 packed.append(struct.pack("!L", self.out_group))
5179 packed.append('\x00' * 4)
5180 packed.append(struct.pack("!Q", self.cookie))
5181 packed.append(struct.pack("!Q", self.cookie_mask))
5182 packed.append(self.match.pack())
5183 length = sum([len(x) for x in packed])
5184 packed[2] = struct.pack("!H", length)
5185 return ''.join(packed)
5186
5187 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005188 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005189 obj = flow_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07005190 _version = reader.read("!B")[0]
5191 assert(_version == 2)
5192 _type = reader.read("!B")[0]
5193 assert(_type == 18)
5194 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005195 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08005196 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07005197 obj.xid = reader.read("!L")[0]
5198 _stats_type = reader.read("!H")[0]
5199 assert(_stats_type == 1)
5200 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005201 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07005202 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005203 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07005204 obj.out_port = util.unpack_port_no(reader)
5205 obj.out_group = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005206 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07005207 obj.cookie = reader.read("!Q")[0]
5208 obj.cookie_mask = reader.read("!Q")[0]
Rich Lanee2567702015-01-26 15:04:35 -08005209 obj.match = ofp.match.unpack(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07005210 return obj
5211
5212 def __eq__(self, other):
5213 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005214 if self.xid != other.xid: return False
5215 if self.flags != other.flags: return False
5216 if self.table_id != other.table_id: return False
5217 if self.out_port != other.out_port: return False
5218 if self.out_group != other.out_group: return False
5219 if self.cookie != other.cookie: return False
5220 if self.cookie_mask != other.cookie_mask: return False
5221 if self.match != other.match: return False
5222 return True
5223
Rich Lanec2ee4b82013-04-24 17:12:38 -07005224 def pretty_print(self, q):
5225 q.text("flow_stats_request {")
5226 with q.group():
5227 with q.indent(2):
5228 q.breakable()
5229 q.text("xid = ");
5230 if self.xid != None:
5231 q.text("%#x" % self.xid)
5232 else:
5233 q.text('None')
5234 q.text(","); q.breakable()
5235 q.text("flags = ");
5236 q.text("%#x" % self.flags)
5237 q.text(","); q.breakable()
5238 q.text("table_id = ");
5239 q.text("%#x" % self.table_id)
5240 q.text(","); q.breakable()
5241 q.text("out_port = ");
5242 q.text(util.pretty_port(self.out_port))
5243 q.text(","); q.breakable()
5244 q.text("out_group = ");
5245 q.text("%#x" % self.out_group)
5246 q.text(","); q.breakable()
5247 q.text("cookie = ");
5248 q.text("%#x" % self.cookie)
5249 q.text(","); q.breakable()
5250 q.text("cookie_mask = ");
5251 q.text("%#x" % self.cookie_mask)
5252 q.text(","); q.breakable()
5253 q.text("match = ");
5254 q.pp(self.match)
5255 q.breakable()
5256 q.text('}')
5257
Rich Lane7dcdf022013-12-11 14:45:27 -08005258stats_request.subtypes[1] = flow_stats_request
5259
5260class get_config_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -07005261 version = 2
5262 type = 8
Rich Lanec2ee4b82013-04-24 17:12:38 -07005263
5264 def __init__(self, xid=None, flags=None, miss_send_len=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005265 if xid != None:
5266 self.xid = xid
5267 else:
5268 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005269 if flags != None:
5270 self.flags = flags
5271 else:
5272 self.flags = 0
5273 if miss_send_len != None:
5274 self.miss_send_len = miss_send_len
5275 else:
5276 self.miss_send_len = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08005277 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005278
5279 def pack(self):
5280 packed = []
5281 packed.append(struct.pack("!B", self.version))
5282 packed.append(struct.pack("!B", self.type))
5283 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5284 packed.append(struct.pack("!L", self.xid))
5285 packed.append(struct.pack("!H", self.flags))
5286 packed.append(struct.pack("!H", self.miss_send_len))
5287 length = sum([len(x) for x in packed])
5288 packed[2] = struct.pack("!H", length)
5289 return ''.join(packed)
5290
5291 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005292 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005293 obj = get_config_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07005294 _version = reader.read("!B")[0]
5295 assert(_version == 2)
5296 _type = reader.read("!B")[0]
5297 assert(_type == 8)
5298 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005299 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08005300 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07005301 obj.xid = reader.read("!L")[0]
5302 obj.flags = reader.read("!H")[0]
5303 obj.miss_send_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005304 return obj
5305
5306 def __eq__(self, other):
5307 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005308 if self.xid != other.xid: return False
5309 if self.flags != other.flags: return False
5310 if self.miss_send_len != other.miss_send_len: return False
5311 return True
5312
Rich Lanec2ee4b82013-04-24 17:12:38 -07005313 def pretty_print(self, q):
5314 q.text("get_config_reply {")
5315 with q.group():
5316 with q.indent(2):
5317 q.breakable()
5318 q.text("xid = ");
5319 if self.xid != None:
5320 q.text("%#x" % self.xid)
5321 else:
5322 q.text('None')
5323 q.text(","); q.breakable()
5324 q.text("flags = ");
5325 q.text("%#x" % self.flags)
5326 q.text(","); q.breakable()
5327 q.text("miss_send_len = ");
5328 q.text("%#x" % self.miss_send_len)
5329 q.breakable()
5330 q.text('}')
5331
Rich Lane7dcdf022013-12-11 14:45:27 -08005332message.subtypes[8] = get_config_reply
5333
5334class get_config_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -07005335 version = 2
5336 type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07005337
5338 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005339 if xid != None:
5340 self.xid = xid
5341 else:
5342 self.xid = None
5343 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005344
5345 def pack(self):
5346 packed = []
5347 packed.append(struct.pack("!B", self.version))
5348 packed.append(struct.pack("!B", self.type))
5349 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5350 packed.append(struct.pack("!L", self.xid))
5351 length = sum([len(x) for x in packed])
5352 packed[2] = struct.pack("!H", length)
5353 return ''.join(packed)
5354
5355 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005356 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005357 obj = get_config_request()
Dan Talaycof6202252013-07-02 01:00:29 -07005358 _version = reader.read("!B")[0]
5359 assert(_version == 2)
5360 _type = reader.read("!B")[0]
5361 assert(_type == 7)
5362 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005363 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08005364 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07005365 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005366 return obj
5367
5368 def __eq__(self, other):
5369 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005370 if self.xid != other.xid: return False
5371 return True
5372
Rich Lanec2ee4b82013-04-24 17:12:38 -07005373 def pretty_print(self, q):
5374 q.text("get_config_request {")
5375 with q.group():
5376 with q.indent(2):
5377 q.breakable()
5378 q.text("xid = ");
5379 if self.xid != None:
5380 q.text("%#x" % self.xid)
5381 else:
5382 q.text('None')
5383 q.breakable()
5384 q.text('}')
5385
Rich Lane7dcdf022013-12-11 14:45:27 -08005386message.subtypes[7] = get_config_request
5387
5388class group_mod(message):
5389 subtypes = {}
5390
Rich Lane95f7fc92014-01-27 17:08:16 -08005391 version = 2
5392 type = 15
5393
5394 def __init__(self, xid=None, command=None, group_type=None, group_id=None, buckets=None):
5395 if xid != None:
5396 self.xid = xid
5397 else:
5398 self.xid = None
5399 if command != None:
5400 self.command = command
5401 else:
5402 self.command = 0
5403 if group_type != None:
5404 self.group_type = group_type
5405 else:
5406 self.group_type = 0
5407 if group_id != None:
5408 self.group_id = group_id
5409 else:
5410 self.group_id = 0
5411 if buckets != None:
5412 self.buckets = buckets
5413 else:
5414 self.buckets = []
5415 return
5416
5417 def pack(self):
5418 packed = []
5419 packed.append(struct.pack("!B", self.version))
5420 packed.append(struct.pack("!B", self.type))
5421 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5422 packed.append(struct.pack("!L", self.xid))
5423 packed.append(struct.pack("!H", self.command))
5424 packed.append(struct.pack("!B", self.group_type))
5425 packed.append('\x00' * 1)
5426 packed.append(struct.pack("!L", self.group_id))
5427 packed.append(loxi.generic_util.pack_list(self.buckets))
5428 length = sum([len(x) for x in packed])
5429 packed[2] = struct.pack("!H", length)
5430 return ''.join(packed)
5431
Rich Lane7dcdf022013-12-11 14:45:27 -08005432 @staticmethod
5433 def unpack(reader):
5434 subtype, = reader.peek('!H', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -08005435 subclass = group_mod.subtypes.get(subtype)
5436 if subclass:
5437 return subclass.unpack(reader)
5438
5439 obj = group_mod()
5440 _version = reader.read("!B")[0]
5441 assert(_version == 2)
5442 _type = reader.read("!B")[0]
5443 assert(_type == 15)
5444 _length = reader.read("!H")[0]
5445 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08005446 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -08005447 obj.xid = reader.read("!L")[0]
5448 obj.command = reader.read("!H")[0]
5449 obj.group_type = reader.read("!B")[0]
5450 reader.skip(1)
5451 obj.group_id = reader.read("!L")[0]
Rich Lanee2567702015-01-26 15:04:35 -08005452 obj.buckets = loxi.generic_util.unpack_list(reader, ofp.common.bucket.unpack)
Rich Lane95f7fc92014-01-27 17:08:16 -08005453 return obj
5454
5455 def __eq__(self, other):
5456 if type(self) != type(other): return False
5457 if self.xid != other.xid: return False
5458 if self.command != other.command: return False
5459 if self.group_type != other.group_type: return False
5460 if self.group_id != other.group_id: return False
5461 if self.buckets != other.buckets: return False
5462 return True
5463
5464 def pretty_print(self, q):
5465 q.text("group_mod {")
5466 with q.group():
5467 with q.indent(2):
5468 q.breakable()
5469 q.text("xid = ");
5470 if self.xid != None:
5471 q.text("%#x" % self.xid)
5472 else:
5473 q.text('None')
5474 q.text(","); q.breakable()
5475 q.text("group_type = ");
5476 q.text("%#x" % self.group_type)
5477 q.text(","); q.breakable()
5478 q.text("group_id = ");
5479 q.text("%#x" % self.group_id)
5480 q.text(","); q.breakable()
5481 q.text("buckets = ");
5482 q.pp(self.buckets)
5483 q.breakable()
5484 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08005485
5486message.subtypes[15] = group_mod
5487
5488class group_add(group_mod):
Rich Lane7b0f2012013-11-22 14:15:26 -08005489 version = 2
5490 type = 15
5491 command = 0
5492
5493 def __init__(self, xid=None, group_type=None, group_id=None, buckets=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005494 if xid != None:
5495 self.xid = xid
5496 else:
5497 self.xid = None
Rich Lane7b0f2012013-11-22 14:15:26 -08005498 if group_type != None:
5499 self.group_type = group_type
5500 else:
5501 self.group_type = 0
5502 if group_id != None:
5503 self.group_id = group_id
5504 else:
5505 self.group_id = 0
5506 if buckets != None:
5507 self.buckets = buckets
5508 else:
5509 self.buckets = []
Rich Lane7dcdf022013-12-11 14:45:27 -08005510 return
Rich Lane7b0f2012013-11-22 14:15:26 -08005511
5512 def pack(self):
5513 packed = []
5514 packed.append(struct.pack("!B", self.version))
5515 packed.append(struct.pack("!B", self.type))
5516 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5517 packed.append(struct.pack("!L", self.xid))
5518 packed.append(struct.pack("!H", self.command))
5519 packed.append(struct.pack("!B", self.group_type))
5520 packed.append('\x00' * 1)
5521 packed.append(struct.pack("!L", self.group_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08005522 packed.append(loxi.generic_util.pack_list(self.buckets))
Rich Lane7b0f2012013-11-22 14:15:26 -08005523 length = sum([len(x) for x in packed])
5524 packed[2] = struct.pack("!H", length)
5525 return ''.join(packed)
5526
5527 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005528 def unpack(reader):
Rich Lane7b0f2012013-11-22 14:15:26 -08005529 obj = group_add()
Rich Lane7b0f2012013-11-22 14:15:26 -08005530 _version = reader.read("!B")[0]
5531 assert(_version == 2)
5532 _type = reader.read("!B")[0]
5533 assert(_type == 15)
5534 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005535 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08005536 reader = orig_reader.slice(_length, 4)
Rich Lane7b0f2012013-11-22 14:15:26 -08005537 obj.xid = reader.read("!L")[0]
5538 _command = reader.read("!H")[0]
5539 assert(_command == 0)
5540 obj.group_type = reader.read("!B")[0]
5541 reader.skip(1)
5542 obj.group_id = reader.read("!L")[0]
Rich Lanee2567702015-01-26 15:04:35 -08005543 obj.buckets = loxi.generic_util.unpack_list(reader, ofp.common.bucket.unpack)
Rich Lane7b0f2012013-11-22 14:15:26 -08005544 return obj
5545
5546 def __eq__(self, other):
5547 if type(self) != type(other): return False
Rich Lane7b0f2012013-11-22 14:15:26 -08005548 if self.xid != other.xid: return False
5549 if self.group_type != other.group_type: return False
5550 if self.group_id != other.group_id: return False
5551 if self.buckets != other.buckets: return False
5552 return True
5553
Rich Lane7b0f2012013-11-22 14:15:26 -08005554 def pretty_print(self, q):
5555 q.text("group_add {")
5556 with q.group():
5557 with q.indent(2):
5558 q.breakable()
5559 q.text("xid = ");
5560 if self.xid != None:
5561 q.text("%#x" % self.xid)
5562 else:
5563 q.text('None')
5564 q.text(","); q.breakable()
5565 q.text("group_type = ");
5566 q.text("%#x" % self.group_type)
5567 q.text(","); q.breakable()
5568 q.text("group_id = ");
5569 q.text("%#x" % self.group_id)
5570 q.text(","); q.breakable()
5571 q.text("buckets = ");
5572 q.pp(self.buckets)
5573 q.breakable()
5574 q.text('}')
5575
Rich Lane7dcdf022013-12-11 14:45:27 -08005576group_mod.subtypes[0] = group_add
5577
5578class group_delete(group_mod):
Rich Lane7b0f2012013-11-22 14:15:26 -08005579 version = 2
5580 type = 15
5581 command = 2
5582
5583 def __init__(self, xid=None, group_type=None, group_id=None, buckets=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005584 if xid != None:
5585 self.xid = xid
5586 else:
5587 self.xid = None
Rich Lane7b0f2012013-11-22 14:15:26 -08005588 if group_type != None:
5589 self.group_type = group_type
5590 else:
5591 self.group_type = 0
5592 if group_id != None:
5593 self.group_id = group_id
5594 else:
5595 self.group_id = 0
5596 if buckets != None:
5597 self.buckets = buckets
5598 else:
5599 self.buckets = []
Rich Lane7dcdf022013-12-11 14:45:27 -08005600 return
Rich Lane7b0f2012013-11-22 14:15:26 -08005601
5602 def pack(self):
5603 packed = []
5604 packed.append(struct.pack("!B", self.version))
5605 packed.append(struct.pack("!B", self.type))
5606 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5607 packed.append(struct.pack("!L", self.xid))
5608 packed.append(struct.pack("!H", self.command))
5609 packed.append(struct.pack("!B", self.group_type))
5610 packed.append('\x00' * 1)
5611 packed.append(struct.pack("!L", self.group_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08005612 packed.append(loxi.generic_util.pack_list(self.buckets))
Rich Lane7b0f2012013-11-22 14:15:26 -08005613 length = sum([len(x) for x in packed])
5614 packed[2] = struct.pack("!H", length)
5615 return ''.join(packed)
5616
5617 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005618 def unpack(reader):
Rich Lane7b0f2012013-11-22 14:15:26 -08005619 obj = group_delete()
Rich Lane7b0f2012013-11-22 14:15:26 -08005620 _version = reader.read("!B")[0]
5621 assert(_version == 2)
5622 _type = reader.read("!B")[0]
5623 assert(_type == 15)
5624 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005625 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08005626 reader = orig_reader.slice(_length, 4)
Rich Lane7b0f2012013-11-22 14:15:26 -08005627 obj.xid = reader.read("!L")[0]
5628 _command = reader.read("!H")[0]
5629 assert(_command == 2)
5630 obj.group_type = reader.read("!B")[0]
5631 reader.skip(1)
5632 obj.group_id = reader.read("!L")[0]
Rich Lanee2567702015-01-26 15:04:35 -08005633 obj.buckets = loxi.generic_util.unpack_list(reader, ofp.common.bucket.unpack)
Rich Lane7b0f2012013-11-22 14:15:26 -08005634 return obj
5635
5636 def __eq__(self, other):
5637 if type(self) != type(other): return False
Rich Lane7b0f2012013-11-22 14:15:26 -08005638 if self.xid != other.xid: return False
5639 if self.group_type != other.group_type: return False
5640 if self.group_id != other.group_id: return False
5641 if self.buckets != other.buckets: return False
5642 return True
5643
Rich Lane7b0f2012013-11-22 14:15:26 -08005644 def pretty_print(self, q):
5645 q.text("group_delete {")
5646 with q.group():
5647 with q.indent(2):
5648 q.breakable()
5649 q.text("xid = ");
5650 if self.xid != None:
5651 q.text("%#x" % self.xid)
5652 else:
5653 q.text('None')
5654 q.text(","); q.breakable()
5655 q.text("group_type = ");
5656 q.text("%#x" % self.group_type)
5657 q.text(","); q.breakable()
5658 q.text("group_id = ");
5659 q.text("%#x" % self.group_id)
5660 q.text(","); q.breakable()
5661 q.text("buckets = ");
5662 q.pp(self.buckets)
5663 q.breakable()
5664 q.text('}')
5665
Rich Lane7dcdf022013-12-11 14:45:27 -08005666group_mod.subtypes[2] = group_delete
5667
5668class group_desc_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07005669 version = 2
5670 type = 19
5671 stats_type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07005672
5673 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005674 if xid != None:
5675 self.xid = xid
5676 else:
5677 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005678 if flags != None:
5679 self.flags = flags
5680 else:
5681 self.flags = 0
5682 if entries != None:
5683 self.entries = entries
5684 else:
5685 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08005686 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005687
5688 def pack(self):
5689 packed = []
5690 packed.append(struct.pack("!B", self.version))
5691 packed.append(struct.pack("!B", self.type))
5692 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5693 packed.append(struct.pack("!L", self.xid))
5694 packed.append(struct.pack("!H", self.stats_type))
5695 packed.append(struct.pack("!H", self.flags))
5696 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08005697 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07005698 length = sum([len(x) for x in packed])
5699 packed[2] = struct.pack("!H", length)
5700 return ''.join(packed)
5701
5702 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005703 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005704 obj = group_desc_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07005705 _version = reader.read("!B")[0]
5706 assert(_version == 2)
5707 _type = reader.read("!B")[0]
5708 assert(_type == 19)
5709 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005710 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08005711 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07005712 obj.xid = reader.read("!L")[0]
5713 _stats_type = reader.read("!H")[0]
5714 assert(_stats_type == 7)
5715 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005716 reader.skip(4)
Rich Lanee2567702015-01-26 15:04:35 -08005717 obj.entries = loxi.generic_util.unpack_list(reader, ofp.common.group_desc_stats_entry.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07005718 return obj
5719
5720 def __eq__(self, other):
5721 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005722 if self.xid != other.xid: return False
5723 if self.flags != other.flags: return False
5724 if self.entries != other.entries: return False
5725 return True
5726
Rich Lanec2ee4b82013-04-24 17:12:38 -07005727 def pretty_print(self, q):
5728 q.text("group_desc_stats_reply {")
5729 with q.group():
5730 with q.indent(2):
5731 q.breakable()
5732 q.text("xid = ");
5733 if self.xid != None:
5734 q.text("%#x" % self.xid)
5735 else:
5736 q.text('None')
5737 q.text(","); q.breakable()
5738 q.text("flags = ");
5739 q.text("%#x" % self.flags)
5740 q.text(","); q.breakable()
5741 q.text("entries = ");
5742 q.pp(self.entries)
5743 q.breakable()
5744 q.text('}')
5745
Rich Lane7dcdf022013-12-11 14:45:27 -08005746stats_reply.subtypes[7] = group_desc_stats_reply
5747
5748class group_desc_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07005749 version = 2
5750 type = 18
5751 stats_type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07005752
5753 def __init__(self, xid=None, flags=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005754 if xid != None:
5755 self.xid = xid
5756 else:
5757 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005758 if flags != None:
5759 self.flags = flags
5760 else:
5761 self.flags = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08005762 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07005763
5764 def pack(self):
5765 packed = []
5766 packed.append(struct.pack("!B", self.version))
5767 packed.append(struct.pack("!B", self.type))
5768 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5769 packed.append(struct.pack("!L", self.xid))
5770 packed.append(struct.pack("!H", self.stats_type))
5771 packed.append(struct.pack("!H", self.flags))
5772 packed.append('\x00' * 4)
5773 length = sum([len(x) for x in packed])
5774 packed[2] = struct.pack("!H", length)
5775 return ''.join(packed)
5776
5777 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005778 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07005779 obj = group_desc_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07005780 _version = reader.read("!B")[0]
5781 assert(_version == 2)
5782 _type = reader.read("!B")[0]
5783 assert(_type == 18)
5784 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005785 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08005786 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07005787 obj.xid = reader.read("!L")[0]
5788 _stats_type = reader.read("!H")[0]
5789 assert(_stats_type == 7)
5790 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07005791 reader.skip(4)
5792 return obj
5793
5794 def __eq__(self, other):
5795 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07005796 if self.xid != other.xid: return False
5797 if self.flags != other.flags: return False
5798 return True
5799
Rich Lanec2ee4b82013-04-24 17:12:38 -07005800 def pretty_print(self, q):
5801 q.text("group_desc_stats_request {")
5802 with q.group():
5803 with q.indent(2):
5804 q.breakable()
5805 q.text("xid = ");
5806 if self.xid != None:
5807 q.text("%#x" % self.xid)
5808 else:
5809 q.text('None')
5810 q.text(","); q.breakable()
5811 q.text("flags = ");
5812 q.text("%#x" % self.flags)
5813 q.breakable()
5814 q.text('}')
5815
Rich Lane7dcdf022013-12-11 14:45:27 -08005816stats_request.subtypes[7] = group_desc_stats_request
5817
5818class group_mod_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07005819 version = 2
5820 type = 1
5821 err_type = 6
5822
5823 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005824 if xid != None:
5825 self.xid = xid
5826 else:
5827 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07005828 if code != None:
5829 self.code = code
5830 else:
5831 self.code = 0
5832 if data != None:
5833 self.data = data
5834 else:
5835 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08005836 return
Rich Lane6f4978c2013-10-20 21:33:52 -07005837
5838 def pack(self):
5839 packed = []
5840 packed.append(struct.pack("!B", self.version))
5841 packed.append(struct.pack("!B", self.type))
5842 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5843 packed.append(struct.pack("!L", self.xid))
5844 packed.append(struct.pack("!H", self.err_type))
5845 packed.append(struct.pack("!H", self.code))
5846 packed.append(self.data)
5847 length = sum([len(x) for x in packed])
5848 packed[2] = struct.pack("!H", length)
5849 return ''.join(packed)
5850
5851 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005852 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07005853 obj = group_mod_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07005854 _version = reader.read("!B")[0]
5855 assert(_version == 2)
5856 _type = reader.read("!B")[0]
5857 assert(_type == 1)
5858 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005859 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08005860 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -07005861 obj.xid = reader.read("!L")[0]
5862 _err_type = reader.read("!H")[0]
5863 assert(_err_type == 6)
5864 obj.code = reader.read("!H")[0]
5865 obj.data = str(reader.read_all())
5866 return obj
5867
5868 def __eq__(self, other):
5869 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07005870 if self.xid != other.xid: return False
5871 if self.code != other.code: return False
5872 if self.data != other.data: return False
5873 return True
5874
Rich Lane6f4978c2013-10-20 21:33:52 -07005875 def pretty_print(self, q):
5876 q.text("group_mod_failed_error_msg {")
5877 with q.group():
5878 with q.indent(2):
5879 q.breakable()
5880 q.text("xid = ");
5881 if self.xid != None:
5882 q.text("%#x" % self.xid)
5883 else:
5884 q.text('None')
5885 q.text(","); q.breakable()
5886 q.text("code = ");
5887 q.text("%#x" % self.code)
5888 q.text(","); q.breakable()
5889 q.text("data = ");
5890 q.pp(self.data)
5891 q.breakable()
5892 q.text('}')
5893
Rich Lane7dcdf022013-12-11 14:45:27 -08005894error_msg.subtypes[6] = group_mod_failed_error_msg
5895
5896class group_modify(group_mod):
Rich Lane7b0f2012013-11-22 14:15:26 -08005897 version = 2
5898 type = 15
5899 command = 1
5900
5901 def __init__(self, xid=None, group_type=None, group_id=None, buckets=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005902 if xid != None:
5903 self.xid = xid
5904 else:
5905 self.xid = None
Rich Lane7b0f2012013-11-22 14:15:26 -08005906 if group_type != None:
5907 self.group_type = group_type
5908 else:
5909 self.group_type = 0
5910 if group_id != None:
5911 self.group_id = group_id
5912 else:
5913 self.group_id = 0
5914 if buckets != None:
5915 self.buckets = buckets
5916 else:
5917 self.buckets = []
Rich Lane7dcdf022013-12-11 14:45:27 -08005918 return
Rich Lane7b0f2012013-11-22 14:15:26 -08005919
5920 def pack(self):
5921 packed = []
5922 packed.append(struct.pack("!B", self.version))
5923 packed.append(struct.pack("!B", self.type))
5924 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
5925 packed.append(struct.pack("!L", self.xid))
5926 packed.append(struct.pack("!H", self.command))
5927 packed.append(struct.pack("!B", self.group_type))
5928 packed.append('\x00' * 1)
5929 packed.append(struct.pack("!L", self.group_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08005930 packed.append(loxi.generic_util.pack_list(self.buckets))
Rich Lane7b0f2012013-11-22 14:15:26 -08005931 length = sum([len(x) for x in packed])
5932 packed[2] = struct.pack("!H", length)
5933 return ''.join(packed)
5934
5935 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08005936 def unpack(reader):
Rich Lane7b0f2012013-11-22 14:15:26 -08005937 obj = group_modify()
Rich Lane7b0f2012013-11-22 14:15:26 -08005938 _version = reader.read("!B")[0]
5939 assert(_version == 2)
5940 _type = reader.read("!B")[0]
5941 assert(_type == 15)
5942 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08005943 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08005944 reader = orig_reader.slice(_length, 4)
Rich Lane7b0f2012013-11-22 14:15:26 -08005945 obj.xid = reader.read("!L")[0]
5946 _command = reader.read("!H")[0]
5947 assert(_command == 1)
5948 obj.group_type = reader.read("!B")[0]
5949 reader.skip(1)
5950 obj.group_id = reader.read("!L")[0]
Rich Lanee2567702015-01-26 15:04:35 -08005951 obj.buckets = loxi.generic_util.unpack_list(reader, ofp.common.bucket.unpack)
Rich Lane7b0f2012013-11-22 14:15:26 -08005952 return obj
5953
5954 def __eq__(self, other):
5955 if type(self) != type(other): return False
Rich Lane7b0f2012013-11-22 14:15:26 -08005956 if self.xid != other.xid: return False
5957 if self.group_type != other.group_type: return False
5958 if self.group_id != other.group_id: return False
5959 if self.buckets != other.buckets: return False
5960 return True
5961
Rich Lane7b0f2012013-11-22 14:15:26 -08005962 def pretty_print(self, q):
5963 q.text("group_modify {")
5964 with q.group():
5965 with q.indent(2):
5966 q.breakable()
5967 q.text("xid = ");
5968 if self.xid != None:
5969 q.text("%#x" % self.xid)
5970 else:
5971 q.text('None')
5972 q.text(","); q.breakable()
5973 q.text("group_type = ");
5974 q.text("%#x" % self.group_type)
5975 q.text(","); q.breakable()
5976 q.text("group_id = ");
5977 q.text("%#x" % self.group_id)
5978 q.text(","); q.breakable()
5979 q.text("buckets = ");
5980 q.pp(self.buckets)
5981 q.breakable()
5982 q.text('}')
5983
Rich Lane7dcdf022013-12-11 14:45:27 -08005984group_mod.subtypes[1] = group_modify
5985
5986class group_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07005987 version = 2
5988 type = 19
5989 stats_type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07005990
5991 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08005992 if xid != None:
5993 self.xid = xid
5994 else:
5995 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07005996 if flags != None:
5997 self.flags = flags
5998 else:
5999 self.flags = 0
6000 if entries != None:
6001 self.entries = entries
6002 else:
6003 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08006004 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006005
6006 def pack(self):
6007 packed = []
6008 packed.append(struct.pack("!B", self.version))
6009 packed.append(struct.pack("!B", self.type))
6010 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6011 packed.append(struct.pack("!L", self.xid))
6012 packed.append(struct.pack("!H", self.stats_type))
6013 packed.append(struct.pack("!H", self.flags))
6014 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08006015 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006016 length = sum([len(x) for x in packed])
6017 packed[2] = struct.pack("!H", length)
6018 return ''.join(packed)
6019
6020 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006021 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006022 obj = group_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07006023 _version = reader.read("!B")[0]
6024 assert(_version == 2)
6025 _type = reader.read("!B")[0]
6026 assert(_type == 19)
6027 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006028 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08006029 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07006030 obj.xid = reader.read("!L")[0]
6031 _stats_type = reader.read("!H")[0]
6032 assert(_stats_type == 6)
6033 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006034 reader.skip(4)
Rich Lanee2567702015-01-26 15:04:35 -08006035 obj.entries = loxi.generic_util.unpack_list(reader, ofp.common.group_stats_entry.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006036 return obj
6037
6038 def __eq__(self, other):
6039 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006040 if self.xid != other.xid: return False
6041 if self.flags != other.flags: return False
6042 if self.entries != other.entries: return False
6043 return True
6044
Rich Lanec2ee4b82013-04-24 17:12:38 -07006045 def pretty_print(self, q):
6046 q.text("group_stats_reply {")
6047 with q.group():
6048 with q.indent(2):
6049 q.breakable()
6050 q.text("xid = ");
6051 if self.xid != None:
6052 q.text("%#x" % self.xid)
6053 else:
6054 q.text('None')
6055 q.text(","); q.breakable()
6056 q.text("flags = ");
6057 q.text("%#x" % self.flags)
6058 q.text(","); q.breakable()
6059 q.text("entries = ");
6060 q.pp(self.entries)
6061 q.breakable()
6062 q.text('}')
6063
Rich Lane7dcdf022013-12-11 14:45:27 -08006064stats_reply.subtypes[6] = group_stats_reply
6065
6066class group_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07006067 version = 2
6068 type = 18
6069 stats_type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07006070
6071 def __init__(self, xid=None, flags=None, group_id=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006072 if xid != None:
6073 self.xid = xid
6074 else:
6075 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006076 if flags != None:
6077 self.flags = flags
6078 else:
6079 self.flags = 0
6080 if group_id != None:
6081 self.group_id = group_id
6082 else:
6083 self.group_id = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08006084 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006085
6086 def pack(self):
6087 packed = []
6088 packed.append(struct.pack("!B", self.version))
6089 packed.append(struct.pack("!B", self.type))
6090 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6091 packed.append(struct.pack("!L", self.xid))
6092 packed.append(struct.pack("!H", self.stats_type))
6093 packed.append(struct.pack("!H", self.flags))
6094 packed.append('\x00' * 4)
6095 packed.append(struct.pack("!L", self.group_id))
6096 packed.append('\x00' * 4)
6097 length = sum([len(x) for x in packed])
6098 packed[2] = struct.pack("!H", length)
6099 return ''.join(packed)
6100
6101 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006102 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006103 obj = group_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07006104 _version = reader.read("!B")[0]
6105 assert(_version == 2)
6106 _type = reader.read("!B")[0]
6107 assert(_type == 18)
6108 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006109 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08006110 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07006111 obj.xid = reader.read("!L")[0]
6112 _stats_type = reader.read("!H")[0]
6113 assert(_stats_type == 6)
6114 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006115 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07006116 obj.group_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006117 reader.skip(4)
6118 return obj
6119
6120 def __eq__(self, other):
6121 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006122 if self.xid != other.xid: return False
6123 if self.flags != other.flags: return False
6124 if self.group_id != other.group_id: return False
6125 return True
6126
Rich Lanec2ee4b82013-04-24 17:12:38 -07006127 def pretty_print(self, q):
6128 q.text("group_stats_request {")
6129 with q.group():
6130 with q.indent(2):
6131 q.breakable()
6132 q.text("xid = ");
6133 if self.xid != None:
6134 q.text("%#x" % self.xid)
6135 else:
6136 q.text('None')
6137 q.text(","); q.breakable()
6138 q.text("flags = ");
6139 q.text("%#x" % self.flags)
6140 q.text(","); q.breakable()
6141 q.text("group_id = ");
6142 q.text("%#x" % self.group_id)
6143 q.breakable()
6144 q.text('}')
6145
Rich Lane7dcdf022013-12-11 14:45:27 -08006146stats_request.subtypes[6] = group_stats_request
6147
6148class hello(message):
Dan Talaycof6202252013-07-02 01:00:29 -07006149 version = 2
6150 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07006151
6152 def __init__(self, xid=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006153 if xid != None:
6154 self.xid = xid
6155 else:
6156 self.xid = None
6157 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006158
6159 def pack(self):
6160 packed = []
6161 packed.append(struct.pack("!B", self.version))
6162 packed.append(struct.pack("!B", self.type))
6163 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6164 packed.append(struct.pack("!L", self.xid))
6165 length = sum([len(x) for x in packed])
6166 packed[2] = struct.pack("!H", length)
6167 return ''.join(packed)
6168
6169 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006170 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006171 obj = hello()
Dan Talaycof6202252013-07-02 01:00:29 -07006172 _version = reader.read("!B")[0]
6173 assert(_version == 2)
6174 _type = reader.read("!B")[0]
6175 assert(_type == 0)
6176 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006177 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08006178 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07006179 obj.xid = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006180 return obj
6181
6182 def __eq__(self, other):
6183 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006184 if self.xid != other.xid: return False
6185 return True
6186
Rich Lanec2ee4b82013-04-24 17:12:38 -07006187 def pretty_print(self, q):
6188 q.text("hello {")
6189 with q.group():
6190 with q.indent(2):
6191 q.breakable()
6192 q.text("xid = ");
6193 if self.xid != None:
6194 q.text("%#x" % self.xid)
6195 else:
6196 q.text('None')
6197 q.breakable()
6198 q.text('}')
6199
Rich Lane7dcdf022013-12-11 14:45:27 -08006200message.subtypes[0] = hello
6201
6202class hello_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07006203 version = 2
6204 type = 1
6205 err_type = 0
6206
6207 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006208 if xid != None:
6209 self.xid = xid
6210 else:
6211 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07006212 if code != None:
6213 self.code = code
6214 else:
6215 self.code = 0
6216 if data != None:
6217 self.data = data
6218 else:
6219 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08006220 return
Rich Lane6f4978c2013-10-20 21:33:52 -07006221
6222 def pack(self):
6223 packed = []
6224 packed.append(struct.pack("!B", self.version))
6225 packed.append(struct.pack("!B", self.type))
6226 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6227 packed.append(struct.pack("!L", self.xid))
6228 packed.append(struct.pack("!H", self.err_type))
6229 packed.append(struct.pack("!H", self.code))
6230 packed.append(self.data)
6231 length = sum([len(x) for x in packed])
6232 packed[2] = struct.pack("!H", length)
6233 return ''.join(packed)
6234
6235 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006236 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07006237 obj = hello_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07006238 _version = reader.read("!B")[0]
6239 assert(_version == 2)
6240 _type = reader.read("!B")[0]
6241 assert(_type == 1)
6242 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006243 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08006244 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -07006245 obj.xid = reader.read("!L")[0]
6246 _err_type = reader.read("!H")[0]
6247 assert(_err_type == 0)
6248 obj.code = reader.read("!H")[0]
6249 obj.data = str(reader.read_all())
6250 return obj
6251
6252 def __eq__(self, other):
6253 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07006254 if self.xid != other.xid: return False
6255 if self.code != other.code: return False
6256 if self.data != other.data: return False
6257 return True
6258
Rich Lane6f4978c2013-10-20 21:33:52 -07006259 def pretty_print(self, q):
6260 q.text("hello_failed_error_msg {")
6261 with q.group():
6262 with q.indent(2):
6263 q.breakable()
6264 q.text("xid = ");
6265 if self.xid != None:
6266 q.text("%#x" % self.xid)
6267 else:
6268 q.text('None')
6269 q.text(","); q.breakable()
6270 q.text("code = ");
6271 q.text("%#x" % self.code)
6272 q.text(","); q.breakable()
6273 q.text("data = ");
6274 q.pp(self.data)
6275 q.breakable()
6276 q.text('}')
6277
Rich Lane7dcdf022013-12-11 14:45:27 -08006278error_msg.subtypes[0] = hello_failed_error_msg
6279
6280class nicira_header(experimenter):
6281 subtypes = {}
6282
Rich Lane95f7fc92014-01-27 17:08:16 -08006283 version = 2
6284 type = 4
6285 experimenter = 8992
6286
6287 def __init__(self, xid=None, subtype=None):
6288 if xid != None:
6289 self.xid = xid
6290 else:
6291 self.xid = None
6292 if subtype != None:
6293 self.subtype = subtype
6294 else:
6295 self.subtype = 0
6296 return
6297
6298 def pack(self):
6299 packed = []
6300 packed.append(struct.pack("!B", self.version))
6301 packed.append(struct.pack("!B", self.type))
6302 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6303 packed.append(struct.pack("!L", self.xid))
6304 packed.append(struct.pack("!L", self.experimenter))
6305 packed.append(struct.pack("!L", self.subtype))
6306 length = sum([len(x) for x in packed])
6307 packed[2] = struct.pack("!H", length)
6308 return ''.join(packed)
6309
Rich Lane7dcdf022013-12-11 14:45:27 -08006310 @staticmethod
6311 def unpack(reader):
6312 subtype, = reader.peek('!L', 12)
Rich Lane95f7fc92014-01-27 17:08:16 -08006313 subclass = nicira_header.subtypes.get(subtype)
6314 if subclass:
6315 return subclass.unpack(reader)
6316
6317 obj = nicira_header()
6318 _version = reader.read("!B")[0]
6319 assert(_version == 2)
6320 _type = reader.read("!B")[0]
6321 assert(_type == 4)
6322 _length = reader.read("!H")[0]
6323 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08006324 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -08006325 obj.xid = reader.read("!L")[0]
6326 _experimenter = reader.read("!L")[0]
6327 assert(_experimenter == 8992)
6328 obj.subtype = reader.read("!L")[0]
6329 return obj
6330
6331 def __eq__(self, other):
6332 if type(self) != type(other): return False
6333 if self.xid != other.xid: return False
6334 if self.subtype != other.subtype: return False
6335 return True
6336
6337 def pretty_print(self, q):
6338 q.text("nicira_header {")
6339 with q.group():
6340 with q.indent(2):
6341 q.breakable()
6342 q.text("xid = ");
6343 if self.xid != None:
6344 q.text("%#x" % self.xid)
6345 else:
6346 q.text('None')
6347 q.breakable()
6348 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08006349
6350experimenter.subtypes[8992] = nicira_header
6351
6352class packet_in(message):
Dan Talaycof6202252013-07-02 01:00:29 -07006353 version = 2
6354 type = 10
Rich Lanec2ee4b82013-04-24 17:12:38 -07006355
6356 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 -08006357 if xid != None:
6358 self.xid = xid
6359 else:
6360 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006361 if buffer_id != None:
6362 self.buffer_id = buffer_id
6363 else:
6364 self.buffer_id = 0
6365 if in_port != None:
6366 self.in_port = in_port
6367 else:
6368 self.in_port = 0
6369 if in_phy_port != None:
6370 self.in_phy_port = in_phy_port
6371 else:
6372 self.in_phy_port = 0
6373 if total_len != None:
6374 self.total_len = total_len
6375 else:
6376 self.total_len = 0
6377 if reason != None:
6378 self.reason = reason
6379 else:
6380 self.reason = 0
6381 if table_id != None:
6382 self.table_id = table_id
6383 else:
6384 self.table_id = 0
6385 if data != None:
6386 self.data = data
6387 else:
Dan Talaycof6202252013-07-02 01:00:29 -07006388 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08006389 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006390
6391 def pack(self):
6392 packed = []
6393 packed.append(struct.pack("!B", self.version))
6394 packed.append(struct.pack("!B", self.type))
6395 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6396 packed.append(struct.pack("!L", self.xid))
6397 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07006398 packed.append(util.pack_port_no(self.in_port))
6399 packed.append(util.pack_port_no(self.in_phy_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006400 packed.append(struct.pack("!H", self.total_len))
6401 packed.append(struct.pack("!B", self.reason))
6402 packed.append(struct.pack("!B", self.table_id))
6403 packed.append(self.data)
6404 length = sum([len(x) for x in packed])
6405 packed[2] = struct.pack("!H", length)
6406 return ''.join(packed)
6407
6408 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006409 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006410 obj = packet_in()
Dan Talaycof6202252013-07-02 01:00:29 -07006411 _version = reader.read("!B")[0]
6412 assert(_version == 2)
6413 _type = reader.read("!B")[0]
6414 assert(_type == 10)
6415 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006416 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08006417 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07006418 obj.xid = reader.read("!L")[0]
6419 obj.buffer_id = reader.read("!L")[0]
6420 obj.in_port = util.unpack_port_no(reader)
6421 obj.in_phy_port = util.unpack_port_no(reader)
6422 obj.total_len = reader.read("!H")[0]
6423 obj.reason = reader.read("!B")[0]
6424 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006425 obj.data = str(reader.read_all())
6426 return obj
6427
6428 def __eq__(self, other):
6429 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006430 if self.xid != other.xid: return False
6431 if self.buffer_id != other.buffer_id: return False
6432 if self.in_port != other.in_port: return False
6433 if self.in_phy_port != other.in_phy_port: return False
6434 if self.total_len != other.total_len: return False
6435 if self.reason != other.reason: return False
6436 if self.table_id != other.table_id: return False
6437 if self.data != other.data: return False
6438 return True
6439
Rich Lanec2ee4b82013-04-24 17:12:38 -07006440 def pretty_print(self, q):
6441 q.text("packet_in {")
6442 with q.group():
6443 with q.indent(2):
6444 q.breakable()
6445 q.text("xid = ");
6446 if self.xid != None:
6447 q.text("%#x" % self.xid)
6448 else:
6449 q.text('None')
6450 q.text(","); q.breakable()
6451 q.text("buffer_id = ");
6452 q.text("%#x" % self.buffer_id)
6453 q.text(","); q.breakable()
6454 q.text("in_port = ");
6455 q.text(util.pretty_port(self.in_port))
6456 q.text(","); q.breakable()
6457 q.text("in_phy_port = ");
6458 q.text(util.pretty_port(self.in_phy_port))
6459 q.text(","); q.breakable()
6460 q.text("total_len = ");
6461 q.text("%#x" % self.total_len)
6462 q.text(","); q.breakable()
6463 q.text("reason = ");
6464 q.text("%#x" % self.reason)
6465 q.text(","); q.breakable()
6466 q.text("table_id = ");
6467 q.text("%#x" % self.table_id)
6468 q.text(","); q.breakable()
6469 q.text("data = ");
6470 q.pp(self.data)
6471 q.breakable()
6472 q.text('}')
6473
Rich Lane7dcdf022013-12-11 14:45:27 -08006474message.subtypes[10] = packet_in
6475
6476class packet_out(message):
Dan Talaycof6202252013-07-02 01:00:29 -07006477 version = 2
6478 type = 13
Rich Lanec2ee4b82013-04-24 17:12:38 -07006479
6480 def __init__(self, xid=None, buffer_id=None, in_port=None, actions=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006481 if xid != None:
6482 self.xid = xid
6483 else:
6484 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006485 if buffer_id != None:
6486 self.buffer_id = buffer_id
6487 else:
6488 self.buffer_id = 0
6489 if in_port != None:
6490 self.in_port = in_port
6491 else:
6492 self.in_port = 0
6493 if actions != None:
6494 self.actions = actions
6495 else:
6496 self.actions = []
6497 if data != None:
6498 self.data = data
6499 else:
Dan Talaycof6202252013-07-02 01:00:29 -07006500 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08006501 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006502
6503 def pack(self):
6504 packed = []
6505 packed.append(struct.pack("!B", self.version))
6506 packed.append(struct.pack("!B", self.type))
6507 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6508 packed.append(struct.pack("!L", self.xid))
6509 packed.append(struct.pack("!L", self.buffer_id))
Dan Talaycof6202252013-07-02 01:00:29 -07006510 packed.append(util.pack_port_no(self.in_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006511 packed.append(struct.pack("!H", 0)) # placeholder for actions_len at index 6
6512 packed.append('\x00' * 6)
Rich Lane7dcdf022013-12-11 14:45:27 -08006513 packed.append(loxi.generic_util.pack_list(self.actions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006514 packed[6] = struct.pack("!H", len(packed[-1]))
6515 packed.append(self.data)
6516 length = sum([len(x) for x in packed])
6517 packed[2] = struct.pack("!H", length)
6518 return ''.join(packed)
6519
6520 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006521 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006522 obj = packet_out()
Dan Talaycof6202252013-07-02 01:00:29 -07006523 _version = reader.read("!B")[0]
6524 assert(_version == 2)
6525 _type = reader.read("!B")[0]
6526 assert(_type == 13)
6527 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006528 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08006529 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07006530 obj.xid = reader.read("!L")[0]
6531 obj.buffer_id = reader.read("!L")[0]
6532 obj.in_port = util.unpack_port_no(reader)
6533 _actions_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006534 reader.skip(6)
Rich Lanee2567702015-01-26 15:04:35 -08006535 obj.actions = loxi.generic_util.unpack_list(reader.slice(_actions_len), ofp.action.action.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006536 obj.data = str(reader.read_all())
6537 return obj
6538
6539 def __eq__(self, other):
6540 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006541 if self.xid != other.xid: return False
6542 if self.buffer_id != other.buffer_id: return False
6543 if self.in_port != other.in_port: return False
6544 if self.actions != other.actions: return False
6545 if self.data != other.data: return False
6546 return True
6547
Rich Lanec2ee4b82013-04-24 17:12:38 -07006548 def pretty_print(self, q):
6549 q.text("packet_out {")
6550 with q.group():
6551 with q.indent(2):
6552 q.breakable()
6553 q.text("xid = ");
6554 if self.xid != None:
6555 q.text("%#x" % self.xid)
6556 else:
6557 q.text('None')
6558 q.text(","); q.breakable()
6559 q.text("buffer_id = ");
6560 q.text("%#x" % self.buffer_id)
6561 q.text(","); q.breakable()
6562 q.text("in_port = ");
6563 q.text(util.pretty_port(self.in_port))
6564 q.text(","); q.breakable()
6565 q.text("actions = ");
6566 q.pp(self.actions)
6567 q.text(","); q.breakable()
6568 q.text("data = ");
6569 q.pp(self.data)
6570 q.breakable()
6571 q.text('}')
6572
Rich Lane7dcdf022013-12-11 14:45:27 -08006573message.subtypes[13] = packet_out
6574
6575class port_mod(message):
Dan Talaycof6202252013-07-02 01:00:29 -07006576 version = 2
6577 type = 16
Rich Lanec2ee4b82013-04-24 17:12:38 -07006578
6579 def __init__(self, xid=None, port_no=None, hw_addr=None, config=None, mask=None, advertise=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006580 if xid != None:
6581 self.xid = xid
6582 else:
6583 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006584 if port_no != None:
6585 self.port_no = port_no
6586 else:
6587 self.port_no = 0
6588 if hw_addr != None:
6589 self.hw_addr = hw_addr
6590 else:
6591 self.hw_addr = [0,0,0,0,0,0]
6592 if config != None:
6593 self.config = config
6594 else:
6595 self.config = 0
6596 if mask != None:
6597 self.mask = mask
6598 else:
6599 self.mask = 0
6600 if advertise != None:
6601 self.advertise = advertise
6602 else:
6603 self.advertise = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08006604 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006605
6606 def pack(self):
6607 packed = []
6608 packed.append(struct.pack("!B", self.version))
6609 packed.append(struct.pack("!B", self.type))
6610 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6611 packed.append(struct.pack("!L", self.xid))
Dan Talaycof6202252013-07-02 01:00:29 -07006612 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006613 packed.append('\x00' * 4)
6614 packed.append(struct.pack("!6B", *self.hw_addr))
6615 packed.append('\x00' * 2)
6616 packed.append(struct.pack("!L", self.config))
6617 packed.append(struct.pack("!L", self.mask))
6618 packed.append(struct.pack("!L", self.advertise))
6619 packed.append('\x00' * 4)
6620 length = sum([len(x) for x in packed])
6621 packed[2] = struct.pack("!H", length)
6622 return ''.join(packed)
6623
6624 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006625 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006626 obj = port_mod()
Dan Talaycof6202252013-07-02 01:00:29 -07006627 _version = reader.read("!B")[0]
6628 assert(_version == 2)
6629 _type = reader.read("!B")[0]
6630 assert(_type == 16)
6631 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006632 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08006633 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07006634 obj.xid = reader.read("!L")[0]
6635 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006636 reader.skip(4)
6637 obj.hw_addr = list(reader.read('!6B'))
6638 reader.skip(2)
Dan Talaycof6202252013-07-02 01:00:29 -07006639 obj.config = reader.read("!L")[0]
6640 obj.mask = reader.read("!L")[0]
6641 obj.advertise = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006642 reader.skip(4)
6643 return obj
6644
6645 def __eq__(self, other):
6646 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006647 if self.xid != other.xid: return False
6648 if self.port_no != other.port_no: return False
6649 if self.hw_addr != other.hw_addr: return False
6650 if self.config != other.config: return False
6651 if self.mask != other.mask: return False
6652 if self.advertise != other.advertise: return False
6653 return True
6654
Rich Lanec2ee4b82013-04-24 17:12:38 -07006655 def pretty_print(self, q):
6656 q.text("port_mod {")
6657 with q.group():
6658 with q.indent(2):
6659 q.breakable()
6660 q.text("xid = ");
6661 if self.xid != None:
6662 q.text("%#x" % self.xid)
6663 else:
6664 q.text('None')
6665 q.text(","); q.breakable()
6666 q.text("port_no = ");
6667 q.text(util.pretty_port(self.port_no))
6668 q.text(","); q.breakable()
6669 q.text("hw_addr = ");
6670 q.text(util.pretty_mac(self.hw_addr))
6671 q.text(","); q.breakable()
6672 q.text("config = ");
6673 q.text("%#x" % self.config)
6674 q.text(","); q.breakable()
6675 q.text("mask = ");
6676 q.text("%#x" % self.mask)
6677 q.text(","); q.breakable()
6678 q.text("advertise = ");
6679 q.text("%#x" % self.advertise)
6680 q.breakable()
6681 q.text('}')
6682
Rich Lane7dcdf022013-12-11 14:45:27 -08006683message.subtypes[16] = port_mod
6684
6685class port_mod_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07006686 version = 2
6687 type = 1
6688 err_type = 7
6689
6690 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006691 if xid != None:
6692 self.xid = xid
6693 else:
6694 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07006695 if code != None:
6696 self.code = code
6697 else:
6698 self.code = 0
6699 if data != None:
6700 self.data = data
6701 else:
6702 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08006703 return
Rich Lane6f4978c2013-10-20 21:33:52 -07006704
6705 def pack(self):
6706 packed = []
6707 packed.append(struct.pack("!B", self.version))
6708 packed.append(struct.pack("!B", self.type))
6709 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6710 packed.append(struct.pack("!L", self.xid))
6711 packed.append(struct.pack("!H", self.err_type))
6712 packed.append(struct.pack("!H", self.code))
6713 packed.append(self.data)
6714 length = sum([len(x) for x in packed])
6715 packed[2] = struct.pack("!H", length)
6716 return ''.join(packed)
6717
6718 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006719 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07006720 obj = port_mod_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07006721 _version = reader.read("!B")[0]
6722 assert(_version == 2)
6723 _type = reader.read("!B")[0]
6724 assert(_type == 1)
6725 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006726 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08006727 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -07006728 obj.xid = reader.read("!L")[0]
6729 _err_type = reader.read("!H")[0]
6730 assert(_err_type == 7)
6731 obj.code = reader.read("!H")[0]
6732 obj.data = str(reader.read_all())
6733 return obj
6734
6735 def __eq__(self, other):
6736 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07006737 if self.xid != other.xid: return False
6738 if self.code != other.code: return False
6739 if self.data != other.data: return False
6740 return True
6741
Rich Lane6f4978c2013-10-20 21:33:52 -07006742 def pretty_print(self, q):
6743 q.text("port_mod_failed_error_msg {")
6744 with q.group():
6745 with q.indent(2):
6746 q.breakable()
6747 q.text("xid = ");
6748 if self.xid != None:
6749 q.text("%#x" % self.xid)
6750 else:
6751 q.text('None')
6752 q.text(","); q.breakable()
6753 q.text("code = ");
6754 q.text("%#x" % self.code)
6755 q.text(","); q.breakable()
6756 q.text("data = ");
6757 q.pp(self.data)
6758 q.breakable()
6759 q.text('}')
6760
Rich Lane7dcdf022013-12-11 14:45:27 -08006761error_msg.subtypes[7] = port_mod_failed_error_msg
6762
6763class port_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07006764 version = 2
6765 type = 19
6766 stats_type = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07006767
6768 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006769 if xid != None:
6770 self.xid = xid
6771 else:
6772 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006773 if flags != None:
6774 self.flags = flags
6775 else:
6776 self.flags = 0
6777 if entries != None:
6778 self.entries = entries
6779 else:
6780 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08006781 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006782
6783 def pack(self):
6784 packed = []
6785 packed.append(struct.pack("!B", self.version))
6786 packed.append(struct.pack("!B", self.type))
6787 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6788 packed.append(struct.pack("!L", self.xid))
6789 packed.append(struct.pack("!H", self.stats_type))
6790 packed.append(struct.pack("!H", self.flags))
6791 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08006792 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006793 length = sum([len(x) for x in packed])
6794 packed[2] = struct.pack("!H", length)
6795 return ''.join(packed)
6796
6797 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006798 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006799 obj = port_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07006800 _version = reader.read("!B")[0]
6801 assert(_version == 2)
6802 _type = reader.read("!B")[0]
6803 assert(_type == 19)
6804 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006805 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08006806 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07006807 obj.xid = reader.read("!L")[0]
6808 _stats_type = reader.read("!H")[0]
6809 assert(_stats_type == 4)
6810 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006811 reader.skip(4)
Rich Lanee2567702015-01-26 15:04:35 -08006812 obj.entries = loxi.generic_util.unpack_list(reader, ofp.common.port_stats_entry.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006813 return obj
6814
6815 def __eq__(self, other):
6816 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006817 if self.xid != other.xid: return False
6818 if self.flags != other.flags: return False
6819 if self.entries != other.entries: return False
6820 return True
6821
Rich Lanec2ee4b82013-04-24 17:12:38 -07006822 def pretty_print(self, q):
6823 q.text("port_stats_reply {")
6824 with q.group():
6825 with q.indent(2):
6826 q.breakable()
6827 q.text("xid = ");
6828 if self.xid != None:
6829 q.text("%#x" % self.xid)
6830 else:
6831 q.text('None')
6832 q.text(","); q.breakable()
6833 q.text("flags = ");
6834 q.text("%#x" % self.flags)
6835 q.text(","); q.breakable()
6836 q.text("entries = ");
6837 q.pp(self.entries)
6838 q.breakable()
6839 q.text('}')
6840
Rich Lane7dcdf022013-12-11 14:45:27 -08006841stats_reply.subtypes[4] = port_stats_reply
6842
6843class port_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07006844 version = 2
6845 type = 18
6846 stats_type = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07006847
6848 def __init__(self, xid=None, flags=None, port_no=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006849 if xid != None:
6850 self.xid = xid
6851 else:
6852 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006853 if flags != None:
6854 self.flags = flags
6855 else:
6856 self.flags = 0
6857 if port_no != None:
6858 self.port_no = port_no
6859 else:
6860 self.port_no = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08006861 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006862
6863 def pack(self):
6864 packed = []
6865 packed.append(struct.pack("!B", self.version))
6866 packed.append(struct.pack("!B", self.type))
6867 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6868 packed.append(struct.pack("!L", self.xid))
6869 packed.append(struct.pack("!H", self.stats_type))
6870 packed.append(struct.pack("!H", self.flags))
6871 packed.append('\x00' * 4)
Dan Talaycof6202252013-07-02 01:00:29 -07006872 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07006873 packed.append('\x00' * 4)
6874 length = sum([len(x) for x in packed])
6875 packed[2] = struct.pack("!H", length)
6876 return ''.join(packed)
6877
6878 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006879 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006880 obj = port_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07006881 _version = reader.read("!B")[0]
6882 assert(_version == 2)
6883 _type = reader.read("!B")[0]
6884 assert(_type == 18)
6885 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006886 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08006887 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07006888 obj.xid = reader.read("!L")[0]
6889 _stats_type = reader.read("!H")[0]
6890 assert(_stats_type == 4)
6891 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006892 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07006893 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006894 reader.skip(4)
6895 return obj
6896
6897 def __eq__(self, other):
6898 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006899 if self.xid != other.xid: return False
6900 if self.flags != other.flags: return False
6901 if self.port_no != other.port_no: return False
6902 return True
6903
Rich Lanec2ee4b82013-04-24 17:12:38 -07006904 def pretty_print(self, q):
6905 q.text("port_stats_request {")
6906 with q.group():
6907 with q.indent(2):
6908 q.breakable()
6909 q.text("xid = ");
6910 if self.xid != None:
6911 q.text("%#x" % self.xid)
6912 else:
6913 q.text('None')
6914 q.text(","); q.breakable()
6915 q.text("flags = ");
6916 q.text("%#x" % self.flags)
6917 q.text(","); q.breakable()
6918 q.text("port_no = ");
6919 q.text(util.pretty_port(self.port_no))
6920 q.breakable()
6921 q.text('}')
6922
Rich Lane7dcdf022013-12-11 14:45:27 -08006923stats_request.subtypes[4] = port_stats_request
6924
6925class port_status(message):
Dan Talaycof6202252013-07-02 01:00:29 -07006926 version = 2
6927 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -07006928
6929 def __init__(self, xid=None, reason=None, desc=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08006930 if xid != None:
6931 self.xid = xid
6932 else:
6933 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07006934 if reason != None:
6935 self.reason = reason
6936 else:
6937 self.reason = 0
6938 if desc != None:
6939 self.desc = desc
6940 else:
Rich Lanee2567702015-01-26 15:04:35 -08006941 self.desc = ofp.port_desc()
Rich Lane7dcdf022013-12-11 14:45:27 -08006942 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07006943
6944 def pack(self):
6945 packed = []
6946 packed.append(struct.pack("!B", self.version))
6947 packed.append(struct.pack("!B", self.type))
6948 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
6949 packed.append(struct.pack("!L", self.xid))
6950 packed.append(struct.pack("!B", self.reason))
6951 packed.append('\x00' * 7)
6952 packed.append(self.desc.pack())
6953 length = sum([len(x) for x in packed])
6954 packed[2] = struct.pack("!H", length)
6955 return ''.join(packed)
6956
6957 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08006958 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07006959 obj = port_status()
Dan Talaycof6202252013-07-02 01:00:29 -07006960 _version = reader.read("!B")[0]
6961 assert(_version == 2)
6962 _type = reader.read("!B")[0]
6963 assert(_type == 12)
6964 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08006965 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08006966 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07006967 obj.xid = reader.read("!L")[0]
6968 obj.reason = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07006969 reader.skip(7)
Rich Lanee2567702015-01-26 15:04:35 -08006970 obj.desc = ofp.port_desc.unpack(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07006971 return obj
6972
6973 def __eq__(self, other):
6974 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07006975 if self.xid != other.xid: return False
6976 if self.reason != other.reason: return False
6977 if self.desc != other.desc: return False
6978 return True
6979
Rich Lanec2ee4b82013-04-24 17:12:38 -07006980 def pretty_print(self, q):
6981 q.text("port_status {")
6982 with q.group():
6983 with q.indent(2):
6984 q.breakable()
6985 q.text("xid = ");
6986 if self.xid != None:
6987 q.text("%#x" % self.xid)
6988 else:
6989 q.text('None')
6990 q.text(","); q.breakable()
6991 q.text("reason = ");
6992 q.text("%#x" % self.reason)
6993 q.text(","); q.breakable()
6994 q.text("desc = ");
6995 q.pp(self.desc)
6996 q.breakable()
6997 q.text('}')
6998
Rich Lane7dcdf022013-12-11 14:45:27 -08006999message.subtypes[12] = port_status
7000
7001class queue_get_config_reply(message):
Dan Talaycof6202252013-07-02 01:00:29 -07007002 version = 2
7003 type = 23
Rich Lanec2ee4b82013-04-24 17:12:38 -07007004
7005 def __init__(self, xid=None, port=None, queues=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007006 if xid != None:
7007 self.xid = xid
7008 else:
7009 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007010 if port != None:
7011 self.port = port
7012 else:
7013 self.port = 0
7014 if queues != None:
7015 self.queues = queues
7016 else:
7017 self.queues = []
Rich Lane7dcdf022013-12-11 14:45:27 -08007018 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007019
7020 def pack(self):
7021 packed = []
7022 packed.append(struct.pack("!B", self.version))
7023 packed.append(struct.pack("!B", self.type))
7024 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7025 packed.append(struct.pack("!L", self.xid))
Dan Talaycof6202252013-07-02 01:00:29 -07007026 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007027 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08007028 packed.append(loxi.generic_util.pack_list(self.queues))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007029 length = sum([len(x) for x in packed])
7030 packed[2] = struct.pack("!H", length)
7031 return ''.join(packed)
7032
7033 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007034 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007035 obj = queue_get_config_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07007036 _version = reader.read("!B")[0]
7037 assert(_version == 2)
7038 _type = reader.read("!B")[0]
7039 assert(_type == 23)
7040 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007041 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08007042 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07007043 obj.xid = reader.read("!L")[0]
7044 obj.port = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07007045 reader.skip(4)
Rich Lanee2567702015-01-26 15:04:35 -08007046 obj.queues = loxi.generic_util.unpack_list(reader, ofp.common.packet_queue.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07007047 return obj
7048
7049 def __eq__(self, other):
7050 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007051 if self.xid != other.xid: return False
7052 if self.port != other.port: return False
7053 if self.queues != other.queues: return False
7054 return True
7055
Rich Lanec2ee4b82013-04-24 17:12:38 -07007056 def pretty_print(self, q):
7057 q.text("queue_get_config_reply {")
7058 with q.group():
7059 with q.indent(2):
7060 q.breakable()
7061 q.text("xid = ");
7062 if self.xid != None:
7063 q.text("%#x" % self.xid)
7064 else:
7065 q.text('None')
7066 q.text(","); q.breakable()
7067 q.text("port = ");
7068 q.text(util.pretty_port(self.port))
7069 q.text(","); q.breakable()
7070 q.text("queues = ");
7071 q.pp(self.queues)
7072 q.breakable()
7073 q.text('}')
7074
Rich Lane7dcdf022013-12-11 14:45:27 -08007075message.subtypes[23] = queue_get_config_reply
7076
7077class queue_get_config_request(message):
Dan Talaycof6202252013-07-02 01:00:29 -07007078 version = 2
7079 type = 22
Rich Lanec2ee4b82013-04-24 17:12:38 -07007080
7081 def __init__(self, xid=None, port=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007082 if xid != None:
7083 self.xid = xid
7084 else:
7085 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007086 if port != None:
7087 self.port = port
7088 else:
7089 self.port = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08007090 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007091
7092 def pack(self):
7093 packed = []
7094 packed.append(struct.pack("!B", self.version))
7095 packed.append(struct.pack("!B", self.type))
7096 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7097 packed.append(struct.pack("!L", self.xid))
Dan Talaycof6202252013-07-02 01:00:29 -07007098 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007099 packed.append('\x00' * 4)
7100 length = sum([len(x) for x in packed])
7101 packed[2] = struct.pack("!H", length)
7102 return ''.join(packed)
7103
7104 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007105 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007106 obj = queue_get_config_request()
Dan Talaycof6202252013-07-02 01:00:29 -07007107 _version = reader.read("!B")[0]
7108 assert(_version == 2)
7109 _type = reader.read("!B")[0]
7110 assert(_type == 22)
7111 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007112 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08007113 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07007114 obj.xid = reader.read("!L")[0]
7115 obj.port = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07007116 reader.skip(4)
7117 return obj
7118
7119 def __eq__(self, other):
7120 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007121 if self.xid != other.xid: return False
7122 if self.port != other.port: return False
7123 return True
7124
Rich Lanec2ee4b82013-04-24 17:12:38 -07007125 def pretty_print(self, q):
7126 q.text("queue_get_config_request {")
7127 with q.group():
7128 with q.indent(2):
7129 q.breakable()
7130 q.text("xid = ");
7131 if self.xid != None:
7132 q.text("%#x" % self.xid)
7133 else:
7134 q.text('None')
7135 q.text(","); q.breakable()
7136 q.text("port = ");
7137 q.text(util.pretty_port(self.port))
7138 q.breakable()
7139 q.text('}')
7140
Rich Lane7dcdf022013-12-11 14:45:27 -08007141message.subtypes[22] = queue_get_config_request
7142
7143class queue_op_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07007144 version = 2
7145 type = 1
7146 err_type = 9
7147
7148 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007149 if xid != None:
7150 self.xid = xid
7151 else:
7152 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07007153 if code != None:
7154 self.code = code
7155 else:
7156 self.code = 0
7157 if data != None:
7158 self.data = data
7159 else:
7160 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08007161 return
Rich Lane6f4978c2013-10-20 21:33:52 -07007162
7163 def pack(self):
7164 packed = []
7165 packed.append(struct.pack("!B", self.version))
7166 packed.append(struct.pack("!B", self.type))
7167 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7168 packed.append(struct.pack("!L", self.xid))
7169 packed.append(struct.pack("!H", self.err_type))
7170 packed.append(struct.pack("!H", self.code))
7171 packed.append(self.data)
7172 length = sum([len(x) for x in packed])
7173 packed[2] = struct.pack("!H", length)
7174 return ''.join(packed)
7175
7176 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007177 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07007178 obj = queue_op_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07007179 _version = reader.read("!B")[0]
7180 assert(_version == 2)
7181 _type = reader.read("!B")[0]
7182 assert(_type == 1)
7183 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007184 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08007185 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -07007186 obj.xid = reader.read("!L")[0]
7187 _err_type = reader.read("!H")[0]
7188 assert(_err_type == 9)
7189 obj.code = reader.read("!H")[0]
7190 obj.data = str(reader.read_all())
7191 return obj
7192
7193 def __eq__(self, other):
7194 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07007195 if self.xid != other.xid: return False
7196 if self.code != other.code: return False
7197 if self.data != other.data: return False
7198 return True
7199
Rich Lane6f4978c2013-10-20 21:33:52 -07007200 def pretty_print(self, q):
7201 q.text("queue_op_failed_error_msg {")
7202 with q.group():
7203 with q.indent(2):
7204 q.breakable()
7205 q.text("xid = ");
7206 if self.xid != None:
7207 q.text("%#x" % self.xid)
7208 else:
7209 q.text('None')
7210 q.text(","); q.breakable()
7211 q.text("code = ");
7212 q.text("%#x" % self.code)
7213 q.text(","); q.breakable()
7214 q.text("data = ");
7215 q.pp(self.data)
7216 q.breakable()
7217 q.text('}')
7218
Rich Lane7dcdf022013-12-11 14:45:27 -08007219error_msg.subtypes[9] = queue_op_failed_error_msg
7220
7221class queue_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07007222 version = 2
7223 type = 19
7224 stats_type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07007225
7226 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007227 if xid != None:
7228 self.xid = xid
7229 else:
7230 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007231 if flags != None:
7232 self.flags = flags
7233 else:
7234 self.flags = 0
7235 if entries != None:
7236 self.entries = entries
7237 else:
7238 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08007239 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007240
7241 def pack(self):
7242 packed = []
7243 packed.append(struct.pack("!B", self.version))
7244 packed.append(struct.pack("!B", self.type))
7245 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7246 packed.append(struct.pack("!L", self.xid))
7247 packed.append(struct.pack("!H", self.stats_type))
7248 packed.append(struct.pack("!H", self.flags))
7249 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08007250 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007251 length = sum([len(x) for x in packed])
7252 packed[2] = struct.pack("!H", length)
7253 return ''.join(packed)
7254
7255 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007256 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007257 obj = queue_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07007258 _version = reader.read("!B")[0]
7259 assert(_version == 2)
7260 _type = reader.read("!B")[0]
7261 assert(_type == 19)
7262 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007263 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08007264 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07007265 obj.xid = reader.read("!L")[0]
7266 _stats_type = reader.read("!H")[0]
7267 assert(_stats_type == 5)
7268 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007269 reader.skip(4)
Rich Lanee2567702015-01-26 15:04:35 -08007270 obj.entries = loxi.generic_util.unpack_list(reader, ofp.common.queue_stats_entry.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07007271 return obj
7272
7273 def __eq__(self, other):
7274 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007275 if self.xid != other.xid: return False
7276 if self.flags != other.flags: return False
7277 if self.entries != other.entries: return False
7278 return True
7279
Rich Lanec2ee4b82013-04-24 17:12:38 -07007280 def pretty_print(self, q):
7281 q.text("queue_stats_reply {")
7282 with q.group():
7283 with q.indent(2):
7284 q.breakable()
7285 q.text("xid = ");
7286 if self.xid != None:
7287 q.text("%#x" % self.xid)
7288 else:
7289 q.text('None')
7290 q.text(","); q.breakable()
7291 q.text("flags = ");
7292 q.text("%#x" % self.flags)
7293 q.text(","); q.breakable()
7294 q.text("entries = ");
7295 q.pp(self.entries)
7296 q.breakable()
7297 q.text('}')
7298
Rich Lane7dcdf022013-12-11 14:45:27 -08007299stats_reply.subtypes[5] = queue_stats_reply
7300
7301class queue_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07007302 version = 2
7303 type = 18
7304 stats_type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07007305
7306 def __init__(self, xid=None, flags=None, port_no=None, queue_id=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007307 if xid != None:
7308 self.xid = xid
7309 else:
7310 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007311 if flags != None:
7312 self.flags = flags
7313 else:
7314 self.flags = 0
7315 if port_no != None:
7316 self.port_no = port_no
7317 else:
7318 self.port_no = 0
7319 if queue_id != None:
7320 self.queue_id = queue_id
7321 else:
7322 self.queue_id = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08007323 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007324
7325 def pack(self):
7326 packed = []
7327 packed.append(struct.pack("!B", self.version))
7328 packed.append(struct.pack("!B", self.type))
7329 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7330 packed.append(struct.pack("!L", self.xid))
7331 packed.append(struct.pack("!H", self.stats_type))
7332 packed.append(struct.pack("!H", self.flags))
7333 packed.append('\x00' * 4)
Dan Talaycof6202252013-07-02 01:00:29 -07007334 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007335 packed.append(struct.pack("!L", self.queue_id))
7336 length = sum([len(x) for x in packed])
7337 packed[2] = struct.pack("!H", length)
7338 return ''.join(packed)
7339
7340 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007341 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007342 obj = queue_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07007343 _version = reader.read("!B")[0]
7344 assert(_version == 2)
7345 _type = reader.read("!B")[0]
7346 assert(_type == 18)
7347 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007348 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08007349 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07007350 obj.xid = reader.read("!L")[0]
7351 _stats_type = reader.read("!H")[0]
7352 assert(_stats_type == 5)
7353 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007354 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07007355 obj.port_no = util.unpack_port_no(reader)
7356 obj.queue_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007357 return obj
7358
7359 def __eq__(self, other):
7360 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007361 if self.xid != other.xid: return False
7362 if self.flags != other.flags: return False
7363 if self.port_no != other.port_no: return False
7364 if self.queue_id != other.queue_id: return False
7365 return True
7366
Rich Lanec2ee4b82013-04-24 17:12:38 -07007367 def pretty_print(self, q):
7368 q.text("queue_stats_request {")
7369 with q.group():
7370 with q.indent(2):
7371 q.breakable()
7372 q.text("xid = ");
7373 if self.xid != None:
7374 q.text("%#x" % self.xid)
7375 else:
7376 q.text('None')
7377 q.text(","); q.breakable()
7378 q.text("flags = ");
7379 q.text("%#x" % self.flags)
7380 q.text(","); q.breakable()
7381 q.text("port_no = ");
7382 q.text(util.pretty_port(self.port_no))
7383 q.text(","); q.breakable()
7384 q.text("queue_id = ");
7385 q.text("%#x" % self.queue_id)
7386 q.breakable()
7387 q.text('}')
7388
Rich Lane7dcdf022013-12-11 14:45:27 -08007389stats_request.subtypes[5] = queue_stats_request
7390
7391class set_config(message):
Dan Talaycof6202252013-07-02 01:00:29 -07007392 version = 2
7393 type = 9
Rich Lanec2ee4b82013-04-24 17:12:38 -07007394
7395 def __init__(self, xid=None, flags=None, miss_send_len=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007396 if xid != None:
7397 self.xid = xid
7398 else:
7399 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007400 if flags != None:
7401 self.flags = flags
7402 else:
7403 self.flags = 0
7404 if miss_send_len != None:
7405 self.miss_send_len = miss_send_len
7406 else:
7407 self.miss_send_len = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08007408 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007409
7410 def pack(self):
7411 packed = []
7412 packed.append(struct.pack("!B", self.version))
7413 packed.append(struct.pack("!B", self.type))
7414 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7415 packed.append(struct.pack("!L", self.xid))
7416 packed.append(struct.pack("!H", self.flags))
7417 packed.append(struct.pack("!H", self.miss_send_len))
7418 length = sum([len(x) for x in packed])
7419 packed[2] = struct.pack("!H", length)
7420 return ''.join(packed)
7421
7422 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007423 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007424 obj = set_config()
Dan Talaycof6202252013-07-02 01:00:29 -07007425 _version = reader.read("!B")[0]
7426 assert(_version == 2)
7427 _type = reader.read("!B")[0]
7428 assert(_type == 9)
7429 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007430 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08007431 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07007432 obj.xid = reader.read("!L")[0]
7433 obj.flags = reader.read("!H")[0]
7434 obj.miss_send_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007435 return obj
7436
7437 def __eq__(self, other):
7438 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007439 if self.xid != other.xid: return False
7440 if self.flags != other.flags: return False
7441 if self.miss_send_len != other.miss_send_len: return False
7442 return True
7443
Rich Lanec2ee4b82013-04-24 17:12:38 -07007444 def pretty_print(self, q):
7445 q.text("set_config {")
7446 with q.group():
7447 with q.indent(2):
7448 q.breakable()
7449 q.text("xid = ");
7450 if self.xid != None:
7451 q.text("%#x" % self.xid)
7452 else:
7453 q.text('None')
7454 q.text(","); q.breakable()
7455 q.text("flags = ");
7456 q.text("%#x" % self.flags)
7457 q.text(","); q.breakable()
7458 q.text("miss_send_len = ");
7459 q.text("%#x" % self.miss_send_len)
7460 q.breakable()
7461 q.text('}')
7462
Rich Lane7dcdf022013-12-11 14:45:27 -08007463message.subtypes[9] = set_config
7464
7465class switch_config_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07007466 version = 2
7467 type = 1
7468 err_type = 10
7469
7470 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007471 if xid != None:
7472 self.xid = xid
7473 else:
7474 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07007475 if code != None:
7476 self.code = code
7477 else:
7478 self.code = 0
7479 if data != None:
7480 self.data = data
7481 else:
7482 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08007483 return
Rich Lane6f4978c2013-10-20 21:33:52 -07007484
7485 def pack(self):
7486 packed = []
7487 packed.append(struct.pack("!B", self.version))
7488 packed.append(struct.pack("!B", self.type))
7489 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7490 packed.append(struct.pack("!L", self.xid))
7491 packed.append(struct.pack("!H", self.err_type))
7492 packed.append(struct.pack("!H", self.code))
7493 packed.append(self.data)
7494 length = sum([len(x) for x in packed])
7495 packed[2] = struct.pack("!H", length)
7496 return ''.join(packed)
7497
7498 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007499 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07007500 obj = switch_config_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07007501 _version = reader.read("!B")[0]
7502 assert(_version == 2)
7503 _type = reader.read("!B")[0]
7504 assert(_type == 1)
7505 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007506 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08007507 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -07007508 obj.xid = reader.read("!L")[0]
7509 _err_type = reader.read("!H")[0]
7510 assert(_err_type == 10)
7511 obj.code = reader.read("!H")[0]
7512 obj.data = str(reader.read_all())
7513 return obj
7514
7515 def __eq__(self, other):
7516 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07007517 if self.xid != other.xid: return False
7518 if self.code != other.code: return False
7519 if self.data != other.data: return False
7520 return True
7521
Rich Lane6f4978c2013-10-20 21:33:52 -07007522 def pretty_print(self, q):
7523 q.text("switch_config_failed_error_msg {")
7524 with q.group():
7525 with q.indent(2):
7526 q.breakable()
7527 q.text("xid = ");
7528 if self.xid != None:
7529 q.text("%#x" % self.xid)
7530 else:
7531 q.text('None')
7532 q.text(","); q.breakable()
7533 q.text("code = ");
7534 q.text("%#x" % self.code)
7535 q.text(","); q.breakable()
7536 q.text("data = ");
7537 q.pp(self.data)
7538 q.breakable()
7539 q.text('}')
7540
Rich Lane7dcdf022013-12-11 14:45:27 -08007541error_msg.subtypes[10] = switch_config_failed_error_msg
7542
7543class table_mod(message):
Dan Talaycof6202252013-07-02 01:00:29 -07007544 version = 2
7545 type = 17
Rich Lanec2ee4b82013-04-24 17:12:38 -07007546
7547 def __init__(self, xid=None, table_id=None, config=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007548 if xid != None:
7549 self.xid = xid
7550 else:
7551 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007552 if table_id != None:
7553 self.table_id = table_id
7554 else:
7555 self.table_id = 0
7556 if config != None:
7557 self.config = config
7558 else:
7559 self.config = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08007560 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007561
7562 def pack(self):
7563 packed = []
7564 packed.append(struct.pack("!B", self.version))
7565 packed.append(struct.pack("!B", self.type))
7566 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7567 packed.append(struct.pack("!L", self.xid))
7568 packed.append(struct.pack("!B", self.table_id))
7569 packed.append('\x00' * 3)
7570 packed.append(struct.pack("!L", self.config))
7571 length = sum([len(x) for x in packed])
7572 packed[2] = struct.pack("!H", length)
7573 return ''.join(packed)
7574
7575 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007576 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007577 obj = table_mod()
Dan Talaycof6202252013-07-02 01:00:29 -07007578 _version = reader.read("!B")[0]
7579 assert(_version == 2)
7580 _type = reader.read("!B")[0]
7581 assert(_type == 17)
7582 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007583 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08007584 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07007585 obj.xid = reader.read("!L")[0]
7586 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007587 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07007588 obj.config = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007589 return obj
7590
7591 def __eq__(self, other):
7592 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007593 if self.xid != other.xid: return False
7594 if self.table_id != other.table_id: return False
7595 if self.config != other.config: return False
7596 return True
7597
Rich Lanec2ee4b82013-04-24 17:12:38 -07007598 def pretty_print(self, q):
7599 q.text("table_mod {")
7600 with q.group():
7601 with q.indent(2):
7602 q.breakable()
7603 q.text("xid = ");
7604 if self.xid != None:
7605 q.text("%#x" % self.xid)
7606 else:
7607 q.text('None')
7608 q.text(","); q.breakable()
7609 q.text("table_id = ");
7610 q.text("%#x" % self.table_id)
7611 q.text(","); q.breakable()
7612 q.text("config = ");
7613 q.text("%#x" % self.config)
7614 q.breakable()
7615 q.text('}')
7616
Rich Lane7dcdf022013-12-11 14:45:27 -08007617message.subtypes[17] = table_mod
7618
7619class table_mod_failed_error_msg(error_msg):
Rich Lane6f4978c2013-10-20 21:33:52 -07007620 version = 2
7621 type = 1
7622 err_type = 8
7623
7624 def __init__(self, xid=None, code=None, data=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007625 if xid != None:
7626 self.xid = xid
7627 else:
7628 self.xid = None
Rich Lane6f4978c2013-10-20 21:33:52 -07007629 if code != None:
7630 self.code = code
7631 else:
7632 self.code = 0
7633 if data != None:
7634 self.data = data
7635 else:
7636 self.data = ''
Rich Lane7dcdf022013-12-11 14:45:27 -08007637 return
Rich Lane6f4978c2013-10-20 21:33:52 -07007638
7639 def pack(self):
7640 packed = []
7641 packed.append(struct.pack("!B", self.version))
7642 packed.append(struct.pack("!B", self.type))
7643 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7644 packed.append(struct.pack("!L", self.xid))
7645 packed.append(struct.pack("!H", self.err_type))
7646 packed.append(struct.pack("!H", self.code))
7647 packed.append(self.data)
7648 length = sum([len(x) for x in packed])
7649 packed[2] = struct.pack("!H", length)
7650 return ''.join(packed)
7651
7652 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007653 def unpack(reader):
Rich Lane6f4978c2013-10-20 21:33:52 -07007654 obj = table_mod_failed_error_msg()
Rich Lane6f4978c2013-10-20 21:33:52 -07007655 _version = reader.read("!B")[0]
7656 assert(_version == 2)
7657 _type = reader.read("!B")[0]
7658 assert(_type == 1)
7659 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007660 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08007661 reader = orig_reader.slice(_length, 4)
Rich Lane6f4978c2013-10-20 21:33:52 -07007662 obj.xid = reader.read("!L")[0]
7663 _err_type = reader.read("!H")[0]
7664 assert(_err_type == 8)
7665 obj.code = reader.read("!H")[0]
7666 obj.data = str(reader.read_all())
7667 return obj
7668
7669 def __eq__(self, other):
7670 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07007671 if self.xid != other.xid: return False
7672 if self.code != other.code: return False
7673 if self.data != other.data: return False
7674 return True
7675
Rich Lane6f4978c2013-10-20 21:33:52 -07007676 def pretty_print(self, q):
7677 q.text("table_mod_failed_error_msg {")
7678 with q.group():
7679 with q.indent(2):
7680 q.breakable()
7681 q.text("xid = ");
7682 if self.xid != None:
7683 q.text("%#x" % self.xid)
7684 else:
7685 q.text('None')
7686 q.text(","); q.breakable()
7687 q.text("code = ");
7688 q.text("%#x" % self.code)
7689 q.text(","); q.breakable()
7690 q.text("data = ");
7691 q.pp(self.data)
7692 q.breakable()
7693 q.text('}')
7694
Rich Lane7dcdf022013-12-11 14:45:27 -08007695error_msg.subtypes[8] = table_mod_failed_error_msg
7696
7697class table_stats_reply(stats_reply):
Dan Talaycof6202252013-07-02 01:00:29 -07007698 version = 2
7699 type = 19
7700 stats_type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07007701
7702 def __init__(self, xid=None, flags=None, entries=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007703 if xid != None:
7704 self.xid = xid
7705 else:
7706 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007707 if flags != None:
7708 self.flags = flags
7709 else:
7710 self.flags = 0
7711 if entries != None:
7712 self.entries = entries
7713 else:
7714 self.entries = []
Rich Lane7dcdf022013-12-11 14:45:27 -08007715 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007716
7717 def pack(self):
7718 packed = []
7719 packed.append(struct.pack("!B", self.version))
7720 packed.append(struct.pack("!B", self.type))
7721 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7722 packed.append(struct.pack("!L", self.xid))
7723 packed.append(struct.pack("!H", self.stats_type))
7724 packed.append(struct.pack("!H", self.flags))
7725 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08007726 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007727 length = sum([len(x) for x in packed])
7728 packed[2] = struct.pack("!H", length)
7729 return ''.join(packed)
7730
7731 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007732 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007733 obj = table_stats_reply()
Dan Talaycof6202252013-07-02 01:00:29 -07007734 _version = reader.read("!B")[0]
7735 assert(_version == 2)
7736 _type = reader.read("!B")[0]
7737 assert(_type == 19)
7738 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007739 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08007740 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07007741 obj.xid = reader.read("!L")[0]
7742 _stats_type = reader.read("!H")[0]
7743 assert(_stats_type == 3)
7744 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007745 reader.skip(4)
Rich Lanee2567702015-01-26 15:04:35 -08007746 obj.entries = loxi.generic_util.unpack_list(reader, ofp.common.table_stats_entry.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07007747 return obj
7748
7749 def __eq__(self, other):
7750 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007751 if self.xid != other.xid: return False
7752 if self.flags != other.flags: return False
7753 if self.entries != other.entries: return False
7754 return True
7755
Rich Lanec2ee4b82013-04-24 17:12:38 -07007756 def pretty_print(self, q):
7757 q.text("table_stats_reply {")
7758 with q.group():
7759 with q.indent(2):
7760 q.breakable()
7761 q.text("xid = ");
7762 if self.xid != None:
7763 q.text("%#x" % self.xid)
7764 else:
7765 q.text('None')
7766 q.text(","); q.breakable()
7767 q.text("flags = ");
7768 q.text("%#x" % self.flags)
7769 q.text(","); q.breakable()
7770 q.text("entries = ");
7771 q.pp(self.entries)
7772 q.breakable()
7773 q.text('}')
7774
Rich Lane7dcdf022013-12-11 14:45:27 -08007775stats_reply.subtypes[3] = table_stats_reply
7776
7777class table_stats_request(stats_request):
Dan Talaycof6202252013-07-02 01:00:29 -07007778 version = 2
7779 type = 18
7780 stats_type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07007781
7782 def __init__(self, xid=None, flags=None):
Rich Lane7dcdf022013-12-11 14:45:27 -08007783 if xid != None:
7784 self.xid = xid
7785 else:
7786 self.xid = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07007787 if flags != None:
7788 self.flags = flags
7789 else:
7790 self.flags = 0
Rich Lane7dcdf022013-12-11 14:45:27 -08007791 return
Rich Lanec2ee4b82013-04-24 17:12:38 -07007792
7793 def pack(self):
7794 packed = []
7795 packed.append(struct.pack("!B", self.version))
7796 packed.append(struct.pack("!B", self.type))
7797 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
7798 packed.append(struct.pack("!L", self.xid))
7799 packed.append(struct.pack("!H", self.stats_type))
7800 packed.append(struct.pack("!H", self.flags))
7801 packed.append('\x00' * 4)
7802 length = sum([len(x) for x in packed])
7803 packed[2] = struct.pack("!H", length)
7804 return ''.join(packed)
7805
7806 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08007807 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07007808 obj = table_stats_request()
Dan Talaycof6202252013-07-02 01:00:29 -07007809 _version = reader.read("!B")[0]
7810 assert(_version == 2)
7811 _type = reader.read("!B")[0]
7812 assert(_type == 18)
7813 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08007814 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08007815 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07007816 obj.xid = reader.read("!L")[0]
7817 _stats_type = reader.read("!H")[0]
7818 assert(_stats_type == 3)
7819 obj.flags = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07007820 reader.skip(4)
7821 return obj
7822
7823 def __eq__(self, other):
7824 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07007825 if self.xid != other.xid: return False
7826 if self.flags != other.flags: return False
7827 return True
7828
Rich Lanec2ee4b82013-04-24 17:12:38 -07007829 def pretty_print(self, q):
7830 q.text("table_stats_request {")
7831 with q.group():
7832 with q.indent(2):
7833 q.breakable()
7834 q.text("xid = ");
7835 if self.xid != None:
7836 q.text("%#x" % self.xid)
7837 else:
7838 q.text('None')
7839 q.text(","); q.breakable()
7840 q.text("flags = ");
7841 q.text("%#x" % self.flags)
7842 q.breakable()
7843 q.text('}')
7844
Rich Lane7dcdf022013-12-11 14:45:27 -08007845stats_request.subtypes[3] = table_stats_request
7846
Rich Lanec2ee4b82013-04-24 17:12:38 -07007847
7848def parse_header(buf):
7849 if len(buf) < 8:
7850 raise loxi.ProtocolError("too short to be an OpenFlow message")
7851 return struct.unpack_from("!BBHL", buf)
7852
7853def parse_message(buf):
7854 msg_ver, msg_type, msg_len, msg_xid = parse_header(buf)
Rich Lanee2567702015-01-26 15:04:35 -08007855 if msg_ver != ofp.OFP_VERSION and msg_type != ofp.OFPT_HELLO:
7856 raise loxi.ProtocolError("wrong OpenFlow version (expected %d, got %d)" % (ofp.OFP_VERSION, msg_ver))
Rich Lanec2ee4b82013-04-24 17:12:38 -07007857 if len(buf) != msg_len:
7858 raise loxi.ProtocolError("incorrect message size")
Rich Lane7dcdf022013-12-11 14:45:27 -08007859 return message.unpack(loxi.generic_util.OFReader(buf))