blob: 450c9bb6c91036dee23786e84459107ca2a3a800 [file] [log] [blame]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001# Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2# Copyright (c) 2011, 2012 Open Networking Foundation
3# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
Dan Talaycof6202252013-07-02 01:00:29 -07004# See the file LICENSE.pyloxi which should have been included in the source distribution
Rich Lane7dcdf022013-12-11 14:45:27 -08005
6# Automatically generated by LOXI from template module.py
Rich Lanec2ee4b82013-04-24 17:12:38 -07007# Do not modify
8
Rich Lanec2ee4b82013-04-24 17:12:38 -07009import struct
Rich Lane7dcdf022013-12-11 14:45:27 -080010import loxi
Rich Lanec2ee4b82013-04-24 17:12:38 -070011import util
12import loxi.generic_util
13
Rich Lanee2567702015-01-26 15:04:35 -080014import sys
15ofp = sys.modules['loxi.of13']
16
Rich Lane5454b682014-01-14 17:07:36 -080017class bsn_controller_connection(loxi.OFObject):
18
19 def __init__(self, state=None, auxiliary_id=None, role=None, uri=None):
20 if state != None:
21 self.state = state
22 else:
23 self.state = 0
24 if auxiliary_id != None:
25 self.auxiliary_id = auxiliary_id
26 else:
27 self.auxiliary_id = 0
28 if role != None:
29 self.role = role
30 else:
31 self.role = 0
32 if uri != None:
33 self.uri = uri
34 else:
35 self.uri = ""
36 return
37
38 def pack(self):
39 packed = []
40 packed.append(struct.pack("!B", self.state))
41 packed.append(struct.pack("!B", self.auxiliary_id))
42 packed.append('\x00' * 2)
43 packed.append(struct.pack("!L", self.role))
44 packed.append(struct.pack("!256s", self.uri))
45 return ''.join(packed)
46
47 @staticmethod
48 def unpack(reader):
49 obj = bsn_controller_connection()
50 obj.state = reader.read("!B")[0]
51 obj.auxiliary_id = reader.read("!B")[0]
52 reader.skip(2)
53 obj.role = reader.read("!L")[0]
54 obj.uri = reader.read("!256s")[0].rstrip("\x00")
55 return obj
56
57 def __eq__(self, other):
58 if type(self) != type(other): return False
59 if self.state != other.state: return False
60 if self.auxiliary_id != other.auxiliary_id: return False
61 if self.role != other.role: return False
62 if self.uri != other.uri: return False
63 return True
64
65 def pretty_print(self, q):
66 q.text("bsn_controller_connection {")
67 with q.group():
68 with q.indent(2):
69 q.breakable()
70 q.text("state = ");
71 q.text("%#x" % self.state)
72 q.text(","); q.breakable()
73 q.text("auxiliary_id = ");
74 q.text("%#x" % self.auxiliary_id)
75 q.text(","); q.breakable()
76 q.text("role = ");
77 q.text("%#x" % self.role)
78 q.text(","); q.breakable()
79 q.text("uri = ");
80 q.pp(self.uri)
81 q.breakable()
82 q.text('}')
83
84
Rich Lane93b33132014-04-21 12:20:58 -070085class bsn_debug_counter_desc_stats_entry(loxi.OFObject):
86
87 def __init__(self, counter_id=None, name=None, description=None):
88 if counter_id != None:
89 self.counter_id = counter_id
90 else:
91 self.counter_id = 0
92 if name != None:
93 self.name = name
94 else:
95 self.name = ""
96 if description != None:
97 self.description = description
98 else:
99 self.description = ""
100 return
101
102 def pack(self):
103 packed = []
104 packed.append(struct.pack("!Q", self.counter_id))
105 packed.append(struct.pack("!64s", self.name))
106 packed.append(struct.pack("!256s", self.description))
107 return ''.join(packed)
108
109 @staticmethod
110 def unpack(reader):
111 obj = bsn_debug_counter_desc_stats_entry()
112 obj.counter_id = reader.read("!Q")[0]
113 obj.name = reader.read("!64s")[0].rstrip("\x00")
114 obj.description = reader.read("!256s")[0].rstrip("\x00")
115 return obj
116
117 def __eq__(self, other):
118 if type(self) != type(other): return False
119 if self.counter_id != other.counter_id: return False
120 if self.name != other.name: return False
121 if self.description != other.description: return False
122 return True
123
124 def pretty_print(self, q):
125 q.text("bsn_debug_counter_desc_stats_entry {")
126 with q.group():
127 with q.indent(2):
128 q.breakable()
129 q.text("counter_id = ");
130 q.text("%#x" % self.counter_id)
131 q.text(","); q.breakable()
132 q.text("name = ");
133 q.pp(self.name)
134 q.text(","); q.breakable()
135 q.text("description = ");
136 q.pp(self.description)
137 q.breakable()
138 q.text('}')
139
140
141class bsn_debug_counter_stats_entry(loxi.OFObject):
142
143 def __init__(self, counter_id=None, value=None):
144 if counter_id != None:
145 self.counter_id = counter_id
146 else:
147 self.counter_id = 0
148 if value != None:
149 self.value = value
150 else:
151 self.value = 0
152 return
153
154 def pack(self):
155 packed = []
156 packed.append(struct.pack("!Q", self.counter_id))
157 packed.append(struct.pack("!Q", self.value))
158 return ''.join(packed)
159
160 @staticmethod
161 def unpack(reader):
162 obj = bsn_debug_counter_stats_entry()
163 obj.counter_id = reader.read("!Q")[0]
164 obj.value = reader.read("!Q")[0]
165 return obj
166
167 def __eq__(self, other):
168 if type(self) != type(other): return False
169 if self.counter_id != other.counter_id: return False
170 if self.value != other.value: return False
171 return True
172
173 def pretty_print(self, q):
174 q.text("bsn_debug_counter_stats_entry {")
175 with q.group():
176 with q.indent(2):
177 q.breakable()
178 q.text("counter_id = ");
179 q.text("%#x" % self.counter_id)
180 q.text(","); q.breakable()
181 q.text("value = ");
182 q.text("%#x" % self.value)
183 q.breakable()
184 q.text('}')
185
186
Rich Lane9ec3fca2014-02-26 16:22:56 -0800187class bsn_flow_checksum_bucket_stats_entry(loxi.OFObject):
188
189 def __init__(self, checksum=None):
190 if checksum != None:
191 self.checksum = checksum
192 else:
193 self.checksum = 0
194 return
195
196 def pack(self):
197 packed = []
198 packed.append(struct.pack("!Q", self.checksum))
199 return ''.join(packed)
200
201 @staticmethod
202 def unpack(reader):
203 obj = bsn_flow_checksum_bucket_stats_entry()
204 obj.checksum = reader.read("!Q")[0]
205 return obj
206
207 def __eq__(self, other):
208 if type(self) != type(other): return False
209 if self.checksum != other.checksum: return False
210 return True
211
212 def pretty_print(self, q):
213 q.text("bsn_flow_checksum_bucket_stats_entry {")
214 with q.group():
215 with q.indent(2):
216 q.breakable()
217 q.text("checksum = ");
218 q.text("%#x" % self.checksum)
219 q.breakable()
220 q.text('}')
221
222
Rich Lanecb18dbd2014-12-18 10:02:29 -0800223class bsn_generic_stats_entry(loxi.OFObject):
224
225 def __init__(self, tlvs=None):
226 if tlvs != None:
227 self.tlvs = tlvs
228 else:
229 self.tlvs = []
230 return
231
232 def pack(self):
233 packed = []
234 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
235 packed.append(loxi.generic_util.pack_list(self.tlvs))
236 length = sum([len(x) for x in packed])
237 packed[0] = struct.pack("!H", length)
238 return ''.join(packed)
239
240 @staticmethod
241 def unpack(reader):
242 obj = bsn_generic_stats_entry()
243 _length = reader.read("!H")[0]
244 orig_reader = reader
245 reader = orig_reader.slice(_length, 2)
Rich Lanee2567702015-01-26 15:04:35 -0800246 obj.tlvs = loxi.generic_util.unpack_list(reader, ofp.bsn_tlv.bsn_tlv.unpack)
Rich Lanecb18dbd2014-12-18 10:02:29 -0800247 return obj
248
249 def __eq__(self, other):
250 if type(self) != type(other): return False
251 if self.tlvs != other.tlvs: return False
252 return True
253
254 def pretty_print(self, q):
255 q.text("bsn_generic_stats_entry {")
256 with q.group():
257 with q.indent(2):
258 q.breakable()
259 q.text("tlvs = ");
260 q.pp(self.tlvs)
261 q.breakable()
262 q.text('}')
263
264
Rich Lane5454b682014-01-14 17:07:36 -0800265class bsn_gentable_bucket_stats_entry(loxi.OFObject):
266
267 def __init__(self, checksum=None):
268 if checksum != None:
269 self.checksum = checksum
270 else:
271 self.checksum = 0
272 return
273
274 def pack(self):
275 packed = []
276 packed.append(util.pack_checksum_128(self.checksum))
277 return ''.join(packed)
278
279 @staticmethod
280 def unpack(reader):
281 obj = bsn_gentable_bucket_stats_entry()
282 obj.checksum = util.unpack_checksum_128(reader)
283 return obj
284
285 def __eq__(self, other):
286 if type(self) != type(other): return False
287 if self.checksum != other.checksum: return False
288 return True
289
290 def pretty_print(self, q):
291 q.text("bsn_gentable_bucket_stats_entry {")
292 with q.group():
293 with q.indent(2):
294 q.breakable()
295 q.text("checksum = ");
296 q.pp(self.checksum)
297 q.breakable()
298 q.text('}')
299
300
301class bsn_gentable_desc_stats_entry(loxi.OFObject):
302
303 def __init__(self, table_id=None, name=None, buckets_size=None, max_entries=None):
304 if table_id != None:
305 self.table_id = table_id
306 else:
307 self.table_id = 0
308 if name != None:
309 self.name = name
310 else:
311 self.name = ""
312 if buckets_size != None:
313 self.buckets_size = buckets_size
314 else:
315 self.buckets_size = 0
316 if max_entries != None:
317 self.max_entries = max_entries
318 else:
319 self.max_entries = 0
320 return
321
322 def pack(self):
323 packed = []
324 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
325 packed.append(struct.pack("!H", self.table_id))
326 packed.append(struct.pack("!32s", self.name))
327 packed.append(struct.pack("!L", self.buckets_size))
328 packed.append(struct.pack("!L", self.max_entries))
329 packed.append('\x00' * 4)
330 length = sum([len(x) for x in packed])
331 packed[0] = struct.pack("!H", length)
332 return ''.join(packed)
333
334 @staticmethod
335 def unpack(reader):
336 obj = bsn_gentable_desc_stats_entry()
337 _length = reader.read("!H")[0]
338 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800339 reader = orig_reader.slice(_length, 2)
Rich Lane5454b682014-01-14 17:07:36 -0800340 obj.table_id = reader.read("!H")[0]
341 obj.name = reader.read("!32s")[0].rstrip("\x00")
342 obj.buckets_size = reader.read("!L")[0]
343 obj.max_entries = reader.read("!L")[0]
344 reader.skip(4)
345 return obj
346
347 def __eq__(self, other):
348 if type(self) != type(other): return False
349 if self.table_id != other.table_id: return False
350 if self.name != other.name: return False
351 if self.buckets_size != other.buckets_size: return False
352 if self.max_entries != other.max_entries: return False
353 return True
354
355 def pretty_print(self, q):
356 q.text("bsn_gentable_desc_stats_entry {")
357 with q.group():
358 with q.indent(2):
359 q.breakable()
360 q.text("table_id = ");
361 q.text("%#x" % self.table_id)
362 q.text(","); q.breakable()
363 q.text("name = ");
364 q.pp(self.name)
365 q.text(","); q.breakable()
366 q.text("buckets_size = ");
367 q.text("%#x" % self.buckets_size)
368 q.text(","); q.breakable()
369 q.text("max_entries = ");
370 q.text("%#x" % self.max_entries)
371 q.breakable()
372 q.text('}')
373
374
375class bsn_gentable_entry_desc_stats_entry(loxi.OFObject):
376
377 def __init__(self, checksum=None, key=None, value=None):
378 if checksum != None:
379 self.checksum = checksum
380 else:
381 self.checksum = 0
382 if key != None:
383 self.key = key
384 else:
385 self.key = []
386 if value != None:
387 self.value = value
388 else:
389 self.value = []
390 return
391
392 def pack(self):
393 packed = []
394 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
395 packed.append(struct.pack("!H", 0)) # placeholder for key_length at index 1
396 packed.append(util.pack_checksum_128(self.checksum))
397 packed.append(loxi.generic_util.pack_list(self.key))
398 packed[1] = struct.pack("!H", len(packed[-1]))
399 packed.append(loxi.generic_util.pack_list(self.value))
400 length = sum([len(x) for x in packed])
401 packed[0] = struct.pack("!H", length)
402 return ''.join(packed)
403
404 @staticmethod
405 def unpack(reader):
406 obj = bsn_gentable_entry_desc_stats_entry()
407 _length = reader.read("!H")[0]
408 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800409 reader = orig_reader.slice(_length, 2)
Rich Lane5454b682014-01-14 17:07:36 -0800410 _key_length = reader.read("!H")[0]
411 obj.checksum = util.unpack_checksum_128(reader)
Rich Lanee2567702015-01-26 15:04:35 -0800412 obj.key = loxi.generic_util.unpack_list(reader.slice(_key_length), ofp.bsn_tlv.bsn_tlv.unpack)
413 obj.value = loxi.generic_util.unpack_list(reader, ofp.bsn_tlv.bsn_tlv.unpack)
Rich Lane5454b682014-01-14 17:07:36 -0800414 return obj
415
416 def __eq__(self, other):
417 if type(self) != type(other): return False
418 if self.checksum != other.checksum: return False
419 if self.key != other.key: return False
420 if self.value != other.value: return False
421 return True
422
423 def pretty_print(self, q):
424 q.text("bsn_gentable_entry_desc_stats_entry {")
425 with q.group():
426 with q.indent(2):
427 q.breakable()
428 q.text("checksum = ");
429 q.pp(self.checksum)
430 q.text(","); q.breakable()
431 q.text("key = ");
432 q.pp(self.key)
433 q.text(","); q.breakable()
434 q.text("value = ");
435 q.pp(self.value)
436 q.breakable()
437 q.text('}')
438
439
440class bsn_gentable_entry_stats_entry(loxi.OFObject):
441
442 def __init__(self, key=None, stats=None):
443 if key != None:
444 self.key = key
445 else:
446 self.key = []
447 if stats != None:
448 self.stats = stats
449 else:
450 self.stats = []
451 return
452
453 def pack(self):
454 packed = []
455 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
456 packed.append(struct.pack("!H", 0)) # placeholder for key_length at index 1
457 packed.append(loxi.generic_util.pack_list(self.key))
458 packed[1] = struct.pack("!H", len(packed[-1]))
459 packed.append(loxi.generic_util.pack_list(self.stats))
460 length = sum([len(x) for x in packed])
461 packed[0] = struct.pack("!H", length)
462 return ''.join(packed)
463
464 @staticmethod
465 def unpack(reader):
466 obj = bsn_gentable_entry_stats_entry()
467 _length = reader.read("!H")[0]
468 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800469 reader = orig_reader.slice(_length, 2)
Rich Lane5454b682014-01-14 17:07:36 -0800470 _key_length = reader.read("!H")[0]
Rich Lanee2567702015-01-26 15:04:35 -0800471 obj.key = loxi.generic_util.unpack_list(reader.slice(_key_length), ofp.bsn_tlv.bsn_tlv.unpack)
472 obj.stats = loxi.generic_util.unpack_list(reader, ofp.bsn_tlv.bsn_tlv.unpack)
Rich Lane5454b682014-01-14 17:07:36 -0800473 return obj
474
475 def __eq__(self, other):
476 if type(self) != type(other): return False
477 if self.key != other.key: return False
478 if self.stats != other.stats: return False
479 return True
480
481 def pretty_print(self, q):
482 q.text("bsn_gentable_entry_stats_entry {")
483 with q.group():
484 with q.indent(2):
485 q.breakable()
486 q.text("key = ");
487 q.pp(self.key)
488 q.text(","); q.breakable()
489 q.text("stats = ");
490 q.pp(self.stats)
491 q.breakable()
492 q.text('}')
493
494
495class bsn_gentable_stats_entry(loxi.OFObject):
496
497 def __init__(self, table_id=None, entry_count=None, checksum=None):
498 if table_id != None:
499 self.table_id = table_id
500 else:
501 self.table_id = 0
502 if entry_count != None:
503 self.entry_count = entry_count
504 else:
505 self.entry_count = 0
506 if checksum != None:
507 self.checksum = checksum
508 else:
509 self.checksum = 0
510 return
511
512 def pack(self):
513 packed = []
514 packed.append(struct.pack("!H", self.table_id))
515 packed.append('\x00' * 2)
516 packed.append(struct.pack("!L", self.entry_count))
517 packed.append(util.pack_checksum_128(self.checksum))
518 return ''.join(packed)
519
520 @staticmethod
521 def unpack(reader):
522 obj = bsn_gentable_stats_entry()
523 obj.table_id = reader.read("!H")[0]
524 reader.skip(2)
525 obj.entry_count = reader.read("!L")[0]
526 obj.checksum = util.unpack_checksum_128(reader)
527 return obj
528
529 def __eq__(self, other):
530 if type(self) != type(other): return False
531 if self.table_id != other.table_id: return False
532 if self.entry_count != other.entry_count: return False
533 if self.checksum != other.checksum: return False
534 return True
535
536 def pretty_print(self, q):
537 q.text("bsn_gentable_stats_entry {")
538 with q.group():
539 with q.indent(2):
540 q.breakable()
541 q.text("table_id = ");
542 q.text("%#x" % self.table_id)
543 q.text(","); q.breakable()
544 q.text("entry_count = ");
545 q.text("%#x" % self.entry_count)
546 q.text(","); q.breakable()
547 q.text("checksum = ");
548 q.pp(self.checksum)
549 q.breakable()
550 q.text('}')
551
552
Rich Lane7dcdf022013-12-11 14:45:27 -0800553class bsn_interface(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700554
555 def __init__(self, hw_addr=None, name=None, ipv4_addr=None, ipv4_netmask=None):
556 if hw_addr != None:
557 self.hw_addr = hw_addr
558 else:
559 self.hw_addr = [0,0,0,0,0,0]
560 if name != None:
561 self.name = name
562 else:
563 self.name = ""
564 if ipv4_addr != None:
565 self.ipv4_addr = ipv4_addr
566 else:
567 self.ipv4_addr = 0
568 if ipv4_netmask != None:
569 self.ipv4_netmask = ipv4_netmask
570 else:
571 self.ipv4_netmask = 0
572 return
573
574 def pack(self):
575 packed = []
576 packed.append(struct.pack("!6B", *self.hw_addr))
577 packed.append('\x00' * 2)
578 packed.append(struct.pack("!16s", self.name))
579 packed.append(struct.pack("!L", self.ipv4_addr))
580 packed.append(struct.pack("!L", self.ipv4_netmask))
581 return ''.join(packed)
582
583 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800584 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700585 obj = bsn_interface()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700586 obj.hw_addr = list(reader.read('!6B'))
587 reader.skip(2)
588 obj.name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -0700589 obj.ipv4_addr = reader.read("!L")[0]
590 obj.ipv4_netmask = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700591 return obj
592
593 def __eq__(self, other):
594 if type(self) != type(other): return False
595 if self.hw_addr != other.hw_addr: return False
596 if self.name != other.name: return False
597 if self.ipv4_addr != other.ipv4_addr: return False
598 if self.ipv4_netmask != other.ipv4_netmask: return False
599 return True
600
Rich Lanec2ee4b82013-04-24 17:12:38 -0700601 def pretty_print(self, q):
602 q.text("bsn_interface {")
603 with q.group():
604 with q.indent(2):
605 q.breakable()
606 q.text("hw_addr = ");
607 q.text(util.pretty_mac(self.hw_addr))
608 q.text(","); q.breakable()
609 q.text("name = ");
610 q.pp(self.name)
611 q.text(","); q.breakable()
612 q.text("ipv4_addr = ");
613 q.text(util.pretty_ipv4(self.ipv4_addr))
614 q.text(","); q.breakable()
615 q.text("ipv4_netmask = ");
616 q.text(util.pretty_ipv4(self.ipv4_netmask))
617 q.breakable()
618 q.text('}')
619
Rich Lane7dcdf022013-12-11 14:45:27 -0800620
621class bsn_lacp_stats_entry(loxi.OFObject):
Rich Lane7b0f2012013-11-22 14:15:26 -0800622
623 def __init__(self, port_no=None, actor_sys_priority=None, actor_sys_mac=None, actor_port_priority=None, actor_port_num=None, actor_key=None, convergence_status=None, partner_sys_priority=None, partner_sys_mac=None, partner_port_priority=None, partner_port_num=None, partner_key=None):
624 if port_no != None:
625 self.port_no = port_no
626 else:
627 self.port_no = 0
628 if actor_sys_priority != None:
629 self.actor_sys_priority = actor_sys_priority
630 else:
631 self.actor_sys_priority = 0
632 if actor_sys_mac != None:
633 self.actor_sys_mac = actor_sys_mac
634 else:
635 self.actor_sys_mac = [0,0,0,0,0,0]
636 if actor_port_priority != None:
637 self.actor_port_priority = actor_port_priority
638 else:
639 self.actor_port_priority = 0
640 if actor_port_num != None:
641 self.actor_port_num = actor_port_num
642 else:
643 self.actor_port_num = 0
644 if actor_key != None:
645 self.actor_key = actor_key
646 else:
647 self.actor_key = 0
648 if convergence_status != None:
649 self.convergence_status = convergence_status
650 else:
651 self.convergence_status = 0
652 if partner_sys_priority != None:
653 self.partner_sys_priority = partner_sys_priority
654 else:
655 self.partner_sys_priority = 0
656 if partner_sys_mac != None:
657 self.partner_sys_mac = partner_sys_mac
658 else:
659 self.partner_sys_mac = [0,0,0,0,0,0]
660 if partner_port_priority != None:
661 self.partner_port_priority = partner_port_priority
662 else:
663 self.partner_port_priority = 0
664 if partner_port_num != None:
665 self.partner_port_num = partner_port_num
666 else:
667 self.partner_port_num = 0
668 if partner_key != None:
669 self.partner_key = partner_key
670 else:
671 self.partner_key = 0
672 return
673
674 def pack(self):
675 packed = []
676 packed.append(util.pack_port_no(self.port_no))
677 packed.append(struct.pack("!H", self.actor_sys_priority))
678 packed.append(struct.pack("!6B", *self.actor_sys_mac))
679 packed.append(struct.pack("!H", self.actor_port_priority))
680 packed.append(struct.pack("!H", self.actor_port_num))
681 packed.append(struct.pack("!H", self.actor_key))
682 packed.append(struct.pack("!B", self.convergence_status))
683 packed.append('\x00' * 1)
684 packed.append(struct.pack("!H", self.partner_sys_priority))
685 packed.append(struct.pack("!6B", *self.partner_sys_mac))
686 packed.append(struct.pack("!H", self.partner_port_priority))
687 packed.append(struct.pack("!H", self.partner_port_num))
688 packed.append(struct.pack("!H", self.partner_key))
689 packed.append('\x00' * 2)
690 return ''.join(packed)
691
692 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800693 def unpack(reader):
Rich Lane7b0f2012013-11-22 14:15:26 -0800694 obj = bsn_lacp_stats_entry()
Rich Lane7b0f2012013-11-22 14:15:26 -0800695 obj.port_no = util.unpack_port_no(reader)
696 obj.actor_sys_priority = reader.read("!H")[0]
697 obj.actor_sys_mac = list(reader.read('!6B'))
698 obj.actor_port_priority = reader.read("!H")[0]
699 obj.actor_port_num = reader.read("!H")[0]
700 obj.actor_key = reader.read("!H")[0]
701 obj.convergence_status = reader.read("!B")[0]
702 reader.skip(1)
703 obj.partner_sys_priority = reader.read("!H")[0]
704 obj.partner_sys_mac = list(reader.read('!6B'))
705 obj.partner_port_priority = reader.read("!H")[0]
706 obj.partner_port_num = reader.read("!H")[0]
707 obj.partner_key = reader.read("!H")[0]
708 reader.skip(2)
709 return obj
710
711 def __eq__(self, other):
712 if type(self) != type(other): return False
713 if self.port_no != other.port_no: return False
714 if self.actor_sys_priority != other.actor_sys_priority: return False
715 if self.actor_sys_mac != other.actor_sys_mac: return False
716 if self.actor_port_priority != other.actor_port_priority: return False
717 if self.actor_port_num != other.actor_port_num: return False
718 if self.actor_key != other.actor_key: return False
719 if self.convergence_status != other.convergence_status: return False
720 if self.partner_sys_priority != other.partner_sys_priority: return False
721 if self.partner_sys_mac != other.partner_sys_mac: return False
722 if self.partner_port_priority != other.partner_port_priority: return False
723 if self.partner_port_num != other.partner_port_num: return False
724 if self.partner_key != other.partner_key: return False
725 return True
726
Rich Lane7b0f2012013-11-22 14:15:26 -0800727 def pretty_print(self, q):
728 q.text("bsn_lacp_stats_entry {")
729 with q.group():
730 with q.indent(2):
731 q.breakable()
732 q.text("port_no = ");
733 q.text(util.pretty_port(self.port_no))
734 q.text(","); q.breakable()
735 q.text("actor_sys_priority = ");
736 q.text("%#x" % self.actor_sys_priority)
737 q.text(","); q.breakable()
738 q.text("actor_sys_mac = ");
739 q.text(util.pretty_mac(self.actor_sys_mac))
740 q.text(","); q.breakable()
741 q.text("actor_port_priority = ");
742 q.text("%#x" % self.actor_port_priority)
743 q.text(","); q.breakable()
744 q.text("actor_port_num = ");
745 q.text("%#x" % self.actor_port_num)
746 q.text(","); q.breakable()
747 q.text("actor_key = ");
748 q.text("%#x" % self.actor_key)
749 q.text(","); q.breakable()
750 q.text("convergence_status = ");
751 q.text("%#x" % self.convergence_status)
752 q.text(","); q.breakable()
753 q.text("partner_sys_priority = ");
754 q.text("%#x" % self.partner_sys_priority)
755 q.text(","); q.breakable()
756 q.text("partner_sys_mac = ");
757 q.text(util.pretty_mac(self.partner_sys_mac))
758 q.text(","); q.breakable()
759 q.text("partner_port_priority = ");
760 q.text("%#x" % self.partner_port_priority)
761 q.text(","); q.breakable()
762 q.text("partner_port_num = ");
763 q.text("%#x" % self.partner_port_num)
764 q.text(","); q.breakable()
765 q.text("partner_key = ");
766 q.text("%#x" % self.partner_key)
767 q.breakable()
768 q.text('}')
769
Rich Lane7dcdf022013-12-11 14:45:27 -0800770
771class bsn_port_counter_stats_entry(loxi.OFObject):
772
773 def __init__(self, port_no=None, values=None):
774 if port_no != None:
775 self.port_no = port_no
776 else:
777 self.port_no = 0
778 if values != None:
779 self.values = values
780 else:
781 self.values = []
782 return
783
784 def pack(self):
785 packed = []
786 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
787 packed.append('\x00' * 2)
788 packed.append(util.pack_port_no(self.port_no))
789 packed.append(loxi.generic_util.pack_list(self.values))
790 length = sum([len(x) for x in packed])
791 packed[0] = struct.pack("!H", length)
792 return ''.join(packed)
793
794 @staticmethod
795 def unpack(reader):
796 obj = bsn_port_counter_stats_entry()
797 _length = reader.read("!H")[0]
798 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800799 reader = orig_reader.slice(_length, 2)
Rich Lane7dcdf022013-12-11 14:45:27 -0800800 reader.skip(2)
801 obj.port_no = util.unpack_port_no(reader)
Rich Lanee2567702015-01-26 15:04:35 -0800802 obj.values = loxi.generic_util.unpack_list(reader, ofp.common.uint64.unpack)
Rich Lane7dcdf022013-12-11 14:45:27 -0800803 return obj
804
805 def __eq__(self, other):
806 if type(self) != type(other): return False
807 if self.port_no != other.port_no: return False
808 if self.values != other.values: return False
809 return True
810
811 def pretty_print(self, q):
812 q.text("bsn_port_counter_stats_entry {")
813 with q.group():
814 with q.indent(2):
815 q.breakable()
816 q.text("port_no = ");
817 q.text(util.pretty_port(self.port_no))
818 q.text(","); q.breakable()
819 q.text("values = ");
820 q.pp(self.values)
821 q.breakable()
822 q.text('}')
823
824
825class bsn_switch_pipeline_stats_entry(loxi.OFObject):
826
827 def __init__(self, pipeline=None):
828 if pipeline != None:
829 self.pipeline = pipeline
830 else:
831 self.pipeline = ""
832 return
833
834 def pack(self):
835 packed = []
836 packed.append(struct.pack("!256s", self.pipeline))
837 return ''.join(packed)
838
839 @staticmethod
840 def unpack(reader):
841 obj = bsn_switch_pipeline_stats_entry()
842 obj.pipeline = reader.read("!256s")[0].rstrip("\x00")
843 return obj
844
845 def __eq__(self, other):
846 if type(self) != type(other): return False
847 if self.pipeline != other.pipeline: return False
848 return True
849
850 def pretty_print(self, q):
851 q.text("bsn_switch_pipeline_stats_entry {")
852 with q.group():
853 with q.indent(2):
854 q.breakable()
855 q.text("pipeline = ");
856 q.pp(self.pipeline)
857 q.breakable()
858 q.text('}')
859
860
Rich Lane9ec3fca2014-02-26 16:22:56 -0800861class bsn_table_checksum_stats_entry(loxi.OFObject):
862
863 def __init__(self, table_id=None, checksum=None):
864 if table_id != None:
865 self.table_id = table_id
866 else:
867 self.table_id = 0
868 if checksum != None:
869 self.checksum = checksum
870 else:
871 self.checksum = 0
872 return
873
874 def pack(self):
875 packed = []
876 packed.append(struct.pack("!B", self.table_id))
877 packed.append(struct.pack("!Q", self.checksum))
878 return ''.join(packed)
879
880 @staticmethod
881 def unpack(reader):
882 obj = bsn_table_checksum_stats_entry()
883 obj.table_id = reader.read("!B")[0]
884 obj.checksum = reader.read("!Q")[0]
885 return obj
886
887 def __eq__(self, other):
888 if type(self) != type(other): return False
889 if self.table_id != other.table_id: return False
890 if self.checksum != other.checksum: return False
891 return True
892
893 def pretty_print(self, q):
894 q.text("bsn_table_checksum_stats_entry {")
895 with q.group():
896 with q.indent(2):
897 q.breakable()
898 q.text("table_id = ");
899 q.text("%#x" % self.table_id)
900 q.text(","); q.breakable()
901 q.text("checksum = ");
902 q.text("%#x" % self.checksum)
903 q.breakable()
904 q.text('}')
905
906
Rich Lane7dcdf022013-12-11 14:45:27 -0800907class bsn_vport(loxi.OFObject):
908 subtypes = {}
909
Rich Lane95f7fc92014-01-27 17:08:16 -0800910
911 def __init__(self, type=None):
912 if type != None:
913 self.type = type
914 else:
915 self.type = 0
916 return
917
918 def pack(self):
919 packed = []
920 packed.append(struct.pack("!H", self.type))
921 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
922 length = sum([len(x) for x in packed])
923 packed[1] = struct.pack("!H", length)
924 return ''.join(packed)
925
Rich Lane7dcdf022013-12-11 14:45:27 -0800926 @staticmethod
927 def unpack(reader):
928 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -0800929 subclass = bsn_vport.subtypes.get(subtype)
930 if subclass:
931 return subclass.unpack(reader)
932
933 obj = bsn_vport()
934 obj.type = reader.read("!H")[0]
935 _length = reader.read("!H")[0]
936 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800937 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800938 return obj
939
940 def __eq__(self, other):
941 if type(self) != type(other): return False
942 if self.type != other.type: return False
943 return True
944
945 def pretty_print(self, q):
946 q.text("bsn_vport {")
947 with q.group():
948 with q.indent(2):
949 q.breakable()
950 q.breakable()
951 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800952
953
Rich Lane93b33132014-04-21 12:20:58 -0700954class bsn_vlan_counter_stats_entry(loxi.OFObject):
955
956 def __init__(self, vlan_vid=None, values=None):
957 if vlan_vid != None:
958 self.vlan_vid = vlan_vid
959 else:
960 self.vlan_vid = 0
961 if values != None:
962 self.values = values
963 else:
964 self.values = []
965 return
966
967 def pack(self):
968 packed = []
969 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
970 packed.append(struct.pack("!H", self.vlan_vid))
971 packed.append('\x00' * 4)
972 packed.append(loxi.generic_util.pack_list(self.values))
973 length = sum([len(x) for x in packed])
974 packed[0] = struct.pack("!H", length)
975 return ''.join(packed)
976
977 @staticmethod
978 def unpack(reader):
979 obj = bsn_vlan_counter_stats_entry()
980 _length = reader.read("!H")[0]
981 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800982 reader = orig_reader.slice(_length, 2)
Rich Lane93b33132014-04-21 12:20:58 -0700983 obj.vlan_vid = reader.read("!H")[0]
984 reader.skip(4)
Rich Lanee2567702015-01-26 15:04:35 -0800985 obj.values = loxi.generic_util.unpack_list(reader, ofp.common.uint64.unpack)
Rich Lane93b33132014-04-21 12:20:58 -0700986 return obj
987
988 def __eq__(self, other):
989 if type(self) != type(other): return False
990 if self.vlan_vid != other.vlan_vid: return False
991 if self.values != other.values: return False
992 return True
993
994 def pretty_print(self, q):
995 q.text("bsn_vlan_counter_stats_entry {")
996 with q.group():
997 with q.indent(2):
998 q.breakable()
999 q.text("vlan_vid = ");
1000 q.text("%#x" % self.vlan_vid)
1001 q.text(","); q.breakable()
1002 q.text("values = ");
1003 q.pp(self.values)
1004 q.breakable()
1005 q.text('}')
1006
1007
1008class bsn_vport_l2gre(bsn_vport):
1009 type = 1
1010
Rich Lanef9530c42014-09-15 09:59:43 -07001011 def __init__(self, flags=None, port_no=None, loopback_port_no=None, local_mac=None, nh_mac=None, src_ip=None, dst_ip=None, dscp=None, ttl=None, vpn=None, rate_limit=None, if_name=None):
Rich Lane93b33132014-04-21 12:20:58 -07001012 if flags != None:
1013 self.flags = flags
1014 else:
1015 self.flags = 0
1016 if port_no != None:
1017 self.port_no = port_no
1018 else:
1019 self.port_no = 0
Rich Lane5587ab12014-06-30 11:19:09 -07001020 if loopback_port_no != None:
1021 self.loopback_port_no = loopback_port_no
1022 else:
1023 self.loopback_port_no = 0
Rich Lane93b33132014-04-21 12:20:58 -07001024 if local_mac != None:
1025 self.local_mac = local_mac
1026 else:
1027 self.local_mac = [0,0,0,0,0,0]
1028 if nh_mac != None:
1029 self.nh_mac = nh_mac
1030 else:
1031 self.nh_mac = [0,0,0,0,0,0]
1032 if src_ip != None:
1033 self.src_ip = src_ip
1034 else:
1035 self.src_ip = 0
1036 if dst_ip != None:
1037 self.dst_ip = dst_ip
1038 else:
1039 self.dst_ip = 0
1040 if dscp != None:
1041 self.dscp = dscp
1042 else:
1043 self.dscp = 0
1044 if ttl != None:
1045 self.ttl = ttl
1046 else:
1047 self.ttl = 0
1048 if vpn != None:
1049 self.vpn = vpn
1050 else:
1051 self.vpn = 0
Rich Lanef9530c42014-09-15 09:59:43 -07001052 if rate_limit != None:
1053 self.rate_limit = rate_limit
1054 else:
1055 self.rate_limit = 0
Rich Lane93b33132014-04-21 12:20:58 -07001056 if if_name != None:
1057 self.if_name = if_name
1058 else:
1059 self.if_name = ""
1060 return
1061
1062 def pack(self):
1063 packed = []
1064 packed.append(struct.pack("!H", self.type))
1065 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
1066 packed.append(struct.pack("!L", self.flags))
1067 packed.append(util.pack_port_no(self.port_no))
Rich Lane5587ab12014-06-30 11:19:09 -07001068 packed.append(util.pack_port_no(self.loopback_port_no))
Rich Lane93b33132014-04-21 12:20:58 -07001069 packed.append(struct.pack("!6B", *self.local_mac))
1070 packed.append(struct.pack("!6B", *self.nh_mac))
1071 packed.append(struct.pack("!L", self.src_ip))
1072 packed.append(struct.pack("!L", self.dst_ip))
1073 packed.append(struct.pack("!B", self.dscp))
1074 packed.append(struct.pack("!B", self.ttl))
1075 packed.append('\x00' * 2)
1076 packed.append(struct.pack("!L", self.vpn))
Rich Lanef9530c42014-09-15 09:59:43 -07001077 packed.append(struct.pack("!L", self.rate_limit))
Rich Lane93b33132014-04-21 12:20:58 -07001078 packed.append(struct.pack("!16s", self.if_name))
1079 length = sum([len(x) for x in packed])
1080 packed[1] = struct.pack("!H", length)
1081 return ''.join(packed)
1082
1083 @staticmethod
1084 def unpack(reader):
1085 obj = bsn_vport_l2gre()
1086 _type = reader.read("!H")[0]
1087 assert(_type == 1)
1088 _length = reader.read("!H")[0]
1089 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001090 reader = orig_reader.slice(_length, 4)
Rich Lane93b33132014-04-21 12:20:58 -07001091 obj.flags = reader.read("!L")[0]
1092 obj.port_no = util.unpack_port_no(reader)
Rich Lane5587ab12014-06-30 11:19:09 -07001093 obj.loopback_port_no = util.unpack_port_no(reader)
Rich Lane93b33132014-04-21 12:20:58 -07001094 obj.local_mac = list(reader.read('!6B'))
1095 obj.nh_mac = list(reader.read('!6B'))
1096 obj.src_ip = reader.read("!L")[0]
1097 obj.dst_ip = reader.read("!L")[0]
1098 obj.dscp = reader.read("!B")[0]
1099 obj.ttl = reader.read("!B")[0]
1100 reader.skip(2)
1101 obj.vpn = reader.read("!L")[0]
Rich Lanef9530c42014-09-15 09:59:43 -07001102 obj.rate_limit = reader.read("!L")[0]
Rich Lane93b33132014-04-21 12:20:58 -07001103 obj.if_name = reader.read("!16s")[0].rstrip("\x00")
1104 return obj
1105
1106 def __eq__(self, other):
1107 if type(self) != type(other): return False
1108 if self.flags != other.flags: return False
1109 if self.port_no != other.port_no: return False
Rich Lane5587ab12014-06-30 11:19:09 -07001110 if self.loopback_port_no != other.loopback_port_no: return False
Rich Lane93b33132014-04-21 12:20:58 -07001111 if self.local_mac != other.local_mac: return False
1112 if self.nh_mac != other.nh_mac: return False
1113 if self.src_ip != other.src_ip: return False
1114 if self.dst_ip != other.dst_ip: return False
1115 if self.dscp != other.dscp: return False
1116 if self.ttl != other.ttl: return False
1117 if self.vpn != other.vpn: return False
Rich Lanef9530c42014-09-15 09:59:43 -07001118 if self.rate_limit != other.rate_limit: return False
Rich Lane93b33132014-04-21 12:20:58 -07001119 if self.if_name != other.if_name: return False
1120 return True
1121
1122 def pretty_print(self, q):
1123 q.text("bsn_vport_l2gre {")
1124 with q.group():
1125 with q.indent(2):
1126 q.breakable()
1127 q.text("flags = ");
1128 q.text("%#x" % self.flags)
1129 q.text(","); q.breakable()
1130 q.text("port_no = ");
1131 q.text(util.pretty_port(self.port_no))
1132 q.text(","); q.breakable()
Rich Lane5587ab12014-06-30 11:19:09 -07001133 q.text("loopback_port_no = ");
1134 q.text(util.pretty_port(self.loopback_port_no))
1135 q.text(","); q.breakable()
Rich Lane93b33132014-04-21 12:20:58 -07001136 q.text("local_mac = ");
1137 q.text(util.pretty_mac(self.local_mac))
1138 q.text(","); q.breakable()
1139 q.text("nh_mac = ");
1140 q.text(util.pretty_mac(self.nh_mac))
1141 q.text(","); q.breakable()
1142 q.text("src_ip = ");
1143 q.text(util.pretty_ipv4(self.src_ip))
1144 q.text(","); q.breakable()
1145 q.text("dst_ip = ");
1146 q.text(util.pretty_ipv4(self.dst_ip))
1147 q.text(","); q.breakable()
1148 q.text("dscp = ");
1149 q.text("%#x" % self.dscp)
1150 q.text(","); q.breakable()
1151 q.text("ttl = ");
1152 q.text("%#x" % self.ttl)
1153 q.text(","); q.breakable()
1154 q.text("vpn = ");
1155 q.text("%#x" % self.vpn)
1156 q.text(","); q.breakable()
Rich Lanef9530c42014-09-15 09:59:43 -07001157 q.text("rate_limit = ");
1158 q.text("%#x" % self.rate_limit)
1159 q.text(","); q.breakable()
Rich Lane93b33132014-04-21 12:20:58 -07001160 q.text("if_name = ");
1161 q.pp(self.if_name)
1162 q.breakable()
1163 q.text('}')
1164
1165bsn_vport.subtypes[1] = bsn_vport_l2gre
1166
Rich Lane7dcdf022013-12-11 14:45:27 -08001167class bsn_vport_q_in_q(bsn_vport):
Dan Talaycof6202252013-07-02 01:00:29 -07001168 type = 0
1169
Kiran Poola150d8b02013-09-20 13:30:39 -07001170 def __init__(self, port_no=None, ingress_tpid=None, ingress_vlan_id=None, egress_tpid=None, egress_vlan_id=None, if_name=None):
Dan Talaycof6202252013-07-02 01:00:29 -07001171 if port_no != None:
1172 self.port_no = port_no
1173 else:
1174 self.port_no = 0
1175 if ingress_tpid != None:
1176 self.ingress_tpid = ingress_tpid
1177 else:
1178 self.ingress_tpid = 0
1179 if ingress_vlan_id != None:
1180 self.ingress_vlan_id = ingress_vlan_id
1181 else:
1182 self.ingress_vlan_id = 0
1183 if egress_tpid != None:
1184 self.egress_tpid = egress_tpid
1185 else:
1186 self.egress_tpid = 0
1187 if egress_vlan_id != None:
1188 self.egress_vlan_id = egress_vlan_id
1189 else:
1190 self.egress_vlan_id = 0
Kiran Poola150d8b02013-09-20 13:30:39 -07001191 if if_name != None:
1192 self.if_name = if_name
1193 else:
1194 self.if_name = ""
Dan Talaycof6202252013-07-02 01:00:29 -07001195 return
1196
1197 def pack(self):
1198 packed = []
1199 packed.append(struct.pack("!H", self.type))
Kiran Poola150d8b02013-09-20 13:30:39 -07001200 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -07001201 packed.append(struct.pack("!L", self.port_no))
1202 packed.append(struct.pack("!H", self.ingress_tpid))
1203 packed.append(struct.pack("!H", self.ingress_vlan_id))
1204 packed.append(struct.pack("!H", self.egress_tpid))
1205 packed.append(struct.pack("!H", self.egress_vlan_id))
Kiran Poola150d8b02013-09-20 13:30:39 -07001206 packed.append(struct.pack("!16s", self.if_name))
Dan Talaycof6202252013-07-02 01:00:29 -07001207 length = sum([len(x) for x in packed])
Kiran Poola150d8b02013-09-20 13:30:39 -07001208 packed[1] = struct.pack("!H", length)
Dan Talaycof6202252013-07-02 01:00:29 -07001209 return ''.join(packed)
1210
1211 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001212 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001213 obj = bsn_vport_q_in_q()
Dan Talaycof6202252013-07-02 01:00:29 -07001214 _type = reader.read("!H")[0]
1215 assert(_type == 0)
1216 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001217 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001218 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001219 obj.port_no = reader.read("!L")[0]
1220 obj.ingress_tpid = reader.read("!H")[0]
1221 obj.ingress_vlan_id = reader.read("!H")[0]
1222 obj.egress_tpid = reader.read("!H")[0]
1223 obj.egress_vlan_id = reader.read("!H")[0]
Kiran Poola150d8b02013-09-20 13:30:39 -07001224 obj.if_name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -07001225 return obj
1226
1227 def __eq__(self, other):
1228 if type(self) != type(other): return False
1229 if self.port_no != other.port_no: return False
1230 if self.ingress_tpid != other.ingress_tpid: return False
1231 if self.ingress_vlan_id != other.ingress_vlan_id: return False
1232 if self.egress_tpid != other.egress_tpid: return False
1233 if self.egress_vlan_id != other.egress_vlan_id: return False
Kiran Poola150d8b02013-09-20 13:30:39 -07001234 if self.if_name != other.if_name: return False
Dan Talaycof6202252013-07-02 01:00:29 -07001235 return True
1236
Dan Talaycof6202252013-07-02 01:00:29 -07001237 def pretty_print(self, q):
1238 q.text("bsn_vport_q_in_q {")
1239 with q.group():
1240 with q.indent(2):
1241 q.breakable()
1242 q.text("port_no = ");
1243 q.text("%#x" % self.port_no)
1244 q.text(","); q.breakable()
1245 q.text("ingress_tpid = ");
1246 q.text("%#x" % self.ingress_tpid)
1247 q.text(","); q.breakable()
1248 q.text("ingress_vlan_id = ");
1249 q.text("%#x" % self.ingress_vlan_id)
1250 q.text(","); q.breakable()
1251 q.text("egress_tpid = ");
1252 q.text("%#x" % self.egress_tpid)
1253 q.text(","); q.breakable()
1254 q.text("egress_vlan_id = ");
1255 q.text("%#x" % self.egress_vlan_id)
Kiran Poola150d8b02013-09-20 13:30:39 -07001256 q.text(","); q.breakable()
1257 q.text("if_name = ");
1258 q.pp(self.if_name)
Dan Talaycof6202252013-07-02 01:00:29 -07001259 q.breakable()
1260 q.text('}')
1261
Rich Lane7dcdf022013-12-11 14:45:27 -08001262bsn_vport.subtypes[0] = bsn_vport_q_in_q
1263
Rich Lane5587ab12014-06-30 11:19:09 -07001264class bsn_vrf_counter_stats_entry(loxi.OFObject):
1265
1266 def __init__(self, vrf=None, values=None):
1267 if vrf != None:
1268 self.vrf = vrf
1269 else:
1270 self.vrf = 0
1271 if values != None:
1272 self.values = values
1273 else:
1274 self.values = []
1275 return
1276
1277 def pack(self):
1278 packed = []
1279 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
1280 packed.append('\x00' * 2)
1281 packed.append(struct.pack("!L", self.vrf))
1282 packed.append(loxi.generic_util.pack_list(self.values))
1283 length = sum([len(x) for x in packed])
1284 packed[0] = struct.pack("!H", length)
1285 return ''.join(packed)
1286
1287 @staticmethod
1288 def unpack(reader):
1289 obj = bsn_vrf_counter_stats_entry()
1290 _length = reader.read("!H")[0]
1291 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001292 reader = orig_reader.slice(_length, 2)
Rich Lane5587ab12014-06-30 11:19:09 -07001293 reader.skip(2)
1294 obj.vrf = reader.read("!L")[0]
Rich Lanee2567702015-01-26 15:04:35 -08001295 obj.values = loxi.generic_util.unpack_list(reader, ofp.common.uint64.unpack)
Rich Lane5587ab12014-06-30 11:19:09 -07001296 return obj
1297
1298 def __eq__(self, other):
1299 if type(self) != type(other): return False
1300 if self.vrf != other.vrf: return False
1301 if self.values != other.values: return False
1302 return True
1303
1304 def pretty_print(self, q):
1305 q.text("bsn_vrf_counter_stats_entry {")
1306 with q.group():
1307 with q.indent(2):
1308 q.breakable()
1309 q.text("vrf = ");
1310 q.text("%#x" % self.vrf)
1311 q.text(","); q.breakable()
1312 q.text("values = ");
1313 q.pp(self.values)
1314 q.breakable()
1315 q.text('}')
1316
1317
Rich Lane7dcdf022013-12-11 14:45:27 -08001318class bucket(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001319
1320 def __init__(self, weight=None, watch_port=None, watch_group=None, actions=None):
1321 if weight != None:
1322 self.weight = weight
1323 else:
1324 self.weight = 0
1325 if watch_port != None:
1326 self.watch_port = watch_port
1327 else:
1328 self.watch_port = 0
1329 if watch_group != None:
1330 self.watch_group = watch_group
1331 else:
1332 self.watch_group = 0
1333 if actions != None:
1334 self.actions = actions
1335 else:
1336 self.actions = []
1337 return
1338
1339 def pack(self):
1340 packed = []
1341 packed.append(struct.pack("!H", 0)) # placeholder for len at index 0
1342 packed.append(struct.pack("!H", self.weight))
Dan Talaycof6202252013-07-02 01:00:29 -07001343 packed.append(util.pack_port_no(self.watch_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001344 packed.append(struct.pack("!L", self.watch_group))
1345 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08001346 packed.append(loxi.generic_util.pack_list(self.actions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001347 length = sum([len(x) for x in packed])
1348 packed[0] = struct.pack("!H", length)
1349 return ''.join(packed)
1350
1351 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001352 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001353 obj = bucket()
Dan Talaycof6202252013-07-02 01:00:29 -07001354 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001355 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001356 reader = orig_reader.slice(_len, 2)
Dan Talaycof6202252013-07-02 01:00:29 -07001357 obj.weight = reader.read("!H")[0]
1358 obj.watch_port = util.unpack_port_no(reader)
1359 obj.watch_group = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001360 reader.skip(4)
Rich Lanee2567702015-01-26 15:04:35 -08001361 obj.actions = loxi.generic_util.unpack_list(reader, ofp.action.action.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001362 return obj
1363
1364 def __eq__(self, other):
1365 if type(self) != type(other): return False
1366 if self.weight != other.weight: return False
1367 if self.watch_port != other.watch_port: return False
1368 if self.watch_group != other.watch_group: return False
1369 if self.actions != other.actions: return False
1370 return True
1371
Rich Lanec2ee4b82013-04-24 17:12:38 -07001372 def pretty_print(self, q):
1373 q.text("bucket {")
1374 with q.group():
1375 with q.indent(2):
1376 q.breakable()
1377 q.text("weight = ");
1378 q.text("%#x" % self.weight)
1379 q.text(","); q.breakable()
1380 q.text("watch_port = ");
1381 q.text(util.pretty_port(self.watch_port))
1382 q.text(","); q.breakable()
1383 q.text("watch_group = ");
1384 q.text("%#x" % self.watch_group)
1385 q.text(","); q.breakable()
1386 q.text("actions = ");
1387 q.pp(self.actions)
1388 q.breakable()
1389 q.text('}')
1390
Rich Lane7dcdf022013-12-11 14:45:27 -08001391
1392class bucket_counter(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001393
1394 def __init__(self, packet_count=None, byte_count=None):
1395 if packet_count != None:
1396 self.packet_count = packet_count
1397 else:
1398 self.packet_count = 0
1399 if byte_count != None:
1400 self.byte_count = byte_count
1401 else:
1402 self.byte_count = 0
1403 return
1404
1405 def pack(self):
1406 packed = []
1407 packed.append(struct.pack("!Q", self.packet_count))
1408 packed.append(struct.pack("!Q", self.byte_count))
1409 return ''.join(packed)
1410
1411 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001412 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001413 obj = bucket_counter()
Dan Talaycof6202252013-07-02 01:00:29 -07001414 obj.packet_count = reader.read("!Q")[0]
1415 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001416 return obj
1417
1418 def __eq__(self, other):
1419 if type(self) != type(other): return False
1420 if self.packet_count != other.packet_count: return False
1421 if self.byte_count != other.byte_count: return False
1422 return True
1423
Rich Lanec2ee4b82013-04-24 17:12:38 -07001424 def pretty_print(self, q):
1425 q.text("bucket_counter {")
1426 with q.group():
1427 with q.indent(2):
1428 q.breakable()
1429 q.text("packet_count = ");
1430 q.text("%#x" % self.packet_count)
1431 q.text(","); q.breakable()
1432 q.text("byte_count = ");
1433 q.text("%#x" % self.byte_count)
1434 q.breakable()
1435 q.text('}')
1436
Rich Lane7dcdf022013-12-11 14:45:27 -08001437
Rich Lane7dcdf022013-12-11 14:45:27 -08001438class flow_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001439
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001440 def __init__(self, table_id=None, duration_sec=None, duration_nsec=None, priority=None, idle_timeout=None, hard_timeout=None, flags=None, cookie=None, packet_count=None, byte_count=None, match=None, instructions=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001441 if table_id != None:
1442 self.table_id = table_id
1443 else:
1444 self.table_id = 0
1445 if duration_sec != None:
1446 self.duration_sec = duration_sec
1447 else:
1448 self.duration_sec = 0
1449 if duration_nsec != None:
1450 self.duration_nsec = duration_nsec
1451 else:
1452 self.duration_nsec = 0
1453 if priority != None:
1454 self.priority = priority
1455 else:
1456 self.priority = 0
1457 if idle_timeout != None:
1458 self.idle_timeout = idle_timeout
1459 else:
1460 self.idle_timeout = 0
1461 if hard_timeout != None:
1462 self.hard_timeout = hard_timeout
1463 else:
1464 self.hard_timeout = 0
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001465 if flags != None:
1466 self.flags = flags
1467 else:
1468 self.flags = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07001469 if cookie != None:
1470 self.cookie = cookie
1471 else:
1472 self.cookie = 0
1473 if packet_count != None:
1474 self.packet_count = packet_count
1475 else:
1476 self.packet_count = 0
1477 if byte_count != None:
1478 self.byte_count = byte_count
1479 else:
1480 self.byte_count = 0
1481 if match != None:
1482 self.match = match
1483 else:
Rich Lanee2567702015-01-26 15:04:35 -08001484 self.match = ofp.match()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001485 if instructions != None:
1486 self.instructions = instructions
1487 else:
1488 self.instructions = []
1489 return
1490
1491 def pack(self):
1492 packed = []
1493 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
1494 packed.append(struct.pack("!B", self.table_id))
1495 packed.append('\x00' * 1)
1496 packed.append(struct.pack("!L", self.duration_sec))
1497 packed.append(struct.pack("!L", self.duration_nsec))
1498 packed.append(struct.pack("!H", self.priority))
1499 packed.append(struct.pack("!H", self.idle_timeout))
1500 packed.append(struct.pack("!H", self.hard_timeout))
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001501 packed.append(struct.pack("!H", self.flags))
1502 packed.append('\x00' * 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001503 packed.append(struct.pack("!Q", self.cookie))
1504 packed.append(struct.pack("!Q", self.packet_count))
1505 packed.append(struct.pack("!Q", self.byte_count))
1506 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08001507 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001508 length = sum([len(x) for x in packed])
1509 packed[0] = struct.pack("!H", length)
1510 return ''.join(packed)
1511
1512 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001513 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001514 obj = flow_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001515 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001516 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001517 reader = orig_reader.slice(_length, 2)
Dan Talaycof6202252013-07-02 01:00:29 -07001518 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001519 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -07001520 obj.duration_sec = reader.read("!L")[0]
1521 obj.duration_nsec = reader.read("!L")[0]
1522 obj.priority = reader.read("!H")[0]
1523 obj.idle_timeout = reader.read("!H")[0]
1524 obj.hard_timeout = reader.read("!H")[0]
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001525 obj.flags = reader.read("!H")[0]
1526 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001527 obj.cookie = reader.read("!Q")[0]
1528 obj.packet_count = reader.read("!Q")[0]
1529 obj.byte_count = reader.read("!Q")[0]
Rich Lanee2567702015-01-26 15:04:35 -08001530 obj.match = ofp.match.unpack(reader)
1531 obj.instructions = loxi.generic_util.unpack_list(reader, ofp.instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001532 return obj
1533
1534 def __eq__(self, other):
1535 if type(self) != type(other): return False
1536 if self.table_id != other.table_id: return False
1537 if self.duration_sec != other.duration_sec: return False
1538 if self.duration_nsec != other.duration_nsec: return False
1539 if self.priority != other.priority: return False
1540 if self.idle_timeout != other.idle_timeout: return False
1541 if self.hard_timeout != other.hard_timeout: return False
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001542 if self.flags != other.flags: return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001543 if self.cookie != other.cookie: return False
1544 if self.packet_count != other.packet_count: return False
1545 if self.byte_count != other.byte_count: return False
1546 if self.match != other.match: return False
1547 if self.instructions != other.instructions: return False
1548 return True
1549
Rich Lanec2ee4b82013-04-24 17:12:38 -07001550 def pretty_print(self, q):
1551 q.text("flow_stats_entry {")
1552 with q.group():
1553 with q.indent(2):
1554 q.breakable()
1555 q.text("table_id = ");
1556 q.text("%#x" % self.table_id)
1557 q.text(","); q.breakable()
1558 q.text("duration_sec = ");
1559 q.text("%#x" % self.duration_sec)
1560 q.text(","); q.breakable()
1561 q.text("duration_nsec = ");
1562 q.text("%#x" % self.duration_nsec)
1563 q.text(","); q.breakable()
1564 q.text("priority = ");
1565 q.text("%#x" % self.priority)
1566 q.text(","); q.breakable()
1567 q.text("idle_timeout = ");
1568 q.text("%#x" % self.idle_timeout)
1569 q.text(","); q.breakable()
1570 q.text("hard_timeout = ");
1571 q.text("%#x" % self.hard_timeout)
1572 q.text(","); q.breakable()
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001573 q.text("flags = ");
1574 q.text("%#x" % self.flags)
1575 q.text(","); q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001576 q.text("cookie = ");
1577 q.text("%#x" % self.cookie)
1578 q.text(","); q.breakable()
1579 q.text("packet_count = ");
1580 q.text("%#x" % self.packet_count)
1581 q.text(","); q.breakable()
1582 q.text("byte_count = ");
1583 q.text("%#x" % self.byte_count)
1584 q.text(","); q.breakable()
1585 q.text("match = ");
1586 q.pp(self.match)
1587 q.text(","); q.breakable()
1588 q.text("instructions = ");
1589 q.pp(self.instructions)
1590 q.breakable()
1591 q.text('}')
1592
Rich Lane7dcdf022013-12-11 14:45:27 -08001593
1594class group_desc_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001595
Rich Lane6f4978c2013-10-20 21:33:52 -07001596 def __init__(self, group_type=None, group_id=None, buckets=None):
1597 if group_type != None:
1598 self.group_type = group_type
Rich Lanec2ee4b82013-04-24 17:12:38 -07001599 else:
Rich Lane6f4978c2013-10-20 21:33:52 -07001600 self.group_type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07001601 if group_id != None:
1602 self.group_id = group_id
1603 else:
1604 self.group_id = 0
1605 if buckets != None:
1606 self.buckets = buckets
1607 else:
1608 self.buckets = []
1609 return
1610
1611 def pack(self):
1612 packed = []
1613 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
Rich Lane6f4978c2013-10-20 21:33:52 -07001614 packed.append(struct.pack("!B", self.group_type))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001615 packed.append('\x00' * 1)
1616 packed.append(struct.pack("!L", self.group_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08001617 packed.append(loxi.generic_util.pack_list(self.buckets))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001618 length = sum([len(x) for x in packed])
1619 packed[0] = struct.pack("!H", length)
1620 return ''.join(packed)
1621
1622 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001623 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001624 obj = group_desc_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001625 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001626 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001627 reader = orig_reader.slice(_length, 2)
Rich Lane6f4978c2013-10-20 21:33:52 -07001628 obj.group_type = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001629 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -07001630 obj.group_id = reader.read("!L")[0]
Rich Lanee2567702015-01-26 15:04:35 -08001631 obj.buckets = loxi.generic_util.unpack_list(reader, ofp.common.bucket.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001632 return obj
1633
1634 def __eq__(self, other):
1635 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001636 if self.group_type != other.group_type: return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001637 if self.group_id != other.group_id: return False
1638 if self.buckets != other.buckets: return False
1639 return True
1640
Rich Lanec2ee4b82013-04-24 17:12:38 -07001641 def pretty_print(self, q):
1642 q.text("group_desc_stats_entry {")
1643 with q.group():
1644 with q.indent(2):
1645 q.breakable()
Rich Lane6f4978c2013-10-20 21:33:52 -07001646 q.text("group_type = ");
1647 q.text("%#x" % self.group_type)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001648 q.text(","); q.breakable()
1649 q.text("group_id = ");
1650 q.text("%#x" % self.group_id)
1651 q.text(","); q.breakable()
1652 q.text("buckets = ");
1653 q.pp(self.buckets)
1654 q.breakable()
1655 q.text('}')
1656
Rich Lane7dcdf022013-12-11 14:45:27 -08001657
1658class group_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001659
1660 def __init__(self, group_id=None, ref_count=None, packet_count=None, byte_count=None, duration_sec=None, duration_nsec=None, bucket_stats=None):
1661 if group_id != None:
1662 self.group_id = group_id
1663 else:
1664 self.group_id = 0
1665 if ref_count != None:
1666 self.ref_count = ref_count
1667 else:
1668 self.ref_count = 0
1669 if packet_count != None:
1670 self.packet_count = packet_count
1671 else:
1672 self.packet_count = 0
1673 if byte_count != None:
1674 self.byte_count = byte_count
1675 else:
1676 self.byte_count = 0
1677 if duration_sec != None:
1678 self.duration_sec = duration_sec
1679 else:
1680 self.duration_sec = 0
1681 if duration_nsec != None:
1682 self.duration_nsec = duration_nsec
1683 else:
1684 self.duration_nsec = 0
1685 if bucket_stats != None:
1686 self.bucket_stats = bucket_stats
1687 else:
1688 self.bucket_stats = []
1689 return
1690
1691 def pack(self):
1692 packed = []
1693 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
1694 packed.append('\x00' * 2)
1695 packed.append(struct.pack("!L", self.group_id))
1696 packed.append(struct.pack("!L", self.ref_count))
1697 packed.append('\x00' * 4)
1698 packed.append(struct.pack("!Q", self.packet_count))
1699 packed.append(struct.pack("!Q", self.byte_count))
1700 packed.append(struct.pack("!L", self.duration_sec))
1701 packed.append(struct.pack("!L", self.duration_nsec))
Rich Lane7dcdf022013-12-11 14:45:27 -08001702 packed.append(loxi.generic_util.pack_list(self.bucket_stats))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001703 length = sum([len(x) for x in packed])
1704 packed[0] = struct.pack("!H", length)
1705 return ''.join(packed)
1706
1707 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001708 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001709 obj = group_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001710 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001711 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001712 reader = orig_reader.slice(_length, 2)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001713 reader.skip(2)
Dan Talaycof6202252013-07-02 01:00:29 -07001714 obj.group_id = reader.read("!L")[0]
1715 obj.ref_count = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001716 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001717 obj.packet_count = reader.read("!Q")[0]
1718 obj.byte_count = reader.read("!Q")[0]
1719 obj.duration_sec = reader.read("!L")[0]
1720 obj.duration_nsec = reader.read("!L")[0]
Rich Lanee2567702015-01-26 15:04:35 -08001721 obj.bucket_stats = loxi.generic_util.unpack_list(reader, ofp.common.bucket_counter.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001722 return obj
1723
1724 def __eq__(self, other):
1725 if type(self) != type(other): return False
1726 if self.group_id != other.group_id: return False
1727 if self.ref_count != other.ref_count: return False
1728 if self.packet_count != other.packet_count: return False
1729 if self.byte_count != other.byte_count: return False
1730 if self.duration_sec != other.duration_sec: return False
1731 if self.duration_nsec != other.duration_nsec: return False
1732 if self.bucket_stats != other.bucket_stats: return False
1733 return True
1734
Rich Lanec2ee4b82013-04-24 17:12:38 -07001735 def pretty_print(self, q):
1736 q.text("group_stats_entry {")
1737 with q.group():
1738 with q.indent(2):
1739 q.breakable()
1740 q.text("group_id = ");
1741 q.text("%#x" % self.group_id)
1742 q.text(","); q.breakable()
1743 q.text("ref_count = ");
1744 q.text("%#x" % self.ref_count)
1745 q.text(","); q.breakable()
1746 q.text("packet_count = ");
1747 q.text("%#x" % self.packet_count)
1748 q.text(","); q.breakable()
1749 q.text("byte_count = ");
1750 q.text("%#x" % self.byte_count)
1751 q.text(","); q.breakable()
1752 q.text("duration_sec = ");
1753 q.text("%#x" % self.duration_sec)
1754 q.text(","); q.breakable()
1755 q.text("duration_nsec = ");
1756 q.text("%#x" % self.duration_nsec)
1757 q.text(","); q.breakable()
1758 q.text("bucket_stats = ");
1759 q.pp(self.bucket_stats)
1760 q.breakable()
1761 q.text('}')
1762
Rich Lane7dcdf022013-12-11 14:45:27 -08001763
1764class hello_elem(loxi.OFObject):
1765 subtypes = {}
1766
Rich Lane95f7fc92014-01-27 17:08:16 -08001767
1768 def __init__(self, type=None):
1769 if type != None:
1770 self.type = type
1771 else:
1772 self.type = 0
1773 return
1774
1775 def pack(self):
1776 packed = []
1777 packed.append(struct.pack("!H", self.type))
1778 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
1779 length = sum([len(x) for x in packed])
1780 packed[1] = struct.pack("!H", length)
1781 return ''.join(packed)
1782
Rich Lane7dcdf022013-12-11 14:45:27 -08001783 @staticmethod
1784 def unpack(reader):
1785 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -08001786 subclass = hello_elem.subtypes.get(subtype)
1787 if subclass:
1788 return subclass.unpack(reader)
1789
1790 obj = hello_elem()
1791 obj.type = reader.read("!H")[0]
1792 _length = reader.read("!H")[0]
1793 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001794 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -08001795 return obj
1796
1797 def __eq__(self, other):
1798 if type(self) != type(other): return False
1799 if self.type != other.type: return False
1800 return True
1801
1802 def pretty_print(self, q):
1803 q.text("hello_elem {")
1804 with q.group():
1805 with q.indent(2):
1806 q.breakable()
1807 q.breakable()
1808 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08001809
1810
1811class hello_elem_versionbitmap(hello_elem):
Dan Talaycof6202252013-07-02 01:00:29 -07001812 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07001813
1814 def __init__(self, bitmaps=None):
1815 if bitmaps != None:
1816 self.bitmaps = bitmaps
1817 else:
1818 self.bitmaps = []
1819 return
1820
1821 def pack(self):
1822 packed = []
1823 packed.append(struct.pack("!H", self.type))
1824 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08001825 packed.append(loxi.generic_util.pack_list(self.bitmaps))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001826 length = sum([len(x) for x in packed])
1827 packed[1] = struct.pack("!H", length)
1828 return ''.join(packed)
1829
1830 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001831 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001832 obj = hello_elem_versionbitmap()
Dan Talaycof6202252013-07-02 01:00:29 -07001833 _type = reader.read("!H")[0]
1834 assert(_type == 1)
1835 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001836 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001837 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08001838 obj.bitmaps = loxi.generic_util.unpack_list(reader, ofp.common.uint32.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001839 return obj
1840
1841 def __eq__(self, other):
1842 if type(self) != type(other): return False
1843 if self.bitmaps != other.bitmaps: return False
1844 return True
1845
Rich Lanec2ee4b82013-04-24 17:12:38 -07001846 def pretty_print(self, q):
1847 q.text("hello_elem_versionbitmap {")
1848 with q.group():
1849 with q.indent(2):
1850 q.breakable()
1851 q.text("bitmaps = ");
1852 q.pp(self.bitmaps)
1853 q.breakable()
1854 q.text('}')
1855
Rich Lane7dcdf022013-12-11 14:45:27 -08001856hello_elem.subtypes[1] = hello_elem_versionbitmap
1857
1858class match_v3(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001859 type = 1
1860
1861 def __init__(self, oxm_list=None):
1862 if oxm_list != None:
1863 self.oxm_list = oxm_list
1864 else:
1865 self.oxm_list = []
1866 return
1867
1868 def pack(self):
1869 packed = []
1870 packed.append(struct.pack("!H", self.type))
1871 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08001872 packed.append(loxi.generic_util.pack_list(self.oxm_list))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001873 length = sum([len(x) for x in packed])
1874 packed[1] = struct.pack("!H", length)
Rich Laned53156a2013-08-05 17:17:33 -07001875 packed.append(loxi.generic_util.pad_to(8, length))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001876 return ''.join(packed)
1877
1878 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001879 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001880 obj = match_v3()
Dan Talaycof6202252013-07-02 01:00:29 -07001881 _type = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001882 assert(_type == 1)
Dan Talaycof6202252013-07-02 01:00:29 -07001883 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001884 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001885 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08001886 obj.oxm_list = loxi.generic_util.unpack_list(reader, ofp.oxm.oxm.unpack)
Rich Lane7dcdf022013-12-11 14:45:27 -08001887 orig_reader.skip_align()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001888 return obj
1889
1890 def __eq__(self, other):
1891 if type(self) != type(other): return False
1892 if self.oxm_list != other.oxm_list: return False
1893 return True
1894
Rich Lanec2ee4b82013-04-24 17:12:38 -07001895 def pretty_print(self, q):
1896 q.text("match_v3 {")
1897 with q.group():
1898 with q.indent(2):
1899 q.breakable()
1900 q.text("oxm_list = ");
1901 q.pp(self.oxm_list)
1902 q.breakable()
1903 q.text('}')
1904
Rich Lane7dcdf022013-12-11 14:45:27 -08001905
1906class meter_band_stats(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001907
1908 def __init__(self, packet_band_count=None, byte_band_count=None):
1909 if packet_band_count != None:
1910 self.packet_band_count = packet_band_count
1911 else:
1912 self.packet_band_count = 0
1913 if byte_band_count != None:
1914 self.byte_band_count = byte_band_count
1915 else:
1916 self.byte_band_count = 0
1917 return
1918
1919 def pack(self):
1920 packed = []
1921 packed.append(struct.pack("!Q", self.packet_band_count))
1922 packed.append(struct.pack("!Q", self.byte_band_count))
1923 return ''.join(packed)
1924
1925 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001926 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001927 obj = meter_band_stats()
Dan Talaycof6202252013-07-02 01:00:29 -07001928 obj.packet_band_count = reader.read("!Q")[0]
1929 obj.byte_band_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001930 return obj
1931
1932 def __eq__(self, other):
1933 if type(self) != type(other): return False
1934 if self.packet_band_count != other.packet_band_count: return False
1935 if self.byte_band_count != other.byte_band_count: return False
1936 return True
1937
Rich Lanec2ee4b82013-04-24 17:12:38 -07001938 def pretty_print(self, q):
1939 q.text("meter_band_stats {")
1940 with q.group():
1941 with q.indent(2):
1942 q.breakable()
1943 q.text("packet_band_count = ");
1944 q.text("%#x" % self.packet_band_count)
1945 q.text(","); q.breakable()
1946 q.text("byte_band_count = ");
1947 q.text("%#x" % self.byte_band_count)
1948 q.breakable()
1949 q.text('}')
1950
Rich Lane7dcdf022013-12-11 14:45:27 -08001951
1952class meter_config(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001953
1954 def __init__(self, flags=None, meter_id=None, entries=None):
1955 if flags != None:
1956 self.flags = flags
1957 else:
1958 self.flags = 0
1959 if meter_id != None:
1960 self.meter_id = meter_id
1961 else:
1962 self.meter_id = 0
1963 if entries != None:
1964 self.entries = entries
1965 else:
1966 self.entries = []
1967 return
1968
1969 def pack(self):
1970 packed = []
1971 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
1972 packed.append(struct.pack("!H", self.flags))
1973 packed.append(struct.pack("!L", self.meter_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08001974 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001975 length = sum([len(x) for x in packed])
1976 packed[0] = struct.pack("!H", length)
1977 return ''.join(packed)
1978
1979 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001980 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001981 obj = meter_config()
Dan Talaycof6202252013-07-02 01:00:29 -07001982 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001983 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001984 reader = orig_reader.slice(_length, 2)
Dan Talaycof6202252013-07-02 01:00:29 -07001985 obj.flags = reader.read("!H")[0]
1986 obj.meter_id = reader.read("!L")[0]
Rich Lanee2567702015-01-26 15:04:35 -08001987 obj.entries = loxi.generic_util.unpack_list(reader, ofp.meter_band.meter_band.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001988 return obj
1989
1990 def __eq__(self, other):
1991 if type(self) != type(other): return False
1992 if self.flags != other.flags: return False
1993 if self.meter_id != other.meter_id: return False
1994 if self.entries != other.entries: return False
1995 return True
1996
Rich Lanec2ee4b82013-04-24 17:12:38 -07001997 def pretty_print(self, q):
1998 q.text("meter_config {")
1999 with q.group():
2000 with q.indent(2):
2001 q.breakable()
2002 q.text("flags = ");
2003 q.text("%#x" % self.flags)
2004 q.text(","); q.breakable()
2005 q.text("meter_id = ");
2006 q.text("%#x" % self.meter_id)
2007 q.text(","); q.breakable()
2008 q.text("entries = ");
2009 q.pp(self.entries)
2010 q.breakable()
2011 q.text('}')
2012
Rich Lane7dcdf022013-12-11 14:45:27 -08002013
2014class meter_features(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002015
2016 def __init__(self, max_meter=None, band_types=None, capabilities=None, max_bands=None, max_color=None):
2017 if max_meter != None:
2018 self.max_meter = max_meter
2019 else:
2020 self.max_meter = 0
2021 if band_types != None:
2022 self.band_types = band_types
2023 else:
2024 self.band_types = 0
2025 if capabilities != None:
2026 self.capabilities = capabilities
2027 else:
2028 self.capabilities = 0
2029 if max_bands != None:
2030 self.max_bands = max_bands
2031 else:
2032 self.max_bands = 0
2033 if max_color != None:
2034 self.max_color = max_color
2035 else:
2036 self.max_color = 0
2037 return
2038
2039 def pack(self):
2040 packed = []
2041 packed.append(struct.pack("!L", self.max_meter))
2042 packed.append(struct.pack("!L", self.band_types))
2043 packed.append(struct.pack("!L", self.capabilities))
2044 packed.append(struct.pack("!B", self.max_bands))
2045 packed.append(struct.pack("!B", self.max_color))
2046 packed.append('\x00' * 2)
2047 return ''.join(packed)
2048
2049 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002050 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002051 obj = meter_features()
Dan Talaycof6202252013-07-02 01:00:29 -07002052 obj.max_meter = reader.read("!L")[0]
2053 obj.band_types = reader.read("!L")[0]
2054 obj.capabilities = reader.read("!L")[0]
2055 obj.max_bands = reader.read("!B")[0]
2056 obj.max_color = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002057 reader.skip(2)
2058 return obj
2059
2060 def __eq__(self, other):
2061 if type(self) != type(other): return False
2062 if self.max_meter != other.max_meter: return False
2063 if self.band_types != other.band_types: return False
2064 if self.capabilities != other.capabilities: return False
2065 if self.max_bands != other.max_bands: return False
2066 if self.max_color != other.max_color: return False
2067 return True
2068
Rich Lanec2ee4b82013-04-24 17:12:38 -07002069 def pretty_print(self, q):
2070 q.text("meter_features {")
2071 with q.group():
2072 with q.indent(2):
2073 q.breakable()
2074 q.text("max_meter = ");
2075 q.text("%#x" % self.max_meter)
2076 q.text(","); q.breakable()
2077 q.text("band_types = ");
2078 q.text("%#x" % self.band_types)
2079 q.text(","); q.breakable()
2080 q.text("capabilities = ");
2081 q.text("%#x" % self.capabilities)
2082 q.text(","); q.breakable()
2083 q.text("max_bands = ");
2084 q.text("%#x" % self.max_bands)
2085 q.text(","); q.breakable()
2086 q.text("max_color = ");
2087 q.text("%#x" % self.max_color)
2088 q.breakable()
2089 q.text('}')
2090
Rich Lane7dcdf022013-12-11 14:45:27 -08002091
2092class meter_stats(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002093
2094 def __init__(self, meter_id=None, flow_count=None, packet_in_count=None, byte_in_count=None, duration_sec=None, duration_nsec=None, band_stats=None):
2095 if meter_id != None:
2096 self.meter_id = meter_id
2097 else:
2098 self.meter_id = 0
2099 if flow_count != None:
2100 self.flow_count = flow_count
2101 else:
2102 self.flow_count = 0
2103 if packet_in_count != None:
2104 self.packet_in_count = packet_in_count
2105 else:
2106 self.packet_in_count = 0
2107 if byte_in_count != None:
2108 self.byte_in_count = byte_in_count
2109 else:
2110 self.byte_in_count = 0
2111 if duration_sec != None:
2112 self.duration_sec = duration_sec
2113 else:
2114 self.duration_sec = 0
2115 if duration_nsec != None:
2116 self.duration_nsec = duration_nsec
2117 else:
2118 self.duration_nsec = 0
2119 if band_stats != None:
2120 self.band_stats = band_stats
2121 else:
2122 self.band_stats = []
2123 return
2124
2125 def pack(self):
2126 packed = []
2127 packed.append(struct.pack("!L", self.meter_id))
2128 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2129 packed.append('\x00' * 6)
2130 packed.append(struct.pack("!L", self.flow_count))
2131 packed.append(struct.pack("!Q", self.packet_in_count))
2132 packed.append(struct.pack("!Q", self.byte_in_count))
2133 packed.append(struct.pack("!L", self.duration_sec))
2134 packed.append(struct.pack("!L", self.duration_nsec))
Rich Lane7dcdf022013-12-11 14:45:27 -08002135 packed.append(loxi.generic_util.pack_list(self.band_stats))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002136 length = sum([len(x) for x in packed])
2137 packed[1] = struct.pack("!H", length)
2138 return ''.join(packed)
2139
2140 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002141 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002142 obj = meter_stats()
Dan Talaycof6202252013-07-02 01:00:29 -07002143 obj.meter_id = reader.read("!L")[0]
2144 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002145 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002146 reader = orig_reader.slice(_len, 6)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002147 reader.skip(6)
Dan Talaycof6202252013-07-02 01:00:29 -07002148 obj.flow_count = reader.read("!L")[0]
2149 obj.packet_in_count = reader.read("!Q")[0]
2150 obj.byte_in_count = reader.read("!Q")[0]
2151 obj.duration_sec = reader.read("!L")[0]
2152 obj.duration_nsec = reader.read("!L")[0]
Rich Lanee2567702015-01-26 15:04:35 -08002153 obj.band_stats = loxi.generic_util.unpack_list(reader, ofp.common.meter_band_stats.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002154 return obj
2155
2156 def __eq__(self, other):
2157 if type(self) != type(other): return False
2158 if self.meter_id != other.meter_id: return False
2159 if self.flow_count != other.flow_count: return False
2160 if self.packet_in_count != other.packet_in_count: return False
2161 if self.byte_in_count != other.byte_in_count: return False
2162 if self.duration_sec != other.duration_sec: return False
2163 if self.duration_nsec != other.duration_nsec: return False
2164 if self.band_stats != other.band_stats: return False
2165 return True
2166
Rich Lanec2ee4b82013-04-24 17:12:38 -07002167 def pretty_print(self, q):
2168 q.text("meter_stats {")
2169 with q.group():
2170 with q.indent(2):
2171 q.breakable()
2172 q.text("meter_id = ");
2173 q.text("%#x" % self.meter_id)
2174 q.text(","); q.breakable()
2175 q.text("flow_count = ");
2176 q.text("%#x" % self.flow_count)
2177 q.text(","); q.breakable()
2178 q.text("packet_in_count = ");
2179 q.text("%#x" % self.packet_in_count)
2180 q.text(","); q.breakable()
2181 q.text("byte_in_count = ");
2182 q.text("%#x" % self.byte_in_count)
2183 q.text(","); q.breakable()
2184 q.text("duration_sec = ");
2185 q.text("%#x" % self.duration_sec)
2186 q.text(","); q.breakable()
2187 q.text("duration_nsec = ");
2188 q.text("%#x" % self.duration_nsec)
2189 q.text(","); q.breakable()
2190 q.text("band_stats = ");
2191 q.pp(self.band_stats)
2192 q.breakable()
2193 q.text('}')
2194
Rich Lane7dcdf022013-12-11 14:45:27 -08002195
2196class packet_queue(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002197
2198 def __init__(self, queue_id=None, port=None, properties=None):
2199 if queue_id != None:
2200 self.queue_id = queue_id
2201 else:
2202 self.queue_id = 0
2203 if port != None:
2204 self.port = port
2205 else:
2206 self.port = 0
2207 if properties != None:
2208 self.properties = properties
2209 else:
2210 self.properties = []
2211 return
2212
2213 def pack(self):
2214 packed = []
2215 packed.append(struct.pack("!L", self.queue_id))
Dan Talaycof6202252013-07-02 01:00:29 -07002216 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002217 packed.append(struct.pack("!H", 0)) # placeholder for len at index 2
2218 packed.append('\x00' * 6)
Rich Lane7dcdf022013-12-11 14:45:27 -08002219 packed.append(loxi.generic_util.pack_list(self.properties))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002220 length = sum([len(x) for x in packed])
2221 packed[2] = struct.pack("!H", length)
2222 return ''.join(packed)
2223
2224 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002225 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002226 obj = packet_queue()
Dan Talaycof6202252013-07-02 01:00:29 -07002227 obj.queue_id = reader.read("!L")[0]
2228 obj.port = util.unpack_port_no(reader)
2229 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002230 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002231 reader = orig_reader.slice(_len, 10)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002232 reader.skip(6)
Rich Lanee2567702015-01-26 15:04:35 -08002233 obj.properties = loxi.generic_util.unpack_list(reader, ofp.common.queue_prop.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002234 return obj
2235
2236 def __eq__(self, other):
2237 if type(self) != type(other): return False
2238 if self.queue_id != other.queue_id: return False
2239 if self.port != other.port: return False
2240 if self.properties != other.properties: return False
2241 return True
2242
Rich Lanec2ee4b82013-04-24 17:12:38 -07002243 def pretty_print(self, q):
2244 q.text("packet_queue {")
2245 with q.group():
2246 with q.indent(2):
2247 q.breakable()
2248 q.text("queue_id = ");
2249 q.text("%#x" % self.queue_id)
2250 q.text(","); q.breakable()
2251 q.text("port = ");
2252 q.text(util.pretty_port(self.port))
2253 q.text(","); q.breakable()
2254 q.text("properties = ");
2255 q.pp(self.properties)
2256 q.breakable()
2257 q.text('}')
2258
Rich Lane7dcdf022013-12-11 14:45:27 -08002259
2260class port_desc(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002261
2262 def __init__(self, port_no=None, hw_addr=None, name=None, config=None, state=None, curr=None, advertised=None, supported=None, peer=None, curr_speed=None, max_speed=None):
2263 if port_no != None:
2264 self.port_no = port_no
2265 else:
2266 self.port_no = 0
2267 if hw_addr != None:
2268 self.hw_addr = hw_addr
2269 else:
2270 self.hw_addr = [0,0,0,0,0,0]
2271 if name != None:
2272 self.name = name
2273 else:
2274 self.name = ""
2275 if config != None:
2276 self.config = config
2277 else:
2278 self.config = 0
2279 if state != None:
2280 self.state = state
2281 else:
2282 self.state = 0
2283 if curr != None:
2284 self.curr = curr
2285 else:
2286 self.curr = 0
2287 if advertised != None:
2288 self.advertised = advertised
2289 else:
2290 self.advertised = 0
2291 if supported != None:
2292 self.supported = supported
2293 else:
2294 self.supported = 0
2295 if peer != None:
2296 self.peer = peer
2297 else:
2298 self.peer = 0
2299 if curr_speed != None:
2300 self.curr_speed = curr_speed
2301 else:
2302 self.curr_speed = 0
2303 if max_speed != None:
2304 self.max_speed = max_speed
2305 else:
2306 self.max_speed = 0
2307 return
2308
2309 def pack(self):
2310 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07002311 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002312 packed.append('\x00' * 4)
2313 packed.append(struct.pack("!6B", *self.hw_addr))
2314 packed.append('\x00' * 2)
2315 packed.append(struct.pack("!16s", self.name))
2316 packed.append(struct.pack("!L", self.config))
2317 packed.append(struct.pack("!L", self.state))
2318 packed.append(struct.pack("!L", self.curr))
2319 packed.append(struct.pack("!L", self.advertised))
2320 packed.append(struct.pack("!L", self.supported))
2321 packed.append(struct.pack("!L", self.peer))
2322 packed.append(struct.pack("!L", self.curr_speed))
2323 packed.append(struct.pack("!L", self.max_speed))
2324 return ''.join(packed)
2325
2326 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002327 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002328 obj = port_desc()
Dan Talaycof6202252013-07-02 01:00:29 -07002329 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002330 reader.skip(4)
2331 obj.hw_addr = list(reader.read('!6B'))
2332 reader.skip(2)
2333 obj.name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -07002334 obj.config = reader.read("!L")[0]
2335 obj.state = reader.read("!L")[0]
2336 obj.curr = reader.read("!L")[0]
2337 obj.advertised = reader.read("!L")[0]
2338 obj.supported = reader.read("!L")[0]
2339 obj.peer = reader.read("!L")[0]
2340 obj.curr_speed = reader.read("!L")[0]
2341 obj.max_speed = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002342 return obj
2343
2344 def __eq__(self, other):
2345 if type(self) != type(other): return False
2346 if self.port_no != other.port_no: return False
2347 if self.hw_addr != other.hw_addr: return False
2348 if self.name != other.name: return False
2349 if self.config != other.config: return False
2350 if self.state != other.state: return False
2351 if self.curr != other.curr: return False
2352 if self.advertised != other.advertised: return False
2353 if self.supported != other.supported: return False
2354 if self.peer != other.peer: return False
2355 if self.curr_speed != other.curr_speed: return False
2356 if self.max_speed != other.max_speed: return False
2357 return True
2358
Rich Lanec2ee4b82013-04-24 17:12:38 -07002359 def pretty_print(self, q):
2360 q.text("port_desc {")
2361 with q.group():
2362 with q.indent(2):
2363 q.breakable()
2364 q.text("port_no = ");
2365 q.text(util.pretty_port(self.port_no))
2366 q.text(","); q.breakable()
2367 q.text("hw_addr = ");
2368 q.text(util.pretty_mac(self.hw_addr))
2369 q.text(","); q.breakable()
2370 q.text("name = ");
2371 q.pp(self.name)
2372 q.text(","); q.breakable()
2373 q.text("config = ");
2374 q.text("%#x" % self.config)
2375 q.text(","); q.breakable()
2376 q.text("state = ");
2377 q.text("%#x" % self.state)
2378 q.text(","); q.breakable()
2379 q.text("curr = ");
2380 q.text("%#x" % self.curr)
2381 q.text(","); q.breakable()
2382 q.text("advertised = ");
2383 q.text("%#x" % self.advertised)
2384 q.text(","); q.breakable()
2385 q.text("supported = ");
2386 q.text("%#x" % self.supported)
2387 q.text(","); q.breakable()
2388 q.text("peer = ");
2389 q.text("%#x" % self.peer)
2390 q.text(","); q.breakable()
2391 q.text("curr_speed = ");
2392 q.text("%#x" % self.curr_speed)
2393 q.text(","); q.breakable()
2394 q.text("max_speed = ");
2395 q.text("%#x" % self.max_speed)
2396 q.breakable()
2397 q.text('}')
2398
Rich Lane7dcdf022013-12-11 14:45:27 -08002399
2400class port_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002401
2402 def __init__(self, port_no=None, rx_packets=None, tx_packets=None, rx_bytes=None, tx_bytes=None, rx_dropped=None, tx_dropped=None, rx_errors=None, tx_errors=None, rx_frame_err=None, rx_over_err=None, rx_crc_err=None, collisions=None, duration_sec=None, duration_nsec=None):
2403 if port_no != None:
2404 self.port_no = port_no
2405 else:
2406 self.port_no = 0
2407 if rx_packets != None:
2408 self.rx_packets = rx_packets
2409 else:
2410 self.rx_packets = 0
2411 if tx_packets != None:
2412 self.tx_packets = tx_packets
2413 else:
2414 self.tx_packets = 0
2415 if rx_bytes != None:
2416 self.rx_bytes = rx_bytes
2417 else:
2418 self.rx_bytes = 0
2419 if tx_bytes != None:
2420 self.tx_bytes = tx_bytes
2421 else:
2422 self.tx_bytes = 0
2423 if rx_dropped != None:
2424 self.rx_dropped = rx_dropped
2425 else:
2426 self.rx_dropped = 0
2427 if tx_dropped != None:
2428 self.tx_dropped = tx_dropped
2429 else:
2430 self.tx_dropped = 0
2431 if rx_errors != None:
2432 self.rx_errors = rx_errors
2433 else:
2434 self.rx_errors = 0
2435 if tx_errors != None:
2436 self.tx_errors = tx_errors
2437 else:
2438 self.tx_errors = 0
2439 if rx_frame_err != None:
2440 self.rx_frame_err = rx_frame_err
2441 else:
2442 self.rx_frame_err = 0
2443 if rx_over_err != None:
2444 self.rx_over_err = rx_over_err
2445 else:
2446 self.rx_over_err = 0
2447 if rx_crc_err != None:
2448 self.rx_crc_err = rx_crc_err
2449 else:
2450 self.rx_crc_err = 0
2451 if collisions != None:
2452 self.collisions = collisions
2453 else:
2454 self.collisions = 0
2455 if duration_sec != None:
2456 self.duration_sec = duration_sec
2457 else:
2458 self.duration_sec = 0
2459 if duration_nsec != None:
2460 self.duration_nsec = duration_nsec
2461 else:
2462 self.duration_nsec = 0
2463 return
2464
2465 def pack(self):
2466 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07002467 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002468 packed.append('\x00' * 4)
2469 packed.append(struct.pack("!Q", self.rx_packets))
2470 packed.append(struct.pack("!Q", self.tx_packets))
2471 packed.append(struct.pack("!Q", self.rx_bytes))
2472 packed.append(struct.pack("!Q", self.tx_bytes))
2473 packed.append(struct.pack("!Q", self.rx_dropped))
2474 packed.append(struct.pack("!Q", self.tx_dropped))
2475 packed.append(struct.pack("!Q", self.rx_errors))
2476 packed.append(struct.pack("!Q", self.tx_errors))
2477 packed.append(struct.pack("!Q", self.rx_frame_err))
2478 packed.append(struct.pack("!Q", self.rx_over_err))
2479 packed.append(struct.pack("!Q", self.rx_crc_err))
2480 packed.append(struct.pack("!Q", self.collisions))
2481 packed.append(struct.pack("!L", self.duration_sec))
2482 packed.append(struct.pack("!L", self.duration_nsec))
2483 return ''.join(packed)
2484
2485 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002486 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002487 obj = port_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07002488 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002489 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07002490 obj.rx_packets = reader.read("!Q")[0]
2491 obj.tx_packets = reader.read("!Q")[0]
2492 obj.rx_bytes = reader.read("!Q")[0]
2493 obj.tx_bytes = reader.read("!Q")[0]
2494 obj.rx_dropped = reader.read("!Q")[0]
2495 obj.tx_dropped = reader.read("!Q")[0]
2496 obj.rx_errors = reader.read("!Q")[0]
2497 obj.tx_errors = reader.read("!Q")[0]
2498 obj.rx_frame_err = reader.read("!Q")[0]
2499 obj.rx_over_err = reader.read("!Q")[0]
2500 obj.rx_crc_err = reader.read("!Q")[0]
2501 obj.collisions = reader.read("!Q")[0]
2502 obj.duration_sec = reader.read("!L")[0]
2503 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002504 return obj
2505
2506 def __eq__(self, other):
2507 if type(self) != type(other): return False
2508 if self.port_no != other.port_no: return False
2509 if self.rx_packets != other.rx_packets: return False
2510 if self.tx_packets != other.tx_packets: return False
2511 if self.rx_bytes != other.rx_bytes: return False
2512 if self.tx_bytes != other.tx_bytes: return False
2513 if self.rx_dropped != other.rx_dropped: return False
2514 if self.tx_dropped != other.tx_dropped: return False
2515 if self.rx_errors != other.rx_errors: return False
2516 if self.tx_errors != other.tx_errors: return False
2517 if self.rx_frame_err != other.rx_frame_err: return False
2518 if self.rx_over_err != other.rx_over_err: return False
2519 if self.rx_crc_err != other.rx_crc_err: return False
2520 if self.collisions != other.collisions: return False
2521 if self.duration_sec != other.duration_sec: return False
2522 if self.duration_nsec != other.duration_nsec: return False
2523 return True
2524
Rich Lanec2ee4b82013-04-24 17:12:38 -07002525 def pretty_print(self, q):
2526 q.text("port_stats_entry {")
2527 with q.group():
2528 with q.indent(2):
2529 q.breakable()
2530 q.text("port_no = ");
2531 q.text(util.pretty_port(self.port_no))
2532 q.text(","); q.breakable()
2533 q.text("rx_packets = ");
2534 q.text("%#x" % self.rx_packets)
2535 q.text(","); q.breakable()
2536 q.text("tx_packets = ");
2537 q.text("%#x" % self.tx_packets)
2538 q.text(","); q.breakable()
2539 q.text("rx_bytes = ");
2540 q.text("%#x" % self.rx_bytes)
2541 q.text(","); q.breakable()
2542 q.text("tx_bytes = ");
2543 q.text("%#x" % self.tx_bytes)
2544 q.text(","); q.breakable()
2545 q.text("rx_dropped = ");
2546 q.text("%#x" % self.rx_dropped)
2547 q.text(","); q.breakable()
2548 q.text("tx_dropped = ");
2549 q.text("%#x" % self.tx_dropped)
2550 q.text(","); q.breakable()
2551 q.text("rx_errors = ");
2552 q.text("%#x" % self.rx_errors)
2553 q.text(","); q.breakable()
2554 q.text("tx_errors = ");
2555 q.text("%#x" % self.tx_errors)
2556 q.text(","); q.breakable()
2557 q.text("rx_frame_err = ");
2558 q.text("%#x" % self.rx_frame_err)
2559 q.text(","); q.breakable()
2560 q.text("rx_over_err = ");
2561 q.text("%#x" % self.rx_over_err)
2562 q.text(","); q.breakable()
2563 q.text("rx_crc_err = ");
2564 q.text("%#x" % self.rx_crc_err)
2565 q.text(","); q.breakable()
2566 q.text("collisions = ");
2567 q.text("%#x" % self.collisions)
2568 q.text(","); q.breakable()
2569 q.text("duration_sec = ");
2570 q.text("%#x" % self.duration_sec)
2571 q.text(","); q.breakable()
2572 q.text("duration_nsec = ");
2573 q.text("%#x" % self.duration_nsec)
2574 q.breakable()
2575 q.text('}')
2576
Rich Lane7dcdf022013-12-11 14:45:27 -08002577
2578class queue_prop(loxi.OFObject):
2579 subtypes = {}
2580
Rich Lane95f7fc92014-01-27 17:08:16 -08002581
2582 def __init__(self, type=None):
2583 if type != None:
2584 self.type = type
2585 else:
2586 self.type = 0
2587 return
2588
2589 def pack(self):
2590 packed = []
2591 packed.append(struct.pack("!H", self.type))
2592 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2593 packed.append('\x00' * 4)
2594 length = sum([len(x) for x in packed])
2595 packed[1] = struct.pack("!H", length)
2596 return ''.join(packed)
2597
Rich Lane7dcdf022013-12-11 14:45:27 -08002598 @staticmethod
2599 def unpack(reader):
2600 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -08002601 subclass = queue_prop.subtypes.get(subtype)
2602 if subclass:
2603 return subclass.unpack(reader)
2604
2605 obj = queue_prop()
2606 obj.type = reader.read("!H")[0]
2607 _len = reader.read("!H")[0]
2608 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002609 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -08002610 reader.skip(4)
2611 return obj
2612
2613 def __eq__(self, other):
2614 if type(self) != type(other): return False
2615 if self.type != other.type: return False
2616 return True
2617
2618 def pretty_print(self, q):
2619 q.text("queue_prop {")
2620 with q.group():
2621 with q.indent(2):
2622 q.breakable()
2623 q.breakable()
2624 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002625
2626
2627class queue_prop_experimenter(queue_prop):
2628 subtypes = {}
2629
Rich Lane95f7fc92014-01-27 17:08:16 -08002630 type = 65535
2631
2632 def __init__(self, experimenter=None, data=None):
2633 if experimenter != None:
2634 self.experimenter = experimenter
2635 else:
2636 self.experimenter = 0
2637 if data != None:
2638 self.data = data
2639 else:
2640 self.data = ''
2641 return
2642
2643 def pack(self):
2644 packed = []
2645 packed.append(struct.pack("!H", self.type))
2646 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2647 packed.append('\x00' * 4)
2648 packed.append(struct.pack("!L", self.experimenter))
2649 packed.append('\x00' * 4)
2650 packed.append(self.data)
2651 length = sum([len(x) for x in packed])
2652 packed[1] = struct.pack("!H", length)
2653 return ''.join(packed)
2654
Rich Lane7dcdf022013-12-11 14:45:27 -08002655 @staticmethod
2656 def unpack(reader):
2657 subtype, = reader.peek('!L', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -08002658 subclass = queue_prop_experimenter.subtypes.get(subtype)
2659 if subclass:
2660 return subclass.unpack(reader)
2661
2662 obj = queue_prop_experimenter()
2663 _type = reader.read("!H")[0]
2664 assert(_type == 65535)
2665 _len = reader.read("!H")[0]
2666 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002667 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -08002668 reader.skip(4)
2669 obj.experimenter = reader.read("!L")[0]
2670 reader.skip(4)
2671 obj.data = str(reader.read_all())
2672 return obj
2673
2674 def __eq__(self, other):
2675 if type(self) != type(other): return False
2676 if self.experimenter != other.experimenter: return False
2677 if self.data != other.data: return False
2678 return True
2679
2680 def pretty_print(self, q):
2681 q.text("queue_prop_experimenter {")
2682 with q.group():
2683 with q.indent(2):
2684 q.breakable()
2685 q.text("data = ");
2686 q.pp(self.data)
2687 q.breakable()
2688 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002689
2690queue_prop.subtypes[65535] = queue_prop_experimenter
2691
2692class queue_prop_max_rate(queue_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002693 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07002694
2695 def __init__(self, rate=None):
2696 if rate != None:
2697 self.rate = rate
2698 else:
2699 self.rate = 0
2700 return
2701
2702 def pack(self):
2703 packed = []
2704 packed.append(struct.pack("!H", self.type))
2705 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2706 packed.append('\x00' * 4)
2707 packed.append(struct.pack("!H", self.rate))
2708 packed.append('\x00' * 6)
2709 length = sum([len(x) for x in packed])
2710 packed[1] = struct.pack("!H", length)
2711 return ''.join(packed)
2712
2713 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002714 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002715 obj = queue_prop_max_rate()
Dan Talaycof6202252013-07-02 01:00:29 -07002716 _type = reader.read("!H")[0]
2717 assert(_type == 2)
2718 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002719 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002720 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002721 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07002722 obj.rate = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002723 reader.skip(6)
2724 return obj
2725
2726 def __eq__(self, other):
2727 if type(self) != type(other): return False
2728 if self.rate != other.rate: return False
2729 return True
2730
Rich Lanec2ee4b82013-04-24 17:12:38 -07002731 def pretty_print(self, q):
2732 q.text("queue_prop_max_rate {")
2733 with q.group():
2734 with q.indent(2):
2735 q.breakable()
2736 q.text("rate = ");
2737 q.text("%#x" % self.rate)
2738 q.breakable()
2739 q.text('}')
2740
Rich Lane7dcdf022013-12-11 14:45:27 -08002741queue_prop.subtypes[2] = queue_prop_max_rate
2742
2743class queue_prop_min_rate(queue_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002744 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07002745
2746 def __init__(self, rate=None):
2747 if rate != None:
2748 self.rate = rate
2749 else:
2750 self.rate = 0
2751 return
2752
2753 def pack(self):
2754 packed = []
2755 packed.append(struct.pack("!H", self.type))
2756 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2757 packed.append('\x00' * 4)
2758 packed.append(struct.pack("!H", self.rate))
2759 packed.append('\x00' * 6)
2760 length = sum([len(x) for x in packed])
2761 packed[1] = struct.pack("!H", length)
2762 return ''.join(packed)
2763
2764 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002765 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002766 obj = queue_prop_min_rate()
Dan Talaycof6202252013-07-02 01:00:29 -07002767 _type = reader.read("!H")[0]
2768 assert(_type == 1)
2769 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002770 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002771 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002772 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07002773 obj.rate = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002774 reader.skip(6)
2775 return obj
2776
2777 def __eq__(self, other):
2778 if type(self) != type(other): return False
2779 if self.rate != other.rate: return False
2780 return True
2781
Rich Lanec2ee4b82013-04-24 17:12:38 -07002782 def pretty_print(self, q):
2783 q.text("queue_prop_min_rate {")
2784 with q.group():
2785 with q.indent(2):
2786 q.breakable()
2787 q.text("rate = ");
2788 q.text("%#x" % self.rate)
2789 q.breakable()
2790 q.text('}')
2791
Rich Lane7dcdf022013-12-11 14:45:27 -08002792queue_prop.subtypes[1] = queue_prop_min_rate
2793
2794class queue_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002795
2796 def __init__(self, port_no=None, queue_id=None, tx_bytes=None, tx_packets=None, tx_errors=None, duration_sec=None, duration_nsec=None):
2797 if port_no != None:
2798 self.port_no = port_no
2799 else:
2800 self.port_no = 0
2801 if queue_id != None:
2802 self.queue_id = queue_id
2803 else:
2804 self.queue_id = 0
2805 if tx_bytes != None:
2806 self.tx_bytes = tx_bytes
2807 else:
2808 self.tx_bytes = 0
2809 if tx_packets != None:
2810 self.tx_packets = tx_packets
2811 else:
2812 self.tx_packets = 0
2813 if tx_errors != None:
2814 self.tx_errors = tx_errors
2815 else:
2816 self.tx_errors = 0
2817 if duration_sec != None:
2818 self.duration_sec = duration_sec
2819 else:
2820 self.duration_sec = 0
2821 if duration_nsec != None:
2822 self.duration_nsec = duration_nsec
2823 else:
2824 self.duration_nsec = 0
2825 return
2826
2827 def pack(self):
2828 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07002829 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002830 packed.append(struct.pack("!L", self.queue_id))
2831 packed.append(struct.pack("!Q", self.tx_bytes))
2832 packed.append(struct.pack("!Q", self.tx_packets))
2833 packed.append(struct.pack("!Q", self.tx_errors))
2834 packed.append(struct.pack("!L", self.duration_sec))
2835 packed.append(struct.pack("!L", self.duration_nsec))
2836 return ''.join(packed)
2837
2838 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002839 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002840 obj = queue_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07002841 obj.port_no = util.unpack_port_no(reader)
2842 obj.queue_id = reader.read("!L")[0]
2843 obj.tx_bytes = reader.read("!Q")[0]
2844 obj.tx_packets = reader.read("!Q")[0]
2845 obj.tx_errors = reader.read("!Q")[0]
2846 obj.duration_sec = reader.read("!L")[0]
2847 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002848 return obj
2849
2850 def __eq__(self, other):
2851 if type(self) != type(other): return False
2852 if self.port_no != other.port_no: return False
2853 if self.queue_id != other.queue_id: return False
2854 if self.tx_bytes != other.tx_bytes: return False
2855 if self.tx_packets != other.tx_packets: return False
2856 if self.tx_errors != other.tx_errors: return False
2857 if self.duration_sec != other.duration_sec: return False
2858 if self.duration_nsec != other.duration_nsec: return False
2859 return True
2860
Rich Lanec2ee4b82013-04-24 17:12:38 -07002861 def pretty_print(self, q):
2862 q.text("queue_stats_entry {")
2863 with q.group():
2864 with q.indent(2):
2865 q.breakable()
2866 q.text("port_no = ");
2867 q.text(util.pretty_port(self.port_no))
2868 q.text(","); q.breakable()
2869 q.text("queue_id = ");
2870 q.text("%#x" % self.queue_id)
2871 q.text(","); q.breakable()
2872 q.text("tx_bytes = ");
2873 q.text("%#x" % self.tx_bytes)
2874 q.text(","); q.breakable()
2875 q.text("tx_packets = ");
2876 q.text("%#x" % self.tx_packets)
2877 q.text(","); q.breakable()
2878 q.text("tx_errors = ");
2879 q.text("%#x" % self.tx_errors)
2880 q.text(","); q.breakable()
2881 q.text("duration_sec = ");
2882 q.text("%#x" % self.duration_sec)
2883 q.text(","); q.breakable()
2884 q.text("duration_nsec = ");
2885 q.text("%#x" % self.duration_nsec)
2886 q.breakable()
2887 q.text('}')
2888
Rich Lane7dcdf022013-12-11 14:45:27 -08002889
2890class table_feature_prop(loxi.OFObject):
2891 subtypes = {}
2892
Rich Lane95f7fc92014-01-27 17:08:16 -08002893
2894 def __init__(self, type=None):
2895 if type != None:
2896 self.type = type
2897 else:
2898 self.type = 0
2899 return
2900
2901 def pack(self):
2902 packed = []
2903 packed.append(struct.pack("!H", self.type))
2904 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
2905 length = sum([len(x) for x in packed])
2906 packed[1] = struct.pack("!H", length)
2907 return ''.join(packed)
2908
Rich Lane7dcdf022013-12-11 14:45:27 -08002909 @staticmethod
2910 def unpack(reader):
2911 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -08002912 subclass = table_feature_prop.subtypes.get(subtype)
2913 if subclass:
2914 return subclass.unpack(reader)
2915
2916 obj = table_feature_prop()
2917 obj.type = reader.read("!H")[0]
2918 _length = reader.read("!H")[0]
2919 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002920 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -08002921 return obj
2922
2923 def __eq__(self, other):
2924 if type(self) != type(other): return False
2925 if self.type != other.type: return False
2926 return True
2927
2928 def pretty_print(self, q):
2929 q.text("table_feature_prop {")
2930 with q.group():
2931 with q.indent(2):
2932 q.breakable()
2933 q.breakable()
2934 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002935
2936
2937class table_feature_prop_apply_actions(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002938 type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07002939
Dan Talaycof6202252013-07-02 01:00:29 -07002940 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002941 if action_ids != None:
2942 self.action_ids = action_ids
2943 else:
2944 self.action_ids = []
2945 return
2946
2947 def pack(self):
2948 packed = []
2949 packed.append(struct.pack("!H", self.type))
2950 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002951 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002952 length = sum([len(x) for x in packed])
2953 packed[1] = struct.pack("!H", length)
2954 return ''.join(packed)
2955
2956 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002957 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002958 obj = table_feature_prop_apply_actions()
Dan Talaycof6202252013-07-02 01:00:29 -07002959 _type = reader.read("!H")[0]
2960 assert(_type == 6)
2961 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002962 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002963 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08002964 obj.action_ids = loxi.generic_util.unpack_list(reader, ofp.action_id.action_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002965 return obj
2966
2967 def __eq__(self, other):
2968 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002969 if self.action_ids != other.action_ids: return False
2970 return True
2971
Rich Lanec2ee4b82013-04-24 17:12:38 -07002972 def pretty_print(self, q):
2973 q.text("table_feature_prop_apply_actions {")
2974 with q.group():
2975 with q.indent(2):
2976 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002977 q.text("action_ids = ");
2978 q.pp(self.action_ids)
2979 q.breakable()
2980 q.text('}')
2981
Rich Lane7dcdf022013-12-11 14:45:27 -08002982table_feature_prop.subtypes[6] = table_feature_prop_apply_actions
2983
2984class table_feature_prop_apply_actions_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002985 type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07002986
Dan Talaycof6202252013-07-02 01:00:29 -07002987 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002988 if action_ids != None:
2989 self.action_ids = action_ids
2990 else:
2991 self.action_ids = []
2992 return
2993
2994 def pack(self):
2995 packed = []
2996 packed.append(struct.pack("!H", self.type))
2997 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002998 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002999 length = sum([len(x) for x in packed])
3000 packed[1] = struct.pack("!H", length)
3001 return ''.join(packed)
3002
3003 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003004 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003005 obj = table_feature_prop_apply_actions_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07003006 _type = reader.read("!H")[0]
3007 assert(_type == 7)
3008 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003009 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003010 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08003011 obj.action_ids = loxi.generic_util.unpack_list(reader, ofp.action_id.action_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003012 return obj
3013
3014 def __eq__(self, other):
3015 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003016 if self.action_ids != other.action_ids: return False
3017 return True
3018
Rich Lanec2ee4b82013-04-24 17:12:38 -07003019 def pretty_print(self, q):
3020 q.text("table_feature_prop_apply_actions_miss {")
3021 with q.group():
3022 with q.indent(2):
3023 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003024 q.text("action_ids = ");
3025 q.pp(self.action_ids)
3026 q.breakable()
3027 q.text('}')
3028
Rich Lane7dcdf022013-12-11 14:45:27 -08003029table_feature_prop.subtypes[7] = table_feature_prop_apply_actions_miss
3030
3031class table_feature_prop_apply_setfield(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003032 type = 14
Rich Lanec2ee4b82013-04-24 17:12:38 -07003033
Dan Talaycof6202252013-07-02 01:00:29 -07003034 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003035 if oxm_ids != None:
3036 self.oxm_ids = oxm_ids
3037 else:
3038 self.oxm_ids = []
3039 return
3040
3041 def pack(self):
3042 packed = []
3043 packed.append(struct.pack("!H", self.type))
3044 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003045 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003046 length = sum([len(x) for x in packed])
3047 packed[1] = struct.pack("!H", length)
3048 return ''.join(packed)
3049
3050 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003051 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003052 obj = table_feature_prop_apply_setfield()
Dan Talaycof6202252013-07-02 01:00:29 -07003053 _type = reader.read("!H")[0]
3054 assert(_type == 14)
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)
Rich Lanee2567702015-01-26 15:04:35 -08003058 obj.oxm_ids = loxi.generic_util.unpack_list(reader, ofp.common.uint32.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003059 return obj
3060
3061 def __eq__(self, other):
3062 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003063 if self.oxm_ids != other.oxm_ids: return False
3064 return True
3065
Rich Lanec2ee4b82013-04-24 17:12:38 -07003066 def pretty_print(self, q):
3067 q.text("table_feature_prop_apply_setfield {")
3068 with q.group():
3069 with q.indent(2):
3070 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003071 q.text("oxm_ids = ");
3072 q.pp(self.oxm_ids)
3073 q.breakable()
3074 q.text('}')
3075
Rich Lane7dcdf022013-12-11 14:45:27 -08003076table_feature_prop.subtypes[14] = table_feature_prop_apply_setfield
3077
3078class table_feature_prop_apply_setfield_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003079 type = 15
Rich Lanec2ee4b82013-04-24 17:12:38 -07003080
Dan Talaycof6202252013-07-02 01:00:29 -07003081 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003082 if oxm_ids != None:
3083 self.oxm_ids = oxm_ids
3084 else:
3085 self.oxm_ids = []
3086 return
3087
3088 def pack(self):
3089 packed = []
3090 packed.append(struct.pack("!H", self.type))
3091 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003092 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003093 length = sum([len(x) for x in packed])
3094 packed[1] = struct.pack("!H", length)
3095 return ''.join(packed)
3096
3097 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003098 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003099 obj = table_feature_prop_apply_setfield_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07003100 _type = reader.read("!H")[0]
3101 assert(_type == 15)
3102 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003103 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003104 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08003105 obj.oxm_ids = loxi.generic_util.unpack_list(reader, ofp.common.uint32.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003106 return obj
3107
3108 def __eq__(self, other):
3109 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003110 if self.oxm_ids != other.oxm_ids: return False
3111 return True
3112
Rich Lanec2ee4b82013-04-24 17:12:38 -07003113 def pretty_print(self, q):
3114 q.text("table_feature_prop_apply_setfield_miss {")
3115 with q.group():
3116 with q.indent(2):
3117 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003118 q.text("oxm_ids = ");
3119 q.pp(self.oxm_ids)
3120 q.breakable()
3121 q.text('}')
3122
Rich Lane7dcdf022013-12-11 14:45:27 -08003123table_feature_prop.subtypes[15] = table_feature_prop_apply_setfield_miss
3124
3125class table_feature_prop_experimenter(table_feature_prop):
Rich Lane2e079da2014-10-29 15:30:24 -07003126 subtypes = {}
3127
Rich Lane9ec3fca2014-02-26 16:22:56 -08003128 type = 65534
Rich Lanec2ee4b82013-04-24 17:12:38 -07003129
Dan Talaycof6202252013-07-02 01:00:29 -07003130 def __init__(self, experimenter=None, subtype=None, experimenter_data=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003131 if experimenter != None:
3132 self.experimenter = experimenter
3133 else:
3134 self.experimenter = 0
3135 if subtype != None:
3136 self.subtype = subtype
3137 else:
3138 self.subtype = 0
3139 if experimenter_data != None:
3140 self.experimenter_data = experimenter_data
3141 else:
Dan Talaycof6202252013-07-02 01:00:29 -07003142 self.experimenter_data = ''
Rich Lanec2ee4b82013-04-24 17:12:38 -07003143 return
3144
3145 def pack(self):
3146 packed = []
3147 packed.append(struct.pack("!H", self.type))
3148 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
3149 packed.append(struct.pack("!L", self.experimenter))
3150 packed.append(struct.pack("!L", self.subtype))
3151 packed.append(self.experimenter_data)
3152 length = sum([len(x) for x in packed])
3153 packed[1] = struct.pack("!H", length)
3154 return ''.join(packed)
3155
3156 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003157 def unpack(reader):
Rich Lane2e079da2014-10-29 15:30:24 -07003158 subtype, = reader.peek('!L', 4)
3159 subclass = table_feature_prop_experimenter.subtypes.get(subtype)
3160 if subclass:
3161 return subclass.unpack(reader)
3162
Rich Lanec2ee4b82013-04-24 17:12:38 -07003163 obj = table_feature_prop_experimenter()
Dan Talaycof6202252013-07-02 01:00:29 -07003164 _type = reader.read("!H")[0]
Rich Lane9ec3fca2014-02-26 16:22:56 -08003165 assert(_type == 65534)
Dan Talaycof6202252013-07-02 01:00:29 -07003166 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003167 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003168 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07003169 obj.experimenter = reader.read("!L")[0]
3170 obj.subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003171 obj.experimenter_data = str(reader.read_all())
3172 return obj
3173
3174 def __eq__(self, other):
3175 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003176 if self.experimenter != other.experimenter: return False
3177 if self.subtype != other.subtype: return False
3178 if self.experimenter_data != other.experimenter_data: return False
3179 return True
3180
Rich Lanec2ee4b82013-04-24 17:12:38 -07003181 def pretty_print(self, q):
3182 q.text("table_feature_prop_experimenter {")
3183 with q.group():
3184 with q.indent(2):
3185 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003186 q.text("subtype = ");
3187 q.text("%#x" % self.subtype)
3188 q.text(","); q.breakable()
3189 q.text("experimenter_data = ");
3190 q.pp(self.experimenter_data)
3191 q.breakable()
3192 q.text('}')
3193
Rich Lane9ec3fca2014-02-26 16:22:56 -08003194table_feature_prop.subtypes[65534] = table_feature_prop_experimenter
3195
3196class table_feature_prop_experimenter_miss(table_feature_prop):
Rich Lane2e079da2014-10-29 15:30:24 -07003197 subtypes = {}
3198
Rich Lane9ec3fca2014-02-26 16:22:56 -08003199 type = 65535
3200
3201 def __init__(self, experimenter=None, subtype=None, experimenter_data=None):
3202 if experimenter != None:
3203 self.experimenter = experimenter
3204 else:
3205 self.experimenter = 0
3206 if subtype != None:
3207 self.subtype = subtype
3208 else:
3209 self.subtype = 0
3210 if experimenter_data != None:
3211 self.experimenter_data = experimenter_data
3212 else:
3213 self.experimenter_data = ''
3214 return
3215
3216 def pack(self):
3217 packed = []
3218 packed.append(struct.pack("!H", self.type))
3219 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
3220 packed.append(struct.pack("!L", self.experimenter))
3221 packed.append(struct.pack("!L", self.subtype))
3222 packed.append(self.experimenter_data)
3223 length = sum([len(x) for x in packed])
3224 packed[1] = struct.pack("!H", length)
3225 return ''.join(packed)
3226
3227 @staticmethod
3228 def unpack(reader):
Rich Lane2e079da2014-10-29 15:30:24 -07003229 subtype, = reader.peek('!L', 4)
3230 subclass = table_feature_prop_experimenter_miss.subtypes.get(subtype)
3231 if subclass:
3232 return subclass.unpack(reader)
3233
Rich Lane9ec3fca2014-02-26 16:22:56 -08003234 obj = table_feature_prop_experimenter_miss()
3235 _type = reader.read("!H")[0]
3236 assert(_type == 65535)
3237 _length = reader.read("!H")[0]
3238 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003239 reader = orig_reader.slice(_length, 4)
Rich Lane9ec3fca2014-02-26 16:22:56 -08003240 obj.experimenter = reader.read("!L")[0]
3241 obj.subtype = reader.read("!L")[0]
3242 obj.experimenter_data = str(reader.read_all())
3243 return obj
3244
3245 def __eq__(self, other):
3246 if type(self) != type(other): return False
3247 if self.experimenter != other.experimenter: return False
3248 if self.subtype != other.subtype: return False
3249 if self.experimenter_data != other.experimenter_data: return False
3250 return True
3251
3252 def pretty_print(self, q):
3253 q.text("table_feature_prop_experimenter_miss {")
3254 with q.group():
3255 with q.indent(2):
3256 q.breakable()
Rich Lane9ec3fca2014-02-26 16:22:56 -08003257 q.text("subtype = ");
3258 q.text("%#x" % self.subtype)
3259 q.text(","); q.breakable()
3260 q.text("experimenter_data = ");
3261 q.pp(self.experimenter_data)
3262 q.breakable()
3263 q.text('}')
3264
3265table_feature_prop.subtypes[65535] = table_feature_prop_experimenter_miss
Rich Lane7dcdf022013-12-11 14:45:27 -08003266
3267class table_feature_prop_instructions(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003268 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07003269
Dan Talaycof6202252013-07-02 01:00:29 -07003270 def __init__(self, instruction_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003271 if instruction_ids != None:
3272 self.instruction_ids = instruction_ids
3273 else:
3274 self.instruction_ids = []
3275 return
3276
3277 def pack(self):
3278 packed = []
3279 packed.append(struct.pack("!H", self.type))
3280 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003281 packed.append(loxi.generic_util.pack_list(self.instruction_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003282 length = sum([len(x) for x in packed])
3283 packed[1] = struct.pack("!H", length)
3284 return ''.join(packed)
3285
3286 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003287 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003288 obj = table_feature_prop_instructions()
Dan Talaycof6202252013-07-02 01:00:29 -07003289 _type = reader.read("!H")[0]
3290 assert(_type == 0)
3291 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003292 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003293 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08003294 obj.instruction_ids = loxi.generic_util.unpack_list(reader, ofp.instruction_id.instruction_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003295 return obj
3296
3297 def __eq__(self, other):
3298 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003299 if self.instruction_ids != other.instruction_ids: return False
3300 return True
3301
Rich Lanec2ee4b82013-04-24 17:12:38 -07003302 def pretty_print(self, q):
3303 q.text("table_feature_prop_instructions {")
3304 with q.group():
3305 with q.indent(2):
3306 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003307 q.text("instruction_ids = ");
3308 q.pp(self.instruction_ids)
3309 q.breakable()
3310 q.text('}')
3311
Rich Lane7dcdf022013-12-11 14:45:27 -08003312table_feature_prop.subtypes[0] = table_feature_prop_instructions
3313
3314class table_feature_prop_instructions_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003315 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07003316
Dan Talaycof6202252013-07-02 01:00:29 -07003317 def __init__(self, instruction_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003318 if instruction_ids != None:
3319 self.instruction_ids = instruction_ids
3320 else:
3321 self.instruction_ids = []
3322 return
3323
3324 def pack(self):
3325 packed = []
3326 packed.append(struct.pack("!H", self.type))
3327 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003328 packed.append(loxi.generic_util.pack_list(self.instruction_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003329 length = sum([len(x) for x in packed])
3330 packed[1] = struct.pack("!H", length)
3331 return ''.join(packed)
3332
3333 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003334 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003335 obj = table_feature_prop_instructions_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07003336 _type = reader.read("!H")[0]
3337 assert(_type == 1)
3338 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003339 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003340 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08003341 obj.instruction_ids = loxi.generic_util.unpack_list(reader, ofp.instruction_id.instruction_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003342 return obj
3343
3344 def __eq__(self, other):
3345 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003346 if self.instruction_ids != other.instruction_ids: return False
3347 return True
3348
Rich Lanec2ee4b82013-04-24 17:12:38 -07003349 def pretty_print(self, q):
3350 q.text("table_feature_prop_instructions_miss {")
3351 with q.group():
3352 with q.indent(2):
3353 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003354 q.text("instruction_ids = ");
3355 q.pp(self.instruction_ids)
3356 q.breakable()
3357 q.text('}')
3358
Rich Lane7dcdf022013-12-11 14:45:27 -08003359table_feature_prop.subtypes[1] = table_feature_prop_instructions_miss
3360
3361class table_feature_prop_match(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003362 type = 8
Rich Lanec2ee4b82013-04-24 17:12:38 -07003363
Dan Talaycof6202252013-07-02 01:00:29 -07003364 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003365 if oxm_ids != None:
3366 self.oxm_ids = oxm_ids
3367 else:
3368 self.oxm_ids = []
3369 return
3370
3371 def pack(self):
3372 packed = []
3373 packed.append(struct.pack("!H", self.type))
3374 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003375 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003376 length = sum([len(x) for x in packed])
3377 packed[1] = struct.pack("!H", length)
3378 return ''.join(packed)
3379
3380 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003381 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003382 obj = table_feature_prop_match()
Dan Talaycof6202252013-07-02 01:00:29 -07003383 _type = reader.read("!H")[0]
3384 assert(_type == 8)
3385 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003386 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003387 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08003388 obj.oxm_ids = loxi.generic_util.unpack_list(reader, ofp.common.uint32.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003389 return obj
3390
3391 def __eq__(self, other):
3392 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003393 if self.oxm_ids != other.oxm_ids: return False
3394 return True
3395
Rich Lanec2ee4b82013-04-24 17:12:38 -07003396 def pretty_print(self, q):
3397 q.text("table_feature_prop_match {")
3398 with q.group():
3399 with q.indent(2):
3400 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003401 q.text("oxm_ids = ");
3402 q.pp(self.oxm_ids)
3403 q.breakable()
3404 q.text('}')
3405
Rich Lane7dcdf022013-12-11 14:45:27 -08003406table_feature_prop.subtypes[8] = table_feature_prop_match
3407
3408class table_feature_prop_next_tables(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003409 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07003410
Dan Talaycof6202252013-07-02 01:00:29 -07003411 def __init__(self, next_table_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003412 if next_table_ids != None:
3413 self.next_table_ids = next_table_ids
3414 else:
3415 self.next_table_ids = []
3416 return
3417
3418 def pack(self):
3419 packed = []
3420 packed.append(struct.pack("!H", self.type))
3421 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003422 packed.append(loxi.generic_util.pack_list(self.next_table_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003423 length = sum([len(x) for x in packed])
3424 packed[1] = struct.pack("!H", length)
3425 return ''.join(packed)
3426
3427 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003428 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003429 obj = table_feature_prop_next_tables()
Dan Talaycof6202252013-07-02 01:00:29 -07003430 _type = reader.read("!H")[0]
3431 assert(_type == 2)
3432 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003433 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003434 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08003435 obj.next_table_ids = loxi.generic_util.unpack_list(reader, ofp.common.uint8.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003436 return obj
3437
3438 def __eq__(self, other):
3439 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003440 if self.next_table_ids != other.next_table_ids: return False
3441 return True
3442
Rich Lanec2ee4b82013-04-24 17:12:38 -07003443 def pretty_print(self, q):
3444 q.text("table_feature_prop_next_tables {")
3445 with q.group():
3446 with q.indent(2):
3447 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003448 q.text("next_table_ids = ");
3449 q.pp(self.next_table_ids)
3450 q.breakable()
3451 q.text('}')
3452
Rich Lane7dcdf022013-12-11 14:45:27 -08003453table_feature_prop.subtypes[2] = table_feature_prop_next_tables
3454
3455class table_feature_prop_next_tables_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003456 type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07003457
Dan Talaycof6202252013-07-02 01:00:29 -07003458 def __init__(self, next_table_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003459 if next_table_ids != None:
3460 self.next_table_ids = next_table_ids
3461 else:
3462 self.next_table_ids = []
3463 return
3464
3465 def pack(self):
3466 packed = []
3467 packed.append(struct.pack("!H", self.type))
3468 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003469 packed.append(loxi.generic_util.pack_list(self.next_table_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003470 length = sum([len(x) for x in packed])
3471 packed[1] = struct.pack("!H", length)
3472 return ''.join(packed)
3473
3474 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003475 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003476 obj = table_feature_prop_next_tables_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07003477 _type = reader.read("!H")[0]
3478 assert(_type == 3)
3479 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003480 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003481 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08003482 obj.next_table_ids = loxi.generic_util.unpack_list(reader, ofp.common.uint8.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003483 return obj
3484
3485 def __eq__(self, other):
3486 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003487 if self.next_table_ids != other.next_table_ids: return False
3488 return True
3489
Rich Lanec2ee4b82013-04-24 17:12:38 -07003490 def pretty_print(self, q):
3491 q.text("table_feature_prop_next_tables_miss {")
3492 with q.group():
3493 with q.indent(2):
3494 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003495 q.text("next_table_ids = ");
3496 q.pp(self.next_table_ids)
3497 q.breakable()
3498 q.text('}')
3499
Rich Lane7dcdf022013-12-11 14:45:27 -08003500table_feature_prop.subtypes[3] = table_feature_prop_next_tables_miss
3501
3502class table_feature_prop_wildcards(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003503 type = 10
Rich Lanec2ee4b82013-04-24 17:12:38 -07003504
Dan Talaycof6202252013-07-02 01:00:29 -07003505 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003506 if oxm_ids != None:
3507 self.oxm_ids = oxm_ids
3508 else:
3509 self.oxm_ids = []
3510 return
3511
3512 def pack(self):
3513 packed = []
3514 packed.append(struct.pack("!H", self.type))
3515 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003516 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003517 length = sum([len(x) for x in packed])
3518 packed[1] = struct.pack("!H", length)
3519 return ''.join(packed)
3520
3521 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003522 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003523 obj = table_feature_prop_wildcards()
Dan Talaycof6202252013-07-02 01:00:29 -07003524 _type = reader.read("!H")[0]
3525 assert(_type == 10)
3526 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003527 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003528 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08003529 obj.oxm_ids = loxi.generic_util.unpack_list(reader, ofp.common.uint32.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003530 return obj
3531
3532 def __eq__(self, other):
3533 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003534 if self.oxm_ids != other.oxm_ids: return False
3535 return True
3536
Rich Lanec2ee4b82013-04-24 17:12:38 -07003537 def pretty_print(self, q):
3538 q.text("table_feature_prop_wildcards {")
3539 with q.group():
3540 with q.indent(2):
3541 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003542 q.text("oxm_ids = ");
3543 q.pp(self.oxm_ids)
3544 q.breakable()
3545 q.text('}')
3546
Rich Lane7dcdf022013-12-11 14:45:27 -08003547table_feature_prop.subtypes[10] = table_feature_prop_wildcards
3548
3549class table_feature_prop_write_actions(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003550 type = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07003551
Dan Talaycof6202252013-07-02 01:00:29 -07003552 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003553 if action_ids != None:
3554 self.action_ids = action_ids
3555 else:
3556 self.action_ids = []
3557 return
3558
3559 def pack(self):
3560 packed = []
3561 packed.append(struct.pack("!H", self.type))
3562 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003563 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003564 length = sum([len(x) for x in packed])
3565 packed[1] = struct.pack("!H", length)
3566 return ''.join(packed)
3567
3568 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003569 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003570 obj = table_feature_prop_write_actions()
Dan Talaycof6202252013-07-02 01:00:29 -07003571 _type = reader.read("!H")[0]
3572 assert(_type == 4)
3573 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003574 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003575 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08003576 obj.action_ids = loxi.generic_util.unpack_list(reader, ofp.action_id.action_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003577 return obj
3578
3579 def __eq__(self, other):
3580 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003581 if self.action_ids != other.action_ids: return False
3582 return True
3583
Rich Lanec2ee4b82013-04-24 17:12:38 -07003584 def pretty_print(self, q):
3585 q.text("table_feature_prop_write_actions {")
3586 with q.group():
3587 with q.indent(2):
3588 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003589 q.text("action_ids = ");
3590 q.pp(self.action_ids)
3591 q.breakable()
3592 q.text('}')
3593
Rich Lane7dcdf022013-12-11 14:45:27 -08003594table_feature_prop.subtypes[4] = table_feature_prop_write_actions
3595
3596class table_feature_prop_write_actions_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003597 type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07003598
Dan Talaycof6202252013-07-02 01:00:29 -07003599 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003600 if action_ids != None:
3601 self.action_ids = action_ids
3602 else:
3603 self.action_ids = []
3604 return
3605
3606 def pack(self):
3607 packed = []
3608 packed.append(struct.pack("!H", self.type))
3609 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003610 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003611 length = sum([len(x) for x in packed])
3612 packed[1] = struct.pack("!H", length)
3613 return ''.join(packed)
3614
3615 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003616 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003617 obj = table_feature_prop_write_actions_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07003618 _type = reader.read("!H")[0]
3619 assert(_type == 5)
3620 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003621 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003622 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08003623 obj.action_ids = loxi.generic_util.unpack_list(reader, ofp.action_id.action_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003624 return obj
3625
3626 def __eq__(self, other):
3627 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003628 if self.action_ids != other.action_ids: return False
3629 return True
3630
Rich Lanec2ee4b82013-04-24 17:12:38 -07003631 def pretty_print(self, q):
3632 q.text("table_feature_prop_write_actions_miss {")
3633 with q.group():
3634 with q.indent(2):
3635 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003636 q.text("action_ids = ");
3637 q.pp(self.action_ids)
3638 q.breakable()
3639 q.text('}')
3640
Rich Lane7dcdf022013-12-11 14:45:27 -08003641table_feature_prop.subtypes[5] = table_feature_prop_write_actions_miss
3642
3643class table_feature_prop_write_setfield(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003644 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -07003645
Dan Talaycof6202252013-07-02 01:00:29 -07003646 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003647 if oxm_ids != None:
3648 self.oxm_ids = oxm_ids
3649 else:
3650 self.oxm_ids = []
3651 return
3652
3653 def pack(self):
3654 packed = []
3655 packed.append(struct.pack("!H", self.type))
3656 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003657 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003658 length = sum([len(x) for x in packed])
3659 packed[1] = struct.pack("!H", length)
3660 return ''.join(packed)
3661
3662 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003663 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003664 obj = table_feature_prop_write_setfield()
Dan Talaycof6202252013-07-02 01:00:29 -07003665 _type = reader.read("!H")[0]
3666 assert(_type == 12)
3667 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003668 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003669 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08003670 obj.oxm_ids = loxi.generic_util.unpack_list(reader, ofp.common.uint32.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003671 return obj
3672
3673 def __eq__(self, other):
3674 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003675 if self.oxm_ids != other.oxm_ids: return False
3676 return True
3677
Rich Lanec2ee4b82013-04-24 17:12:38 -07003678 def pretty_print(self, q):
3679 q.text("table_feature_prop_write_setfield {")
3680 with q.group():
3681 with q.indent(2):
3682 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003683 q.text("oxm_ids = ");
3684 q.pp(self.oxm_ids)
3685 q.breakable()
3686 q.text('}')
3687
Rich Lane7dcdf022013-12-11 14:45:27 -08003688table_feature_prop.subtypes[12] = table_feature_prop_write_setfield
3689
3690class table_feature_prop_write_setfield_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003691 type = 13
Rich Lanec2ee4b82013-04-24 17:12:38 -07003692
Dan Talaycof6202252013-07-02 01:00:29 -07003693 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003694 if oxm_ids != None:
3695 self.oxm_ids = oxm_ids
3696 else:
3697 self.oxm_ids = []
3698 return
3699
3700 def pack(self):
3701 packed = []
3702 packed.append(struct.pack("!H", self.type))
3703 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003704 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003705 length = sum([len(x) for x in packed])
3706 packed[1] = struct.pack("!H", length)
3707 return ''.join(packed)
3708
3709 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003710 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003711 obj = table_feature_prop_write_setfield_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07003712 _type = reader.read("!H")[0]
3713 assert(_type == 13)
3714 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003715 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003716 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08003717 obj.oxm_ids = loxi.generic_util.unpack_list(reader, ofp.common.uint32.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003718 return obj
3719
3720 def __eq__(self, other):
3721 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003722 if self.oxm_ids != other.oxm_ids: return False
3723 return True
3724
Rich Lanec2ee4b82013-04-24 17:12:38 -07003725 def pretty_print(self, q):
3726 q.text("table_feature_prop_write_setfield_miss {")
3727 with q.group():
3728 with q.indent(2):
3729 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003730 q.text("oxm_ids = ");
3731 q.pp(self.oxm_ids)
3732 q.breakable()
3733 q.text('}')
3734
Rich Lane7dcdf022013-12-11 14:45:27 -08003735table_feature_prop.subtypes[13] = table_feature_prop_write_setfield_miss
3736
3737class table_features(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003738
3739 def __init__(self, table_id=None, name=None, metadata_match=None, metadata_write=None, config=None, max_entries=None, properties=None):
3740 if table_id != None:
3741 self.table_id = table_id
3742 else:
3743 self.table_id = 0
3744 if name != None:
3745 self.name = name
3746 else:
3747 self.name = ""
3748 if metadata_match != None:
3749 self.metadata_match = metadata_match
3750 else:
3751 self.metadata_match = 0
3752 if metadata_write != None:
3753 self.metadata_write = metadata_write
3754 else:
3755 self.metadata_write = 0
3756 if config != None:
3757 self.config = config
3758 else:
3759 self.config = 0
3760 if max_entries != None:
3761 self.max_entries = max_entries
3762 else:
3763 self.max_entries = 0
3764 if properties != None:
3765 self.properties = properties
3766 else:
3767 self.properties = []
3768 return
3769
3770 def pack(self):
3771 packed = []
3772 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
3773 packed.append(struct.pack("!B", self.table_id))
3774 packed.append('\x00' * 5)
3775 packed.append(struct.pack("!32s", self.name))
3776 packed.append(struct.pack("!Q", self.metadata_match))
3777 packed.append(struct.pack("!Q", self.metadata_write))
3778 packed.append(struct.pack("!L", self.config))
3779 packed.append(struct.pack("!L", self.max_entries))
Rich Lane7dcdf022013-12-11 14:45:27 -08003780 packed.append(loxi.generic_util.pack_list(self.properties))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003781 length = sum([len(x) for x in packed])
3782 packed[0] = struct.pack("!H", length)
3783 return ''.join(packed)
3784
3785 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003786 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003787 obj = table_features()
Dan Talaycof6202252013-07-02 01:00:29 -07003788 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003789 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003790 reader = orig_reader.slice(_length, 2)
Dan Talaycof6202252013-07-02 01:00:29 -07003791 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003792 reader.skip(5)
3793 obj.name = reader.read("!32s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -07003794 obj.metadata_match = reader.read("!Q")[0]
3795 obj.metadata_write = reader.read("!Q")[0]
3796 obj.config = reader.read("!L")[0]
3797 obj.max_entries = reader.read("!L")[0]
Rich Lanee2567702015-01-26 15:04:35 -08003798 obj.properties = loxi.generic_util.unpack_list(reader, ofp.common.table_feature_prop.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003799 return obj
3800
3801 def __eq__(self, other):
3802 if type(self) != type(other): return False
3803 if self.table_id != other.table_id: return False
3804 if self.name != other.name: return False
3805 if self.metadata_match != other.metadata_match: return False
3806 if self.metadata_write != other.metadata_write: return False
3807 if self.config != other.config: return False
3808 if self.max_entries != other.max_entries: return False
3809 if self.properties != other.properties: return False
3810 return True
3811
Rich Lanec2ee4b82013-04-24 17:12:38 -07003812 def pretty_print(self, q):
3813 q.text("table_features {")
3814 with q.group():
3815 with q.indent(2):
3816 q.breakable()
3817 q.text("table_id = ");
3818 q.text("%#x" % self.table_id)
3819 q.text(","); q.breakable()
3820 q.text("name = ");
3821 q.pp(self.name)
3822 q.text(","); q.breakable()
3823 q.text("metadata_match = ");
3824 q.text("%#x" % self.metadata_match)
3825 q.text(","); q.breakable()
3826 q.text("metadata_write = ");
3827 q.text("%#x" % self.metadata_write)
3828 q.text(","); q.breakable()
3829 q.text("config = ");
3830 q.text("%#x" % self.config)
3831 q.text(","); q.breakable()
3832 q.text("max_entries = ");
3833 q.text("%#x" % self.max_entries)
3834 q.text(","); q.breakable()
3835 q.text("properties = ");
3836 q.pp(self.properties)
3837 q.breakable()
3838 q.text('}')
3839
Rich Lane7dcdf022013-12-11 14:45:27 -08003840
3841class table_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003842
3843 def __init__(self, table_id=None, active_count=None, lookup_count=None, matched_count=None):
3844 if table_id != None:
3845 self.table_id = table_id
3846 else:
3847 self.table_id = 0
3848 if active_count != None:
3849 self.active_count = active_count
3850 else:
3851 self.active_count = 0
3852 if lookup_count != None:
3853 self.lookup_count = lookup_count
3854 else:
3855 self.lookup_count = 0
3856 if matched_count != None:
3857 self.matched_count = matched_count
3858 else:
3859 self.matched_count = 0
3860 return
3861
3862 def pack(self):
3863 packed = []
3864 packed.append(struct.pack("!B", self.table_id))
3865 packed.append('\x00' * 3)
3866 packed.append(struct.pack("!L", self.active_count))
3867 packed.append(struct.pack("!Q", self.lookup_count))
3868 packed.append(struct.pack("!Q", self.matched_count))
3869 return ''.join(packed)
3870
3871 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003872 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003873 obj = table_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07003874 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003875 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07003876 obj.active_count = reader.read("!L")[0]
3877 obj.lookup_count = reader.read("!Q")[0]
3878 obj.matched_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003879 return obj
3880
3881 def __eq__(self, other):
3882 if type(self) != type(other): return False
3883 if self.table_id != other.table_id: return False
3884 if self.active_count != other.active_count: return False
3885 if self.lookup_count != other.lookup_count: return False
3886 if self.matched_count != other.matched_count: return False
3887 return True
3888
Rich Lanec2ee4b82013-04-24 17:12:38 -07003889 def pretty_print(self, q):
3890 q.text("table_stats_entry {")
3891 with q.group():
3892 with q.indent(2):
3893 q.breakable()
3894 q.text("table_id = ");
3895 q.text("%#x" % self.table_id)
3896 q.text(","); q.breakable()
3897 q.text("active_count = ");
3898 q.text("%#x" % self.active_count)
3899 q.text(","); q.breakable()
3900 q.text("lookup_count = ");
3901 q.text("%#x" % self.lookup_count)
3902 q.text(","); q.breakable()
3903 q.text("matched_count = ");
3904 q.text("%#x" % self.matched_count)
3905 q.breakable()
3906 q.text('}')
3907
Rich Lane7dcdf022013-12-11 14:45:27 -08003908
3909class uint32(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003910
3911 def __init__(self, value=None):
3912 if value != None:
3913 self.value = value
3914 else:
3915 self.value = 0
3916 return
3917
3918 def pack(self):
3919 packed = []
3920 packed.append(struct.pack("!L", self.value))
3921 return ''.join(packed)
3922
3923 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003924 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003925 obj = uint32()
Dan Talaycof6202252013-07-02 01:00:29 -07003926 obj.value = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003927 return obj
3928
3929 def __eq__(self, other):
3930 if type(self) != type(other): return False
3931 if self.value != other.value: return False
3932 return True
3933
Rich Lanec2ee4b82013-04-24 17:12:38 -07003934 def pretty_print(self, q):
3935 q.text("uint32 {")
3936 with q.group():
3937 with q.indent(2):
3938 q.breakable()
3939 q.text("value = ");
3940 q.text("%#x" % self.value)
3941 q.breakable()
3942 q.text('}')
3943
Rich Lane7dcdf022013-12-11 14:45:27 -08003944
3945class uint64(loxi.OFObject):
3946
3947 def __init__(self, value=None):
3948 if value != None:
3949 self.value = value
3950 else:
3951 self.value = 0
3952 return
3953
3954 def pack(self):
3955 packed = []
3956 packed.append(struct.pack("!Q", self.value))
3957 return ''.join(packed)
3958
3959 @staticmethod
3960 def unpack(reader):
3961 obj = uint64()
3962 obj.value = reader.read("!Q")[0]
3963 return obj
3964
3965 def __eq__(self, other):
3966 if type(self) != type(other): return False
3967 if self.value != other.value: return False
3968 return True
3969
3970 def pretty_print(self, q):
3971 q.text("uint64 {")
3972 with q.group():
3973 with q.indent(2):
3974 q.breakable()
3975 q.text("value = ");
3976 q.text("%#x" % self.value)
3977 q.breakable()
3978 q.text('}')
3979
3980
3981class uint8(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003982
3983 def __init__(self, value=None):
3984 if value != None:
3985 self.value = value
3986 else:
3987 self.value = 0
3988 return
3989
3990 def pack(self):
3991 packed = []
3992 packed.append(struct.pack("!B", self.value))
3993 return ''.join(packed)
3994
3995 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003996 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003997 obj = uint8()
Dan Talaycof6202252013-07-02 01:00:29 -07003998 obj.value = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003999 return obj
4000
4001 def __eq__(self, other):
4002 if type(self) != type(other): return False
4003 if self.value != other.value: return False
4004 return True
4005
Rich Lanec2ee4b82013-04-24 17:12:38 -07004006 def pretty_print(self, q):
4007 q.text("uint8 {")
4008 with q.group():
4009 with q.indent(2):
4010 q.breakable()
4011 q.text("value = ");
4012 q.text("%#x" % self.value)
4013 q.breakable()
4014 q.text('}')
4015
4016
Rich Lane7dcdf022013-12-11 14:45:27 -08004017
Rich Lanec2ee4b82013-04-24 17:12:38 -07004018match = match_v3