blob: 3e30b70dae3b20d18afa8751362059fe314e52b1 [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 const
Harshmeet Singh1db46332014-10-14 16:29:13 -070012import bsn_tlv
13import meter_band
Rich Lane7dcdf022013-12-11 14:45:27 -080014import instruction
15import oxm
Harshmeet Singh1db46332014-10-14 16:29:13 -070016import common
Rich Lane7dcdf022013-12-11 14:45:27 -080017import instruction_id
Harshmeet Singh1db46332014-10-14 16:29:13 -070018import action
19import message
20import action_id
Rich Lanec2ee4b82013-04-24 17:12:38 -070021import util
22import loxi.generic_util
23
Rich Lane5454b682014-01-14 17:07:36 -080024class bsn_controller_connection(loxi.OFObject):
25
26 def __init__(self, state=None, auxiliary_id=None, role=None, uri=None):
27 if state != None:
28 self.state = state
29 else:
30 self.state = 0
31 if auxiliary_id != None:
32 self.auxiliary_id = auxiliary_id
33 else:
34 self.auxiliary_id = 0
35 if role != None:
36 self.role = role
37 else:
38 self.role = 0
39 if uri != None:
40 self.uri = uri
41 else:
42 self.uri = ""
43 return
44
45 def pack(self):
46 packed = []
47 packed.append(struct.pack("!B", self.state))
48 packed.append(struct.pack("!B", self.auxiliary_id))
49 packed.append('\x00' * 2)
50 packed.append(struct.pack("!L", self.role))
51 packed.append(struct.pack("!256s", self.uri))
52 return ''.join(packed)
53
54 @staticmethod
55 def unpack(reader):
56 obj = bsn_controller_connection()
57 obj.state = reader.read("!B")[0]
58 obj.auxiliary_id = reader.read("!B")[0]
59 reader.skip(2)
60 obj.role = reader.read("!L")[0]
61 obj.uri = reader.read("!256s")[0].rstrip("\x00")
62 return obj
63
64 def __eq__(self, other):
65 if type(self) != type(other): return False
66 if self.state != other.state: return False
67 if self.auxiliary_id != other.auxiliary_id: return False
68 if self.role != other.role: return False
69 if self.uri != other.uri: return False
70 return True
71
72 def pretty_print(self, q):
73 q.text("bsn_controller_connection {")
74 with q.group():
75 with q.indent(2):
76 q.breakable()
77 q.text("state = ");
78 q.text("%#x" % self.state)
79 q.text(","); q.breakable()
80 q.text("auxiliary_id = ");
81 q.text("%#x" % self.auxiliary_id)
82 q.text(","); q.breakable()
83 q.text("role = ");
84 q.text("%#x" % self.role)
85 q.text(","); q.breakable()
86 q.text("uri = ");
87 q.pp(self.uri)
88 q.breakable()
89 q.text('}')
90
91
Rich Lane93b33132014-04-21 12:20:58 -070092class bsn_debug_counter_desc_stats_entry(loxi.OFObject):
93
94 def __init__(self, counter_id=None, name=None, description=None):
95 if counter_id != None:
96 self.counter_id = counter_id
97 else:
98 self.counter_id = 0
99 if name != None:
100 self.name = name
101 else:
102 self.name = ""
103 if description != None:
104 self.description = description
105 else:
106 self.description = ""
107 return
108
109 def pack(self):
110 packed = []
111 packed.append(struct.pack("!Q", self.counter_id))
112 packed.append(struct.pack("!64s", self.name))
113 packed.append(struct.pack("!256s", self.description))
114 return ''.join(packed)
115
116 @staticmethod
117 def unpack(reader):
118 obj = bsn_debug_counter_desc_stats_entry()
119 obj.counter_id = reader.read("!Q")[0]
120 obj.name = reader.read("!64s")[0].rstrip("\x00")
121 obj.description = reader.read("!256s")[0].rstrip("\x00")
122 return obj
123
124 def __eq__(self, other):
125 if type(self) != type(other): return False
126 if self.counter_id != other.counter_id: return False
127 if self.name != other.name: return False
128 if self.description != other.description: return False
129 return True
130
131 def pretty_print(self, q):
132 q.text("bsn_debug_counter_desc_stats_entry {")
133 with q.group():
134 with q.indent(2):
135 q.breakable()
136 q.text("counter_id = ");
137 q.text("%#x" % self.counter_id)
138 q.text(","); q.breakable()
139 q.text("name = ");
140 q.pp(self.name)
141 q.text(","); q.breakable()
142 q.text("description = ");
143 q.pp(self.description)
144 q.breakable()
145 q.text('}')
146
147
148class bsn_debug_counter_stats_entry(loxi.OFObject):
149
150 def __init__(self, counter_id=None, value=None):
151 if counter_id != None:
152 self.counter_id = counter_id
153 else:
154 self.counter_id = 0
155 if value != None:
156 self.value = value
157 else:
158 self.value = 0
159 return
160
161 def pack(self):
162 packed = []
163 packed.append(struct.pack("!Q", self.counter_id))
164 packed.append(struct.pack("!Q", self.value))
165 return ''.join(packed)
166
167 @staticmethod
168 def unpack(reader):
169 obj = bsn_debug_counter_stats_entry()
170 obj.counter_id = reader.read("!Q")[0]
171 obj.value = reader.read("!Q")[0]
172 return obj
173
174 def __eq__(self, other):
175 if type(self) != type(other): return False
176 if self.counter_id != other.counter_id: return False
177 if self.value != other.value: return False
178 return True
179
180 def pretty_print(self, q):
181 q.text("bsn_debug_counter_stats_entry {")
182 with q.group():
183 with q.indent(2):
184 q.breakable()
185 q.text("counter_id = ");
186 q.text("%#x" % self.counter_id)
187 q.text(","); q.breakable()
188 q.text("value = ");
189 q.text("%#x" % self.value)
190 q.breakable()
191 q.text('}')
192
193
Rich Lane9ec3fca2014-02-26 16:22:56 -0800194class bsn_flow_checksum_bucket_stats_entry(loxi.OFObject):
195
196 def __init__(self, checksum=None):
197 if checksum != None:
198 self.checksum = checksum
199 else:
200 self.checksum = 0
201 return
202
203 def pack(self):
204 packed = []
205 packed.append(struct.pack("!Q", self.checksum))
206 return ''.join(packed)
207
208 @staticmethod
209 def unpack(reader):
210 obj = bsn_flow_checksum_bucket_stats_entry()
211 obj.checksum = reader.read("!Q")[0]
212 return obj
213
214 def __eq__(self, other):
215 if type(self) != type(other): return False
216 if self.checksum != other.checksum: return False
217 return True
218
219 def pretty_print(self, q):
220 q.text("bsn_flow_checksum_bucket_stats_entry {")
221 with q.group():
222 with q.indent(2):
223 q.breakable()
224 q.text("checksum = ");
225 q.text("%#x" % self.checksum)
226 q.breakable()
227 q.text('}')
228
229
Rich Lane5454b682014-01-14 17:07:36 -0800230class bsn_gentable_bucket_stats_entry(loxi.OFObject):
231
232 def __init__(self, checksum=None):
233 if checksum != None:
234 self.checksum = checksum
235 else:
236 self.checksum = 0
237 return
238
239 def pack(self):
240 packed = []
241 packed.append(util.pack_checksum_128(self.checksum))
242 return ''.join(packed)
243
244 @staticmethod
245 def unpack(reader):
246 obj = bsn_gentable_bucket_stats_entry()
247 obj.checksum = util.unpack_checksum_128(reader)
248 return obj
249
250 def __eq__(self, other):
251 if type(self) != type(other): return False
252 if self.checksum != other.checksum: return False
253 return True
254
255 def pretty_print(self, q):
256 q.text("bsn_gentable_bucket_stats_entry {")
257 with q.group():
258 with q.indent(2):
259 q.breakable()
260 q.text("checksum = ");
261 q.pp(self.checksum)
262 q.breakable()
263 q.text('}')
264
265
266class bsn_gentable_desc_stats_entry(loxi.OFObject):
267
268 def __init__(self, table_id=None, name=None, buckets_size=None, max_entries=None):
269 if table_id != None:
270 self.table_id = table_id
271 else:
272 self.table_id = 0
273 if name != None:
274 self.name = name
275 else:
276 self.name = ""
277 if buckets_size != None:
278 self.buckets_size = buckets_size
279 else:
280 self.buckets_size = 0
281 if max_entries != None:
282 self.max_entries = max_entries
283 else:
284 self.max_entries = 0
285 return
286
287 def pack(self):
288 packed = []
289 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
290 packed.append(struct.pack("!H", self.table_id))
291 packed.append(struct.pack("!32s", self.name))
292 packed.append(struct.pack("!L", self.buckets_size))
293 packed.append(struct.pack("!L", self.max_entries))
294 packed.append('\x00' * 4)
295 length = sum([len(x) for x in packed])
296 packed[0] = struct.pack("!H", length)
297 return ''.join(packed)
298
299 @staticmethod
300 def unpack(reader):
301 obj = bsn_gentable_desc_stats_entry()
302 _length = reader.read("!H")[0]
303 orig_reader = reader
304 reader = orig_reader.slice(_length - (0 + 2))
305 obj.table_id = reader.read("!H")[0]
306 obj.name = reader.read("!32s")[0].rstrip("\x00")
307 obj.buckets_size = reader.read("!L")[0]
308 obj.max_entries = reader.read("!L")[0]
309 reader.skip(4)
310 return obj
311
312 def __eq__(self, other):
313 if type(self) != type(other): return False
314 if self.table_id != other.table_id: return False
315 if self.name != other.name: return False
316 if self.buckets_size != other.buckets_size: return False
317 if self.max_entries != other.max_entries: return False
318 return True
319
320 def pretty_print(self, q):
321 q.text("bsn_gentable_desc_stats_entry {")
322 with q.group():
323 with q.indent(2):
324 q.breakable()
325 q.text("table_id = ");
326 q.text("%#x" % self.table_id)
327 q.text(","); q.breakable()
328 q.text("name = ");
329 q.pp(self.name)
330 q.text(","); q.breakable()
331 q.text("buckets_size = ");
332 q.text("%#x" % self.buckets_size)
333 q.text(","); q.breakable()
334 q.text("max_entries = ");
335 q.text("%#x" % self.max_entries)
336 q.breakable()
337 q.text('}')
338
339
340class bsn_gentable_entry_desc_stats_entry(loxi.OFObject):
341
342 def __init__(self, checksum=None, key=None, value=None):
343 if checksum != None:
344 self.checksum = checksum
345 else:
346 self.checksum = 0
347 if key != None:
348 self.key = key
349 else:
350 self.key = []
351 if value != None:
352 self.value = value
353 else:
354 self.value = []
355 return
356
357 def pack(self):
358 packed = []
359 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
360 packed.append(struct.pack("!H", 0)) # placeholder for key_length at index 1
361 packed.append(util.pack_checksum_128(self.checksum))
362 packed.append(loxi.generic_util.pack_list(self.key))
363 packed[1] = struct.pack("!H", len(packed[-1]))
364 packed.append(loxi.generic_util.pack_list(self.value))
365 length = sum([len(x) for x in packed])
366 packed[0] = struct.pack("!H", length)
367 return ''.join(packed)
368
369 @staticmethod
370 def unpack(reader):
371 obj = bsn_gentable_entry_desc_stats_entry()
372 _length = reader.read("!H")[0]
373 orig_reader = reader
374 reader = orig_reader.slice(_length - (0 + 2))
375 _key_length = reader.read("!H")[0]
376 obj.checksum = util.unpack_checksum_128(reader)
377 obj.key = loxi.generic_util.unpack_list(reader.slice(_key_length), bsn_tlv.bsn_tlv.unpack)
378 obj.value = loxi.generic_util.unpack_list(reader, bsn_tlv.bsn_tlv.unpack)
379 return obj
380
381 def __eq__(self, other):
382 if type(self) != type(other): return False
383 if self.checksum != other.checksum: return False
384 if self.key != other.key: return False
385 if self.value != other.value: return False
386 return True
387
388 def pretty_print(self, q):
389 q.text("bsn_gentable_entry_desc_stats_entry {")
390 with q.group():
391 with q.indent(2):
392 q.breakable()
393 q.text("checksum = ");
394 q.pp(self.checksum)
395 q.text(","); q.breakable()
396 q.text("key = ");
397 q.pp(self.key)
398 q.text(","); q.breakable()
399 q.text("value = ");
400 q.pp(self.value)
401 q.breakable()
402 q.text('}')
403
404
405class bsn_gentable_entry_stats_entry(loxi.OFObject):
406
407 def __init__(self, key=None, stats=None):
408 if key != None:
409 self.key = key
410 else:
411 self.key = []
412 if stats != None:
413 self.stats = stats
414 else:
415 self.stats = []
416 return
417
418 def pack(self):
419 packed = []
420 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
421 packed.append(struct.pack("!H", 0)) # placeholder for key_length at index 1
422 packed.append(loxi.generic_util.pack_list(self.key))
423 packed[1] = struct.pack("!H", len(packed[-1]))
424 packed.append(loxi.generic_util.pack_list(self.stats))
425 length = sum([len(x) for x in packed])
426 packed[0] = struct.pack("!H", length)
427 return ''.join(packed)
428
429 @staticmethod
430 def unpack(reader):
431 obj = bsn_gentable_entry_stats_entry()
432 _length = reader.read("!H")[0]
433 orig_reader = reader
434 reader = orig_reader.slice(_length - (0 + 2))
435 _key_length = reader.read("!H")[0]
436 obj.key = loxi.generic_util.unpack_list(reader.slice(_key_length), bsn_tlv.bsn_tlv.unpack)
437 obj.stats = loxi.generic_util.unpack_list(reader, bsn_tlv.bsn_tlv.unpack)
438 return obj
439
440 def __eq__(self, other):
441 if type(self) != type(other): return False
442 if self.key != other.key: return False
443 if self.stats != other.stats: return False
444 return True
445
446 def pretty_print(self, q):
447 q.text("bsn_gentable_entry_stats_entry {")
448 with q.group():
449 with q.indent(2):
450 q.breakable()
451 q.text("key = ");
452 q.pp(self.key)
453 q.text(","); q.breakable()
454 q.text("stats = ");
455 q.pp(self.stats)
456 q.breakable()
457 q.text('}')
458
459
460class bsn_gentable_stats_entry(loxi.OFObject):
461
462 def __init__(self, table_id=None, entry_count=None, checksum=None):
463 if table_id != None:
464 self.table_id = table_id
465 else:
466 self.table_id = 0
467 if entry_count != None:
468 self.entry_count = entry_count
469 else:
470 self.entry_count = 0
471 if checksum != None:
472 self.checksum = checksum
473 else:
474 self.checksum = 0
475 return
476
477 def pack(self):
478 packed = []
479 packed.append(struct.pack("!H", self.table_id))
480 packed.append('\x00' * 2)
481 packed.append(struct.pack("!L", self.entry_count))
482 packed.append(util.pack_checksum_128(self.checksum))
483 return ''.join(packed)
484
485 @staticmethod
486 def unpack(reader):
487 obj = bsn_gentable_stats_entry()
488 obj.table_id = reader.read("!H")[0]
489 reader.skip(2)
490 obj.entry_count = reader.read("!L")[0]
491 obj.checksum = util.unpack_checksum_128(reader)
492 return obj
493
494 def __eq__(self, other):
495 if type(self) != type(other): return False
496 if self.table_id != other.table_id: return False
497 if self.entry_count != other.entry_count: return False
498 if self.checksum != other.checksum: return False
499 return True
500
501 def pretty_print(self, q):
502 q.text("bsn_gentable_stats_entry {")
503 with q.group():
504 with q.indent(2):
505 q.breakable()
506 q.text("table_id = ");
507 q.text("%#x" % self.table_id)
508 q.text(","); q.breakable()
509 q.text("entry_count = ");
510 q.text("%#x" % self.entry_count)
511 q.text(","); q.breakable()
512 q.text("checksum = ");
513 q.pp(self.checksum)
514 q.breakable()
515 q.text('}')
516
517
Rich Lane7dcdf022013-12-11 14:45:27 -0800518class bsn_interface(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700519
520 def __init__(self, hw_addr=None, name=None, ipv4_addr=None, ipv4_netmask=None):
521 if hw_addr != None:
522 self.hw_addr = hw_addr
523 else:
524 self.hw_addr = [0,0,0,0,0,0]
525 if name != None:
526 self.name = name
527 else:
528 self.name = ""
529 if ipv4_addr != None:
530 self.ipv4_addr = ipv4_addr
531 else:
532 self.ipv4_addr = 0
533 if ipv4_netmask != None:
534 self.ipv4_netmask = ipv4_netmask
535 else:
536 self.ipv4_netmask = 0
537 return
538
539 def pack(self):
540 packed = []
541 packed.append(struct.pack("!6B", *self.hw_addr))
542 packed.append('\x00' * 2)
543 packed.append(struct.pack("!16s", self.name))
544 packed.append(struct.pack("!L", self.ipv4_addr))
545 packed.append(struct.pack("!L", self.ipv4_netmask))
546 return ''.join(packed)
547
548 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800549 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700550 obj = bsn_interface()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700551 obj.hw_addr = list(reader.read('!6B'))
552 reader.skip(2)
553 obj.name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -0700554 obj.ipv4_addr = reader.read("!L")[0]
555 obj.ipv4_netmask = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700556 return obj
557
558 def __eq__(self, other):
559 if type(self) != type(other): return False
560 if self.hw_addr != other.hw_addr: return False
561 if self.name != other.name: return False
562 if self.ipv4_addr != other.ipv4_addr: return False
563 if self.ipv4_netmask != other.ipv4_netmask: return False
564 return True
565
Rich Lanec2ee4b82013-04-24 17:12:38 -0700566 def pretty_print(self, q):
567 q.text("bsn_interface {")
568 with q.group():
569 with q.indent(2):
570 q.breakable()
571 q.text("hw_addr = ");
572 q.text(util.pretty_mac(self.hw_addr))
573 q.text(","); q.breakable()
574 q.text("name = ");
575 q.pp(self.name)
576 q.text(","); q.breakable()
577 q.text("ipv4_addr = ");
578 q.text(util.pretty_ipv4(self.ipv4_addr))
579 q.text(","); q.breakable()
580 q.text("ipv4_netmask = ");
581 q.text(util.pretty_ipv4(self.ipv4_netmask))
582 q.breakable()
583 q.text('}')
584
Rich Lane7dcdf022013-12-11 14:45:27 -0800585
586class bsn_lacp_stats_entry(loxi.OFObject):
Rich Lane7b0f2012013-11-22 14:15:26 -0800587
588 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):
589 if port_no != None:
590 self.port_no = port_no
591 else:
592 self.port_no = 0
593 if actor_sys_priority != None:
594 self.actor_sys_priority = actor_sys_priority
595 else:
596 self.actor_sys_priority = 0
597 if actor_sys_mac != None:
598 self.actor_sys_mac = actor_sys_mac
599 else:
600 self.actor_sys_mac = [0,0,0,0,0,0]
601 if actor_port_priority != None:
602 self.actor_port_priority = actor_port_priority
603 else:
604 self.actor_port_priority = 0
605 if actor_port_num != None:
606 self.actor_port_num = actor_port_num
607 else:
608 self.actor_port_num = 0
609 if actor_key != None:
610 self.actor_key = actor_key
611 else:
612 self.actor_key = 0
613 if convergence_status != None:
614 self.convergence_status = convergence_status
615 else:
616 self.convergence_status = 0
617 if partner_sys_priority != None:
618 self.partner_sys_priority = partner_sys_priority
619 else:
620 self.partner_sys_priority = 0
621 if partner_sys_mac != None:
622 self.partner_sys_mac = partner_sys_mac
623 else:
624 self.partner_sys_mac = [0,0,0,0,0,0]
625 if partner_port_priority != None:
626 self.partner_port_priority = partner_port_priority
627 else:
628 self.partner_port_priority = 0
629 if partner_port_num != None:
630 self.partner_port_num = partner_port_num
631 else:
632 self.partner_port_num = 0
633 if partner_key != None:
634 self.partner_key = partner_key
635 else:
636 self.partner_key = 0
637 return
638
639 def pack(self):
640 packed = []
641 packed.append(util.pack_port_no(self.port_no))
642 packed.append(struct.pack("!H", self.actor_sys_priority))
643 packed.append(struct.pack("!6B", *self.actor_sys_mac))
644 packed.append(struct.pack("!H", self.actor_port_priority))
645 packed.append(struct.pack("!H", self.actor_port_num))
646 packed.append(struct.pack("!H", self.actor_key))
647 packed.append(struct.pack("!B", self.convergence_status))
648 packed.append('\x00' * 1)
649 packed.append(struct.pack("!H", self.partner_sys_priority))
650 packed.append(struct.pack("!6B", *self.partner_sys_mac))
651 packed.append(struct.pack("!H", self.partner_port_priority))
652 packed.append(struct.pack("!H", self.partner_port_num))
653 packed.append(struct.pack("!H", self.partner_key))
654 packed.append('\x00' * 2)
655 return ''.join(packed)
656
657 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800658 def unpack(reader):
Rich Lane7b0f2012013-11-22 14:15:26 -0800659 obj = bsn_lacp_stats_entry()
Rich Lane7b0f2012013-11-22 14:15:26 -0800660 obj.port_no = util.unpack_port_no(reader)
661 obj.actor_sys_priority = reader.read("!H")[0]
662 obj.actor_sys_mac = list(reader.read('!6B'))
663 obj.actor_port_priority = reader.read("!H")[0]
664 obj.actor_port_num = reader.read("!H")[0]
665 obj.actor_key = reader.read("!H")[0]
666 obj.convergence_status = reader.read("!B")[0]
667 reader.skip(1)
668 obj.partner_sys_priority = reader.read("!H")[0]
669 obj.partner_sys_mac = list(reader.read('!6B'))
670 obj.partner_port_priority = reader.read("!H")[0]
671 obj.partner_port_num = reader.read("!H")[0]
672 obj.partner_key = reader.read("!H")[0]
673 reader.skip(2)
674 return obj
675
676 def __eq__(self, other):
677 if type(self) != type(other): return False
678 if self.port_no != other.port_no: return False
679 if self.actor_sys_priority != other.actor_sys_priority: return False
680 if self.actor_sys_mac != other.actor_sys_mac: return False
681 if self.actor_port_priority != other.actor_port_priority: return False
682 if self.actor_port_num != other.actor_port_num: return False
683 if self.actor_key != other.actor_key: return False
684 if self.convergence_status != other.convergence_status: return False
685 if self.partner_sys_priority != other.partner_sys_priority: return False
686 if self.partner_sys_mac != other.partner_sys_mac: return False
687 if self.partner_port_priority != other.partner_port_priority: return False
688 if self.partner_port_num != other.partner_port_num: return False
689 if self.partner_key != other.partner_key: return False
690 return True
691
Rich Lane7b0f2012013-11-22 14:15:26 -0800692 def pretty_print(self, q):
693 q.text("bsn_lacp_stats_entry {")
694 with q.group():
695 with q.indent(2):
696 q.breakable()
697 q.text("port_no = ");
698 q.text(util.pretty_port(self.port_no))
699 q.text(","); q.breakable()
700 q.text("actor_sys_priority = ");
701 q.text("%#x" % self.actor_sys_priority)
702 q.text(","); q.breakable()
703 q.text("actor_sys_mac = ");
704 q.text(util.pretty_mac(self.actor_sys_mac))
705 q.text(","); q.breakable()
706 q.text("actor_port_priority = ");
707 q.text("%#x" % self.actor_port_priority)
708 q.text(","); q.breakable()
709 q.text("actor_port_num = ");
710 q.text("%#x" % self.actor_port_num)
711 q.text(","); q.breakable()
712 q.text("actor_key = ");
713 q.text("%#x" % self.actor_key)
714 q.text(","); q.breakable()
715 q.text("convergence_status = ");
716 q.text("%#x" % self.convergence_status)
717 q.text(","); q.breakable()
718 q.text("partner_sys_priority = ");
719 q.text("%#x" % self.partner_sys_priority)
720 q.text(","); q.breakable()
721 q.text("partner_sys_mac = ");
722 q.text(util.pretty_mac(self.partner_sys_mac))
723 q.text(","); q.breakable()
724 q.text("partner_port_priority = ");
725 q.text("%#x" % self.partner_port_priority)
726 q.text(","); q.breakable()
727 q.text("partner_port_num = ");
728 q.text("%#x" % self.partner_port_num)
729 q.text(","); q.breakable()
730 q.text("partner_key = ");
731 q.text("%#x" % self.partner_key)
732 q.breakable()
733 q.text('}')
734
Rich Lane7dcdf022013-12-11 14:45:27 -0800735
736class bsn_port_counter_stats_entry(loxi.OFObject):
737
738 def __init__(self, port_no=None, values=None):
739 if port_no != None:
740 self.port_no = port_no
741 else:
742 self.port_no = 0
743 if values != None:
744 self.values = values
745 else:
746 self.values = []
747 return
748
749 def pack(self):
750 packed = []
751 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
752 packed.append('\x00' * 2)
753 packed.append(util.pack_port_no(self.port_no))
754 packed.append(loxi.generic_util.pack_list(self.values))
755 length = sum([len(x) for x in packed])
756 packed[0] = struct.pack("!H", length)
757 return ''.join(packed)
758
759 @staticmethod
760 def unpack(reader):
761 obj = bsn_port_counter_stats_entry()
762 _length = reader.read("!H")[0]
763 orig_reader = reader
764 reader = orig_reader.slice(_length - (0 + 2))
765 reader.skip(2)
766 obj.port_no = util.unpack_port_no(reader)
767 obj.values = loxi.generic_util.unpack_list(reader, common.uint64.unpack)
768 return obj
769
770 def __eq__(self, other):
771 if type(self) != type(other): return False
772 if self.port_no != other.port_no: return False
773 if self.values != other.values: return False
774 return True
775
776 def pretty_print(self, q):
777 q.text("bsn_port_counter_stats_entry {")
778 with q.group():
779 with q.indent(2):
780 q.breakable()
781 q.text("port_no = ");
782 q.text(util.pretty_port(self.port_no))
783 q.text(","); q.breakable()
784 q.text("values = ");
785 q.pp(self.values)
786 q.breakable()
787 q.text('}')
788
789
790class bsn_switch_pipeline_stats_entry(loxi.OFObject):
791
792 def __init__(self, pipeline=None):
793 if pipeline != None:
794 self.pipeline = pipeline
795 else:
796 self.pipeline = ""
797 return
798
799 def pack(self):
800 packed = []
801 packed.append(struct.pack("!256s", self.pipeline))
802 return ''.join(packed)
803
804 @staticmethod
805 def unpack(reader):
806 obj = bsn_switch_pipeline_stats_entry()
807 obj.pipeline = reader.read("!256s")[0].rstrip("\x00")
808 return obj
809
810 def __eq__(self, other):
811 if type(self) != type(other): return False
812 if self.pipeline != other.pipeline: return False
813 return True
814
815 def pretty_print(self, q):
816 q.text("bsn_switch_pipeline_stats_entry {")
817 with q.group():
818 with q.indent(2):
819 q.breakable()
820 q.text("pipeline = ");
821 q.pp(self.pipeline)
822 q.breakable()
823 q.text('}')
824
825
Rich Lane9ec3fca2014-02-26 16:22:56 -0800826class bsn_table_checksum_stats_entry(loxi.OFObject):
827
828 def __init__(self, table_id=None, checksum=None):
829 if table_id != None:
830 self.table_id = table_id
831 else:
832 self.table_id = 0
833 if checksum != None:
834 self.checksum = checksum
835 else:
836 self.checksum = 0
837 return
838
839 def pack(self):
840 packed = []
841 packed.append(struct.pack("!B", self.table_id))
842 packed.append(struct.pack("!Q", self.checksum))
843 return ''.join(packed)
844
845 @staticmethod
846 def unpack(reader):
847 obj = bsn_table_checksum_stats_entry()
848 obj.table_id = reader.read("!B")[0]
849 obj.checksum = reader.read("!Q")[0]
850 return obj
851
852 def __eq__(self, other):
853 if type(self) != type(other): return False
854 if self.table_id != other.table_id: return False
855 if self.checksum != other.checksum: return False
856 return True
857
858 def pretty_print(self, q):
859 q.text("bsn_table_checksum_stats_entry {")
860 with q.group():
861 with q.indent(2):
862 q.breakable()
863 q.text("table_id = ");
864 q.text("%#x" % self.table_id)
865 q.text(","); q.breakable()
866 q.text("checksum = ");
867 q.text("%#x" % self.checksum)
868 q.breakable()
869 q.text('}')
870
871
Rich Lane7dcdf022013-12-11 14:45:27 -0800872class bsn_vport(loxi.OFObject):
873 subtypes = {}
874
Rich Lane95f7fc92014-01-27 17:08:16 -0800875
876 def __init__(self, type=None):
877 if type != None:
878 self.type = type
879 else:
880 self.type = 0
881 return
882
883 def pack(self):
884 packed = []
885 packed.append(struct.pack("!H", self.type))
886 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
887 length = sum([len(x) for x in packed])
888 packed[1] = struct.pack("!H", length)
889 return ''.join(packed)
890
Rich Lane7dcdf022013-12-11 14:45:27 -0800891 @staticmethod
892 def unpack(reader):
893 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -0800894 subclass = bsn_vport.subtypes.get(subtype)
895 if subclass:
896 return subclass.unpack(reader)
897
898 obj = bsn_vport()
899 obj.type = reader.read("!H")[0]
900 _length = reader.read("!H")[0]
901 orig_reader = reader
902 reader = orig_reader.slice(_length - (2 + 2))
903 return obj
904
905 def __eq__(self, other):
906 if type(self) != type(other): return False
907 if self.type != other.type: return False
908 return True
909
910 def pretty_print(self, q):
911 q.text("bsn_vport {")
912 with q.group():
913 with q.indent(2):
914 q.breakable()
915 q.breakable()
916 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800917
918
Rich Lane93b33132014-04-21 12:20:58 -0700919class bsn_vlan_counter_stats_entry(loxi.OFObject):
920
921 def __init__(self, vlan_vid=None, values=None):
922 if vlan_vid != None:
923 self.vlan_vid = vlan_vid
924 else:
925 self.vlan_vid = 0
926 if values != None:
927 self.values = values
928 else:
929 self.values = []
930 return
931
932 def pack(self):
933 packed = []
934 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
935 packed.append(struct.pack("!H", self.vlan_vid))
936 packed.append('\x00' * 4)
937 packed.append(loxi.generic_util.pack_list(self.values))
938 length = sum([len(x) for x in packed])
939 packed[0] = struct.pack("!H", length)
940 return ''.join(packed)
941
942 @staticmethod
943 def unpack(reader):
944 obj = bsn_vlan_counter_stats_entry()
945 _length = reader.read("!H")[0]
946 orig_reader = reader
947 reader = orig_reader.slice(_length - (0 + 2))
948 obj.vlan_vid = reader.read("!H")[0]
949 reader.skip(4)
950 obj.values = loxi.generic_util.unpack_list(reader, common.uint64.unpack)
951 return obj
952
953 def __eq__(self, other):
954 if type(self) != type(other): return False
955 if self.vlan_vid != other.vlan_vid: return False
956 if self.values != other.values: return False
957 return True
958
959 def pretty_print(self, q):
960 q.text("bsn_vlan_counter_stats_entry {")
961 with q.group():
962 with q.indent(2):
963 q.breakable()
964 q.text("vlan_vid = ");
965 q.text("%#x" % self.vlan_vid)
966 q.text(","); q.breakable()
967 q.text("values = ");
968 q.pp(self.values)
969 q.breakable()
970 q.text('}')
971
972
973class bsn_vport_l2gre(bsn_vport):
974 type = 1
975
Rich Lanef9530c42014-09-15 09:59:43 -0700976 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 -0700977 if flags != None:
978 self.flags = flags
979 else:
980 self.flags = 0
981 if port_no != None:
982 self.port_no = port_no
983 else:
984 self.port_no = 0
Rich Lane5587ab12014-06-30 11:19:09 -0700985 if loopback_port_no != None:
986 self.loopback_port_no = loopback_port_no
987 else:
988 self.loopback_port_no = 0
Rich Lane93b33132014-04-21 12:20:58 -0700989 if local_mac != None:
990 self.local_mac = local_mac
991 else:
992 self.local_mac = [0,0,0,0,0,0]
993 if nh_mac != None:
994 self.nh_mac = nh_mac
995 else:
996 self.nh_mac = [0,0,0,0,0,0]
997 if src_ip != None:
998 self.src_ip = src_ip
999 else:
1000 self.src_ip = 0
1001 if dst_ip != None:
1002 self.dst_ip = dst_ip
1003 else:
1004 self.dst_ip = 0
1005 if dscp != None:
1006 self.dscp = dscp
1007 else:
1008 self.dscp = 0
1009 if ttl != None:
1010 self.ttl = ttl
1011 else:
1012 self.ttl = 0
1013 if vpn != None:
1014 self.vpn = vpn
1015 else:
1016 self.vpn = 0
Rich Lanef9530c42014-09-15 09:59:43 -07001017 if rate_limit != None:
1018 self.rate_limit = rate_limit
1019 else:
1020 self.rate_limit = 0
Rich Lane93b33132014-04-21 12:20:58 -07001021 if if_name != None:
1022 self.if_name = if_name
1023 else:
1024 self.if_name = ""
1025 return
1026
1027 def pack(self):
1028 packed = []
1029 packed.append(struct.pack("!H", self.type))
1030 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
1031 packed.append(struct.pack("!L", self.flags))
1032 packed.append(util.pack_port_no(self.port_no))
Rich Lane5587ab12014-06-30 11:19:09 -07001033 packed.append(util.pack_port_no(self.loopback_port_no))
Rich Lane93b33132014-04-21 12:20:58 -07001034 packed.append(struct.pack("!6B", *self.local_mac))
1035 packed.append(struct.pack("!6B", *self.nh_mac))
1036 packed.append(struct.pack("!L", self.src_ip))
1037 packed.append(struct.pack("!L", self.dst_ip))
1038 packed.append(struct.pack("!B", self.dscp))
1039 packed.append(struct.pack("!B", self.ttl))
1040 packed.append('\x00' * 2)
1041 packed.append(struct.pack("!L", self.vpn))
Rich Lanef9530c42014-09-15 09:59:43 -07001042 packed.append(struct.pack("!L", self.rate_limit))
Rich Lane93b33132014-04-21 12:20:58 -07001043 packed.append(struct.pack("!16s", self.if_name))
1044 length = sum([len(x) for x in packed])
1045 packed[1] = struct.pack("!H", length)
1046 return ''.join(packed)
1047
1048 @staticmethod
1049 def unpack(reader):
1050 obj = bsn_vport_l2gre()
1051 _type = reader.read("!H")[0]
1052 assert(_type == 1)
1053 _length = reader.read("!H")[0]
1054 orig_reader = reader
1055 reader = orig_reader.slice(_length - (2 + 2))
1056 obj.flags = reader.read("!L")[0]
1057 obj.port_no = util.unpack_port_no(reader)
Rich Lane5587ab12014-06-30 11:19:09 -07001058 obj.loopback_port_no = util.unpack_port_no(reader)
Rich Lane93b33132014-04-21 12:20:58 -07001059 obj.local_mac = list(reader.read('!6B'))
1060 obj.nh_mac = list(reader.read('!6B'))
1061 obj.src_ip = reader.read("!L")[0]
1062 obj.dst_ip = reader.read("!L")[0]
1063 obj.dscp = reader.read("!B")[0]
1064 obj.ttl = reader.read("!B")[0]
1065 reader.skip(2)
1066 obj.vpn = reader.read("!L")[0]
Rich Lanef9530c42014-09-15 09:59:43 -07001067 obj.rate_limit = reader.read("!L")[0]
Rich Lane93b33132014-04-21 12:20:58 -07001068 obj.if_name = reader.read("!16s")[0].rstrip("\x00")
1069 return obj
1070
1071 def __eq__(self, other):
1072 if type(self) != type(other): return False
1073 if self.flags != other.flags: return False
1074 if self.port_no != other.port_no: return False
Rich Lane5587ab12014-06-30 11:19:09 -07001075 if self.loopback_port_no != other.loopback_port_no: return False
Rich Lane93b33132014-04-21 12:20:58 -07001076 if self.local_mac != other.local_mac: return False
1077 if self.nh_mac != other.nh_mac: return False
1078 if self.src_ip != other.src_ip: return False
1079 if self.dst_ip != other.dst_ip: return False
1080 if self.dscp != other.dscp: return False
1081 if self.ttl != other.ttl: return False
1082 if self.vpn != other.vpn: return False
Rich Lanef9530c42014-09-15 09:59:43 -07001083 if self.rate_limit != other.rate_limit: return False
Rich Lane93b33132014-04-21 12:20:58 -07001084 if self.if_name != other.if_name: return False
1085 return True
1086
1087 def pretty_print(self, q):
1088 q.text("bsn_vport_l2gre {")
1089 with q.group():
1090 with q.indent(2):
1091 q.breakable()
1092 q.text("flags = ");
1093 q.text("%#x" % self.flags)
1094 q.text(","); q.breakable()
1095 q.text("port_no = ");
1096 q.text(util.pretty_port(self.port_no))
1097 q.text(","); q.breakable()
Rich Lane5587ab12014-06-30 11:19:09 -07001098 q.text("loopback_port_no = ");
1099 q.text(util.pretty_port(self.loopback_port_no))
1100 q.text(","); q.breakable()
Rich Lane93b33132014-04-21 12:20:58 -07001101 q.text("local_mac = ");
1102 q.text(util.pretty_mac(self.local_mac))
1103 q.text(","); q.breakable()
1104 q.text("nh_mac = ");
1105 q.text(util.pretty_mac(self.nh_mac))
1106 q.text(","); q.breakable()
1107 q.text("src_ip = ");
1108 q.text(util.pretty_ipv4(self.src_ip))
1109 q.text(","); q.breakable()
1110 q.text("dst_ip = ");
1111 q.text(util.pretty_ipv4(self.dst_ip))
1112 q.text(","); q.breakable()
1113 q.text("dscp = ");
1114 q.text("%#x" % self.dscp)
1115 q.text(","); q.breakable()
1116 q.text("ttl = ");
1117 q.text("%#x" % self.ttl)
1118 q.text(","); q.breakable()
1119 q.text("vpn = ");
1120 q.text("%#x" % self.vpn)
1121 q.text(","); q.breakable()
Rich Lanef9530c42014-09-15 09:59:43 -07001122 q.text("rate_limit = ");
1123 q.text("%#x" % self.rate_limit)
1124 q.text(","); q.breakable()
Rich Lane93b33132014-04-21 12:20:58 -07001125 q.text("if_name = ");
1126 q.pp(self.if_name)
1127 q.breakable()
1128 q.text('}')
1129
1130bsn_vport.subtypes[1] = bsn_vport_l2gre
1131
Rich Lane7dcdf022013-12-11 14:45:27 -08001132class bsn_vport_q_in_q(bsn_vport):
Dan Talaycof6202252013-07-02 01:00:29 -07001133 type = 0
1134
Kiran Poola150d8b02013-09-20 13:30:39 -07001135 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 -07001136 if port_no != None:
1137 self.port_no = port_no
1138 else:
1139 self.port_no = 0
1140 if ingress_tpid != None:
1141 self.ingress_tpid = ingress_tpid
1142 else:
1143 self.ingress_tpid = 0
1144 if ingress_vlan_id != None:
1145 self.ingress_vlan_id = ingress_vlan_id
1146 else:
1147 self.ingress_vlan_id = 0
1148 if egress_tpid != None:
1149 self.egress_tpid = egress_tpid
1150 else:
1151 self.egress_tpid = 0
1152 if egress_vlan_id != None:
1153 self.egress_vlan_id = egress_vlan_id
1154 else:
1155 self.egress_vlan_id = 0
Kiran Poola150d8b02013-09-20 13:30:39 -07001156 if if_name != None:
1157 self.if_name = if_name
1158 else:
1159 self.if_name = ""
Dan Talaycof6202252013-07-02 01:00:29 -07001160 return
1161
1162 def pack(self):
1163 packed = []
1164 packed.append(struct.pack("!H", self.type))
Kiran Poola150d8b02013-09-20 13:30:39 -07001165 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -07001166 packed.append(struct.pack("!L", self.port_no))
1167 packed.append(struct.pack("!H", self.ingress_tpid))
1168 packed.append(struct.pack("!H", self.ingress_vlan_id))
1169 packed.append(struct.pack("!H", self.egress_tpid))
1170 packed.append(struct.pack("!H", self.egress_vlan_id))
Kiran Poola150d8b02013-09-20 13:30:39 -07001171 packed.append(struct.pack("!16s", self.if_name))
Dan Talaycof6202252013-07-02 01:00:29 -07001172 length = sum([len(x) for x in packed])
Kiran Poola150d8b02013-09-20 13:30:39 -07001173 packed[1] = struct.pack("!H", length)
Dan Talaycof6202252013-07-02 01:00:29 -07001174 return ''.join(packed)
1175
1176 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001177 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001178 obj = bsn_vport_q_in_q()
Dan Talaycof6202252013-07-02 01:00:29 -07001179 _type = reader.read("!H")[0]
1180 assert(_type == 0)
1181 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001182 orig_reader = reader
1183 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001184 obj.port_no = reader.read("!L")[0]
1185 obj.ingress_tpid = reader.read("!H")[0]
1186 obj.ingress_vlan_id = reader.read("!H")[0]
1187 obj.egress_tpid = reader.read("!H")[0]
1188 obj.egress_vlan_id = reader.read("!H")[0]
Kiran Poola150d8b02013-09-20 13:30:39 -07001189 obj.if_name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -07001190 return obj
1191
1192 def __eq__(self, other):
1193 if type(self) != type(other): return False
1194 if self.port_no != other.port_no: return False
1195 if self.ingress_tpid != other.ingress_tpid: return False
1196 if self.ingress_vlan_id != other.ingress_vlan_id: return False
1197 if self.egress_tpid != other.egress_tpid: return False
1198 if self.egress_vlan_id != other.egress_vlan_id: return False
Kiran Poola150d8b02013-09-20 13:30:39 -07001199 if self.if_name != other.if_name: return False
Dan Talaycof6202252013-07-02 01:00:29 -07001200 return True
1201
Dan Talaycof6202252013-07-02 01:00:29 -07001202 def pretty_print(self, q):
1203 q.text("bsn_vport_q_in_q {")
1204 with q.group():
1205 with q.indent(2):
1206 q.breakable()
1207 q.text("port_no = ");
1208 q.text("%#x" % self.port_no)
1209 q.text(","); q.breakable()
1210 q.text("ingress_tpid = ");
1211 q.text("%#x" % self.ingress_tpid)
1212 q.text(","); q.breakable()
1213 q.text("ingress_vlan_id = ");
1214 q.text("%#x" % self.ingress_vlan_id)
1215 q.text(","); q.breakable()
1216 q.text("egress_tpid = ");
1217 q.text("%#x" % self.egress_tpid)
1218 q.text(","); q.breakable()
1219 q.text("egress_vlan_id = ");
1220 q.text("%#x" % self.egress_vlan_id)
Kiran Poola150d8b02013-09-20 13:30:39 -07001221 q.text(","); q.breakable()
1222 q.text("if_name = ");
1223 q.pp(self.if_name)
Dan Talaycof6202252013-07-02 01:00:29 -07001224 q.breakable()
1225 q.text('}')
1226
Rich Lane7dcdf022013-12-11 14:45:27 -08001227bsn_vport.subtypes[0] = bsn_vport_q_in_q
1228
Rich Lane5587ab12014-06-30 11:19:09 -07001229class bsn_vrf_counter_stats_entry(loxi.OFObject):
1230
1231 def __init__(self, vrf=None, values=None):
1232 if vrf != None:
1233 self.vrf = vrf
1234 else:
1235 self.vrf = 0
1236 if values != None:
1237 self.values = values
1238 else:
1239 self.values = []
1240 return
1241
1242 def pack(self):
1243 packed = []
1244 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
1245 packed.append('\x00' * 2)
1246 packed.append(struct.pack("!L", self.vrf))
1247 packed.append(loxi.generic_util.pack_list(self.values))
1248 length = sum([len(x) for x in packed])
1249 packed[0] = struct.pack("!H", length)
1250 return ''.join(packed)
1251
1252 @staticmethod
1253 def unpack(reader):
1254 obj = bsn_vrf_counter_stats_entry()
1255 _length = reader.read("!H")[0]
1256 orig_reader = reader
1257 reader = orig_reader.slice(_length - (0 + 2))
1258 reader.skip(2)
1259 obj.vrf = reader.read("!L")[0]
1260 obj.values = loxi.generic_util.unpack_list(reader, common.uint64.unpack)
1261 return obj
1262
1263 def __eq__(self, other):
1264 if type(self) != type(other): return False
1265 if self.vrf != other.vrf: return False
1266 if self.values != other.values: return False
1267 return True
1268
1269 def pretty_print(self, q):
1270 q.text("bsn_vrf_counter_stats_entry {")
1271 with q.group():
1272 with q.indent(2):
1273 q.breakable()
1274 q.text("vrf = ");
1275 q.text("%#x" % self.vrf)
1276 q.text(","); q.breakable()
1277 q.text("values = ");
1278 q.pp(self.values)
1279 q.breakable()
1280 q.text('}')
1281
1282
Rich Lane7dcdf022013-12-11 14:45:27 -08001283class bucket(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001284
1285 def __init__(self, weight=None, watch_port=None, watch_group=None, actions=None):
1286 if weight != None:
1287 self.weight = weight
1288 else:
1289 self.weight = 0
1290 if watch_port != None:
1291 self.watch_port = watch_port
1292 else:
1293 self.watch_port = 0
1294 if watch_group != None:
1295 self.watch_group = watch_group
1296 else:
1297 self.watch_group = 0
1298 if actions != None:
1299 self.actions = actions
1300 else:
1301 self.actions = []
1302 return
1303
1304 def pack(self):
1305 packed = []
1306 packed.append(struct.pack("!H", 0)) # placeholder for len at index 0
1307 packed.append(struct.pack("!H", self.weight))
Dan Talaycof6202252013-07-02 01:00:29 -07001308 packed.append(util.pack_port_no(self.watch_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001309 packed.append(struct.pack("!L", self.watch_group))
1310 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08001311 packed.append(loxi.generic_util.pack_list(self.actions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001312 length = sum([len(x) for x in packed])
1313 packed[0] = struct.pack("!H", length)
1314 return ''.join(packed)
1315
1316 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001317 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001318 obj = bucket()
Dan Talaycof6202252013-07-02 01:00:29 -07001319 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001320 orig_reader = reader
1321 reader = orig_reader.slice(_len - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001322 obj.weight = reader.read("!H")[0]
1323 obj.watch_port = util.unpack_port_no(reader)
1324 obj.watch_group = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001325 reader.skip(4)
Rich Lane7dcdf022013-12-11 14:45:27 -08001326 obj.actions = loxi.generic_util.unpack_list(reader, action.action.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001327 return obj
1328
1329 def __eq__(self, other):
1330 if type(self) != type(other): return False
1331 if self.weight != other.weight: return False
1332 if self.watch_port != other.watch_port: return False
1333 if self.watch_group != other.watch_group: return False
1334 if self.actions != other.actions: return False
1335 return True
1336
Rich Lanec2ee4b82013-04-24 17:12:38 -07001337 def pretty_print(self, q):
1338 q.text("bucket {")
1339 with q.group():
1340 with q.indent(2):
1341 q.breakable()
1342 q.text("weight = ");
1343 q.text("%#x" % self.weight)
1344 q.text(","); q.breakable()
1345 q.text("watch_port = ");
1346 q.text(util.pretty_port(self.watch_port))
1347 q.text(","); q.breakable()
1348 q.text("watch_group = ");
1349 q.text("%#x" % self.watch_group)
1350 q.text(","); q.breakable()
1351 q.text("actions = ");
1352 q.pp(self.actions)
1353 q.breakable()
1354 q.text('}')
1355
Rich Lane7dcdf022013-12-11 14:45:27 -08001356
1357class bucket_counter(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001358
1359 def __init__(self, packet_count=None, byte_count=None):
1360 if packet_count != None:
1361 self.packet_count = packet_count
1362 else:
1363 self.packet_count = 0
1364 if byte_count != None:
1365 self.byte_count = byte_count
1366 else:
1367 self.byte_count = 0
1368 return
1369
1370 def pack(self):
1371 packed = []
1372 packed.append(struct.pack("!Q", self.packet_count))
1373 packed.append(struct.pack("!Q", self.byte_count))
1374 return ''.join(packed)
1375
1376 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001377 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001378 obj = bucket_counter()
Dan Talaycof6202252013-07-02 01:00:29 -07001379 obj.packet_count = reader.read("!Q")[0]
1380 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001381 return obj
1382
1383 def __eq__(self, other):
1384 if type(self) != type(other): return False
1385 if self.packet_count != other.packet_count: return False
1386 if self.byte_count != other.byte_count: return False
1387 return True
1388
Rich Lanec2ee4b82013-04-24 17:12:38 -07001389 def pretty_print(self, q):
1390 q.text("bucket_counter {")
1391 with q.group():
1392 with q.indent(2):
1393 q.breakable()
1394 q.text("packet_count = ");
1395 q.text("%#x" % self.packet_count)
1396 q.text(","); q.breakable()
1397 q.text("byte_count = ");
1398 q.text("%#x" % self.byte_count)
1399 q.breakable()
1400 q.text('}')
1401
Rich Lane7dcdf022013-12-11 14:45:27 -08001402
Rich Lane7dcdf022013-12-11 14:45:27 -08001403class flow_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001404
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001405 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 -07001406 if table_id != None:
1407 self.table_id = table_id
1408 else:
1409 self.table_id = 0
1410 if duration_sec != None:
1411 self.duration_sec = duration_sec
1412 else:
1413 self.duration_sec = 0
1414 if duration_nsec != None:
1415 self.duration_nsec = duration_nsec
1416 else:
1417 self.duration_nsec = 0
1418 if priority != None:
1419 self.priority = priority
1420 else:
1421 self.priority = 0
1422 if idle_timeout != None:
1423 self.idle_timeout = idle_timeout
1424 else:
1425 self.idle_timeout = 0
1426 if hard_timeout != None:
1427 self.hard_timeout = hard_timeout
1428 else:
1429 self.hard_timeout = 0
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001430 if flags != None:
1431 self.flags = flags
1432 else:
1433 self.flags = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07001434 if cookie != None:
1435 self.cookie = cookie
1436 else:
1437 self.cookie = 0
1438 if packet_count != None:
1439 self.packet_count = packet_count
1440 else:
1441 self.packet_count = 0
1442 if byte_count != None:
1443 self.byte_count = byte_count
1444 else:
1445 self.byte_count = 0
1446 if match != None:
1447 self.match = match
1448 else:
1449 self.match = common.match()
1450 if instructions != None:
1451 self.instructions = instructions
1452 else:
1453 self.instructions = []
1454 return
1455
1456 def pack(self):
1457 packed = []
1458 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
1459 packed.append(struct.pack("!B", self.table_id))
1460 packed.append('\x00' * 1)
1461 packed.append(struct.pack("!L", self.duration_sec))
1462 packed.append(struct.pack("!L", self.duration_nsec))
1463 packed.append(struct.pack("!H", self.priority))
1464 packed.append(struct.pack("!H", self.idle_timeout))
1465 packed.append(struct.pack("!H", self.hard_timeout))
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001466 packed.append(struct.pack("!H", self.flags))
1467 packed.append('\x00' * 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001468 packed.append(struct.pack("!Q", self.cookie))
1469 packed.append(struct.pack("!Q", self.packet_count))
1470 packed.append(struct.pack("!Q", self.byte_count))
1471 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08001472 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001473 length = sum([len(x) for x in packed])
1474 packed[0] = struct.pack("!H", length)
1475 return ''.join(packed)
1476
1477 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001478 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001479 obj = flow_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001480 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001481 orig_reader = reader
1482 reader = orig_reader.slice(_length - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001483 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001484 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -07001485 obj.duration_sec = reader.read("!L")[0]
1486 obj.duration_nsec = reader.read("!L")[0]
1487 obj.priority = reader.read("!H")[0]
1488 obj.idle_timeout = reader.read("!H")[0]
1489 obj.hard_timeout = reader.read("!H")[0]
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001490 obj.flags = reader.read("!H")[0]
1491 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001492 obj.cookie = reader.read("!Q")[0]
1493 obj.packet_count = reader.read("!Q")[0]
1494 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001495 obj.match = common.match.unpack(reader)
Rich Lane7dcdf022013-12-11 14:45:27 -08001496 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001497 return obj
1498
1499 def __eq__(self, other):
1500 if type(self) != type(other): return False
1501 if self.table_id != other.table_id: return False
1502 if self.duration_sec != other.duration_sec: return False
1503 if self.duration_nsec != other.duration_nsec: return False
1504 if self.priority != other.priority: return False
1505 if self.idle_timeout != other.idle_timeout: return False
1506 if self.hard_timeout != other.hard_timeout: return False
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001507 if self.flags != other.flags: return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001508 if self.cookie != other.cookie: return False
1509 if self.packet_count != other.packet_count: return False
1510 if self.byte_count != other.byte_count: return False
1511 if self.match != other.match: return False
1512 if self.instructions != other.instructions: return False
1513 return True
1514
Rich Lanec2ee4b82013-04-24 17:12:38 -07001515 def pretty_print(self, q):
1516 q.text("flow_stats_entry {")
1517 with q.group():
1518 with q.indent(2):
1519 q.breakable()
1520 q.text("table_id = ");
1521 q.text("%#x" % self.table_id)
1522 q.text(","); q.breakable()
1523 q.text("duration_sec = ");
1524 q.text("%#x" % self.duration_sec)
1525 q.text(","); q.breakable()
1526 q.text("duration_nsec = ");
1527 q.text("%#x" % self.duration_nsec)
1528 q.text(","); q.breakable()
1529 q.text("priority = ");
1530 q.text("%#x" % self.priority)
1531 q.text(","); q.breakable()
1532 q.text("idle_timeout = ");
1533 q.text("%#x" % self.idle_timeout)
1534 q.text(","); q.breakable()
1535 q.text("hard_timeout = ");
1536 q.text("%#x" % self.hard_timeout)
1537 q.text(","); q.breakable()
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001538 q.text("flags = ");
1539 q.text("%#x" % self.flags)
1540 q.text(","); q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001541 q.text("cookie = ");
1542 q.text("%#x" % self.cookie)
1543 q.text(","); q.breakable()
1544 q.text("packet_count = ");
1545 q.text("%#x" % self.packet_count)
1546 q.text(","); q.breakable()
1547 q.text("byte_count = ");
1548 q.text("%#x" % self.byte_count)
1549 q.text(","); q.breakable()
1550 q.text("match = ");
1551 q.pp(self.match)
1552 q.text(","); q.breakable()
1553 q.text("instructions = ");
1554 q.pp(self.instructions)
1555 q.breakable()
1556 q.text('}')
1557
Rich Lane7dcdf022013-12-11 14:45:27 -08001558
1559class group_desc_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001560
Rich Lane6f4978c2013-10-20 21:33:52 -07001561 def __init__(self, group_type=None, group_id=None, buckets=None):
1562 if group_type != None:
1563 self.group_type = group_type
Rich Lanec2ee4b82013-04-24 17:12:38 -07001564 else:
Rich Lane6f4978c2013-10-20 21:33:52 -07001565 self.group_type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07001566 if group_id != None:
1567 self.group_id = group_id
1568 else:
1569 self.group_id = 0
1570 if buckets != None:
1571 self.buckets = buckets
1572 else:
1573 self.buckets = []
1574 return
1575
1576 def pack(self):
1577 packed = []
1578 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
Rich Lane6f4978c2013-10-20 21:33:52 -07001579 packed.append(struct.pack("!B", self.group_type))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001580 packed.append('\x00' * 1)
1581 packed.append(struct.pack("!L", self.group_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08001582 packed.append(loxi.generic_util.pack_list(self.buckets))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001583 length = sum([len(x) for x in packed])
1584 packed[0] = struct.pack("!H", length)
1585 return ''.join(packed)
1586
1587 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001588 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001589 obj = group_desc_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001590 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001591 orig_reader = reader
1592 reader = orig_reader.slice(_length - (0 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07001593 obj.group_type = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001594 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -07001595 obj.group_id = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001596 obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001597 return obj
1598
1599 def __eq__(self, other):
1600 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001601 if self.group_type != other.group_type: return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001602 if self.group_id != other.group_id: return False
1603 if self.buckets != other.buckets: return False
1604 return True
1605
Rich Lanec2ee4b82013-04-24 17:12:38 -07001606 def pretty_print(self, q):
1607 q.text("group_desc_stats_entry {")
1608 with q.group():
1609 with q.indent(2):
1610 q.breakable()
Rich Lane6f4978c2013-10-20 21:33:52 -07001611 q.text("group_type = ");
1612 q.text("%#x" % self.group_type)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001613 q.text(","); q.breakable()
1614 q.text("group_id = ");
1615 q.text("%#x" % self.group_id)
1616 q.text(","); q.breakable()
1617 q.text("buckets = ");
1618 q.pp(self.buckets)
1619 q.breakable()
1620 q.text('}')
1621
Rich Lane7dcdf022013-12-11 14:45:27 -08001622
1623class group_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001624
1625 def __init__(self, group_id=None, ref_count=None, packet_count=None, byte_count=None, duration_sec=None, duration_nsec=None, bucket_stats=None):
1626 if group_id != None:
1627 self.group_id = group_id
1628 else:
1629 self.group_id = 0
1630 if ref_count != None:
1631 self.ref_count = ref_count
1632 else:
1633 self.ref_count = 0
1634 if packet_count != None:
1635 self.packet_count = packet_count
1636 else:
1637 self.packet_count = 0
1638 if byte_count != None:
1639 self.byte_count = byte_count
1640 else:
1641 self.byte_count = 0
1642 if duration_sec != None:
1643 self.duration_sec = duration_sec
1644 else:
1645 self.duration_sec = 0
1646 if duration_nsec != None:
1647 self.duration_nsec = duration_nsec
1648 else:
1649 self.duration_nsec = 0
1650 if bucket_stats != None:
1651 self.bucket_stats = bucket_stats
1652 else:
1653 self.bucket_stats = []
1654 return
1655
1656 def pack(self):
1657 packed = []
1658 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
1659 packed.append('\x00' * 2)
1660 packed.append(struct.pack("!L", self.group_id))
1661 packed.append(struct.pack("!L", self.ref_count))
1662 packed.append('\x00' * 4)
1663 packed.append(struct.pack("!Q", self.packet_count))
1664 packed.append(struct.pack("!Q", self.byte_count))
1665 packed.append(struct.pack("!L", self.duration_sec))
1666 packed.append(struct.pack("!L", self.duration_nsec))
Rich Lane7dcdf022013-12-11 14:45:27 -08001667 packed.append(loxi.generic_util.pack_list(self.bucket_stats))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001668 length = sum([len(x) for x in packed])
1669 packed[0] = struct.pack("!H", length)
1670 return ''.join(packed)
1671
1672 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001673 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001674 obj = group_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001675 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001676 orig_reader = reader
1677 reader = orig_reader.slice(_length - (0 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001678 reader.skip(2)
Dan Talaycof6202252013-07-02 01:00:29 -07001679 obj.group_id = reader.read("!L")[0]
1680 obj.ref_count = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001681 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001682 obj.packet_count = reader.read("!Q")[0]
1683 obj.byte_count = reader.read("!Q")[0]
1684 obj.duration_sec = reader.read("!L")[0]
1685 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001686 obj.bucket_stats = loxi.generic_util.unpack_list(reader, common.bucket_counter.unpack)
1687 return obj
1688
1689 def __eq__(self, other):
1690 if type(self) != type(other): return False
1691 if self.group_id != other.group_id: return False
1692 if self.ref_count != other.ref_count: return False
1693 if self.packet_count != other.packet_count: return False
1694 if self.byte_count != other.byte_count: return False
1695 if self.duration_sec != other.duration_sec: return False
1696 if self.duration_nsec != other.duration_nsec: return False
1697 if self.bucket_stats != other.bucket_stats: return False
1698 return True
1699
Rich Lanec2ee4b82013-04-24 17:12:38 -07001700 def pretty_print(self, q):
1701 q.text("group_stats_entry {")
1702 with q.group():
1703 with q.indent(2):
1704 q.breakable()
1705 q.text("group_id = ");
1706 q.text("%#x" % self.group_id)
1707 q.text(","); q.breakable()
1708 q.text("ref_count = ");
1709 q.text("%#x" % self.ref_count)
1710 q.text(","); q.breakable()
1711 q.text("packet_count = ");
1712 q.text("%#x" % self.packet_count)
1713 q.text(","); q.breakable()
1714 q.text("byte_count = ");
1715 q.text("%#x" % self.byte_count)
1716 q.text(","); q.breakable()
1717 q.text("duration_sec = ");
1718 q.text("%#x" % self.duration_sec)
1719 q.text(","); q.breakable()
1720 q.text("duration_nsec = ");
1721 q.text("%#x" % self.duration_nsec)
1722 q.text(","); q.breakable()
1723 q.text("bucket_stats = ");
1724 q.pp(self.bucket_stats)
1725 q.breakable()
1726 q.text('}')
1727
Rich Lane7dcdf022013-12-11 14:45:27 -08001728
1729class hello_elem(loxi.OFObject):
1730 subtypes = {}
1731
Rich Lane95f7fc92014-01-27 17:08:16 -08001732
1733 def __init__(self, type=None):
1734 if type != None:
1735 self.type = type
1736 else:
1737 self.type = 0
1738 return
1739
1740 def pack(self):
1741 packed = []
1742 packed.append(struct.pack("!H", self.type))
1743 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
1744 length = sum([len(x) for x in packed])
1745 packed[1] = struct.pack("!H", length)
1746 return ''.join(packed)
1747
Rich Lane7dcdf022013-12-11 14:45:27 -08001748 @staticmethod
1749 def unpack(reader):
1750 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -08001751 subclass = hello_elem.subtypes.get(subtype)
1752 if subclass:
1753 return subclass.unpack(reader)
1754
1755 obj = hello_elem()
1756 obj.type = reader.read("!H")[0]
1757 _length = reader.read("!H")[0]
1758 orig_reader = reader
1759 reader = orig_reader.slice(_length - (2 + 2))
1760 return obj
1761
1762 def __eq__(self, other):
1763 if type(self) != type(other): return False
1764 if self.type != other.type: return False
1765 return True
1766
1767 def pretty_print(self, q):
1768 q.text("hello_elem {")
1769 with q.group():
1770 with q.indent(2):
1771 q.breakable()
1772 q.breakable()
1773 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08001774
1775
1776class hello_elem_versionbitmap(hello_elem):
Dan Talaycof6202252013-07-02 01:00:29 -07001777 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07001778
1779 def __init__(self, bitmaps=None):
1780 if bitmaps != None:
1781 self.bitmaps = bitmaps
1782 else:
1783 self.bitmaps = []
1784 return
1785
1786 def pack(self):
1787 packed = []
1788 packed.append(struct.pack("!H", self.type))
1789 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08001790 packed.append(loxi.generic_util.pack_list(self.bitmaps))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001791 length = sum([len(x) for x in packed])
1792 packed[1] = struct.pack("!H", length)
1793 return ''.join(packed)
1794
1795 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001796 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001797 obj = hello_elem_versionbitmap()
Dan Talaycof6202252013-07-02 01:00:29 -07001798 _type = reader.read("!H")[0]
1799 assert(_type == 1)
1800 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001801 orig_reader = reader
1802 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001803 obj.bitmaps = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
1804 return obj
1805
1806 def __eq__(self, other):
1807 if type(self) != type(other): return False
1808 if self.bitmaps != other.bitmaps: return False
1809 return True
1810
Rich Lanec2ee4b82013-04-24 17:12:38 -07001811 def pretty_print(self, q):
1812 q.text("hello_elem_versionbitmap {")
1813 with q.group():
1814 with q.indent(2):
1815 q.breakable()
1816 q.text("bitmaps = ");
1817 q.pp(self.bitmaps)
1818 q.breakable()
1819 q.text('}')
1820
Rich Lane7dcdf022013-12-11 14:45:27 -08001821hello_elem.subtypes[1] = hello_elem_versionbitmap
1822
1823class match_v3(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001824 type = 1
1825
1826 def __init__(self, oxm_list=None):
1827 if oxm_list != None:
1828 self.oxm_list = oxm_list
1829 else:
1830 self.oxm_list = []
1831 return
1832
1833 def pack(self):
1834 packed = []
1835 packed.append(struct.pack("!H", self.type))
1836 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08001837 packed.append(loxi.generic_util.pack_list(self.oxm_list))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001838 length = sum([len(x) for x in packed])
1839 packed[1] = struct.pack("!H", length)
Rich Laned53156a2013-08-05 17:17:33 -07001840 packed.append(loxi.generic_util.pad_to(8, length))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001841 return ''.join(packed)
1842
1843 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001844 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001845 obj = match_v3()
Dan Talaycof6202252013-07-02 01:00:29 -07001846 _type = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001847 assert(_type == 1)
Dan Talaycof6202252013-07-02 01:00:29 -07001848 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001849 orig_reader = reader
1850 reader = orig_reader.slice(_length - (2 + 2))
1851 obj.oxm_list = loxi.generic_util.unpack_list(reader, oxm.oxm.unpack)
1852 orig_reader.skip_align()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001853 return obj
1854
1855 def __eq__(self, other):
1856 if type(self) != type(other): return False
1857 if self.oxm_list != other.oxm_list: return False
1858 return True
1859
Rich Lanec2ee4b82013-04-24 17:12:38 -07001860 def pretty_print(self, q):
1861 q.text("match_v3 {")
1862 with q.group():
1863 with q.indent(2):
1864 q.breakable()
1865 q.text("oxm_list = ");
1866 q.pp(self.oxm_list)
1867 q.breakable()
1868 q.text('}')
1869
Rich Lane7dcdf022013-12-11 14:45:27 -08001870
1871class meter_band_stats(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001872
1873 def __init__(self, packet_band_count=None, byte_band_count=None):
1874 if packet_band_count != None:
1875 self.packet_band_count = packet_band_count
1876 else:
1877 self.packet_band_count = 0
1878 if byte_band_count != None:
1879 self.byte_band_count = byte_band_count
1880 else:
1881 self.byte_band_count = 0
1882 return
1883
1884 def pack(self):
1885 packed = []
1886 packed.append(struct.pack("!Q", self.packet_band_count))
1887 packed.append(struct.pack("!Q", self.byte_band_count))
1888 return ''.join(packed)
1889
1890 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001891 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001892 obj = meter_band_stats()
Dan Talaycof6202252013-07-02 01:00:29 -07001893 obj.packet_band_count = reader.read("!Q")[0]
1894 obj.byte_band_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001895 return obj
1896
1897 def __eq__(self, other):
1898 if type(self) != type(other): return False
1899 if self.packet_band_count != other.packet_band_count: return False
1900 if self.byte_band_count != other.byte_band_count: return False
1901 return True
1902
Rich Lanec2ee4b82013-04-24 17:12:38 -07001903 def pretty_print(self, q):
1904 q.text("meter_band_stats {")
1905 with q.group():
1906 with q.indent(2):
1907 q.breakable()
1908 q.text("packet_band_count = ");
1909 q.text("%#x" % self.packet_band_count)
1910 q.text(","); q.breakable()
1911 q.text("byte_band_count = ");
1912 q.text("%#x" % self.byte_band_count)
1913 q.breakable()
1914 q.text('}')
1915
Rich Lane7dcdf022013-12-11 14:45:27 -08001916
1917class meter_config(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001918
1919 def __init__(self, flags=None, meter_id=None, entries=None):
1920 if flags != None:
1921 self.flags = flags
1922 else:
1923 self.flags = 0
1924 if meter_id != None:
1925 self.meter_id = meter_id
1926 else:
1927 self.meter_id = 0
1928 if entries != None:
1929 self.entries = entries
1930 else:
1931 self.entries = []
1932 return
1933
1934 def pack(self):
1935 packed = []
1936 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
1937 packed.append(struct.pack("!H", self.flags))
1938 packed.append(struct.pack("!L", self.meter_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08001939 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001940 length = sum([len(x) for x in packed])
1941 packed[0] = struct.pack("!H", length)
1942 return ''.join(packed)
1943
1944 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001945 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001946 obj = meter_config()
Dan Talaycof6202252013-07-02 01:00:29 -07001947 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001948 orig_reader = reader
1949 reader = orig_reader.slice(_length - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001950 obj.flags = reader.read("!H")[0]
1951 obj.meter_id = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001952 obj.entries = loxi.generic_util.unpack_list(reader, meter_band.meter_band.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001953 return obj
1954
1955 def __eq__(self, other):
1956 if type(self) != type(other): return False
1957 if self.flags != other.flags: return False
1958 if self.meter_id != other.meter_id: return False
1959 if self.entries != other.entries: return False
1960 return True
1961
Rich Lanec2ee4b82013-04-24 17:12:38 -07001962 def pretty_print(self, q):
1963 q.text("meter_config {")
1964 with q.group():
1965 with q.indent(2):
1966 q.breakable()
1967 q.text("flags = ");
1968 q.text("%#x" % self.flags)
1969 q.text(","); q.breakable()
1970 q.text("meter_id = ");
1971 q.text("%#x" % self.meter_id)
1972 q.text(","); q.breakable()
1973 q.text("entries = ");
1974 q.pp(self.entries)
1975 q.breakable()
1976 q.text('}')
1977
Rich Lane7dcdf022013-12-11 14:45:27 -08001978
1979class meter_features(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001980
1981 def __init__(self, max_meter=None, band_types=None, capabilities=None, max_bands=None, max_color=None):
1982 if max_meter != None:
1983 self.max_meter = max_meter
1984 else:
1985 self.max_meter = 0
1986 if band_types != None:
1987 self.band_types = band_types
1988 else:
1989 self.band_types = 0
1990 if capabilities != None:
1991 self.capabilities = capabilities
1992 else:
1993 self.capabilities = 0
1994 if max_bands != None:
1995 self.max_bands = max_bands
1996 else:
1997 self.max_bands = 0
1998 if max_color != None:
1999 self.max_color = max_color
2000 else:
2001 self.max_color = 0
2002 return
2003
2004 def pack(self):
2005 packed = []
2006 packed.append(struct.pack("!L", self.max_meter))
2007 packed.append(struct.pack("!L", self.band_types))
2008 packed.append(struct.pack("!L", self.capabilities))
2009 packed.append(struct.pack("!B", self.max_bands))
2010 packed.append(struct.pack("!B", self.max_color))
2011 packed.append('\x00' * 2)
2012 return ''.join(packed)
2013
2014 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002015 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002016 obj = meter_features()
Dan Talaycof6202252013-07-02 01:00:29 -07002017 obj.max_meter = reader.read("!L")[0]
2018 obj.band_types = reader.read("!L")[0]
2019 obj.capabilities = reader.read("!L")[0]
2020 obj.max_bands = reader.read("!B")[0]
2021 obj.max_color = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002022 reader.skip(2)
2023 return obj
2024
2025 def __eq__(self, other):
2026 if type(self) != type(other): return False
2027 if self.max_meter != other.max_meter: return False
2028 if self.band_types != other.band_types: return False
2029 if self.capabilities != other.capabilities: return False
2030 if self.max_bands != other.max_bands: return False
2031 if self.max_color != other.max_color: return False
2032 return True
2033
Rich Lanec2ee4b82013-04-24 17:12:38 -07002034 def pretty_print(self, q):
2035 q.text("meter_features {")
2036 with q.group():
2037 with q.indent(2):
2038 q.breakable()
2039 q.text("max_meter = ");
2040 q.text("%#x" % self.max_meter)
2041 q.text(","); q.breakable()
2042 q.text("band_types = ");
2043 q.text("%#x" % self.band_types)
2044 q.text(","); q.breakable()
2045 q.text("capabilities = ");
2046 q.text("%#x" % self.capabilities)
2047 q.text(","); q.breakable()
2048 q.text("max_bands = ");
2049 q.text("%#x" % self.max_bands)
2050 q.text(","); q.breakable()
2051 q.text("max_color = ");
2052 q.text("%#x" % self.max_color)
2053 q.breakable()
2054 q.text('}')
2055
Rich Lane7dcdf022013-12-11 14:45:27 -08002056
2057class meter_stats(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002058
2059 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):
2060 if meter_id != None:
2061 self.meter_id = meter_id
2062 else:
2063 self.meter_id = 0
2064 if flow_count != None:
2065 self.flow_count = flow_count
2066 else:
2067 self.flow_count = 0
2068 if packet_in_count != None:
2069 self.packet_in_count = packet_in_count
2070 else:
2071 self.packet_in_count = 0
2072 if byte_in_count != None:
2073 self.byte_in_count = byte_in_count
2074 else:
2075 self.byte_in_count = 0
2076 if duration_sec != None:
2077 self.duration_sec = duration_sec
2078 else:
2079 self.duration_sec = 0
2080 if duration_nsec != None:
2081 self.duration_nsec = duration_nsec
2082 else:
2083 self.duration_nsec = 0
2084 if band_stats != None:
2085 self.band_stats = band_stats
2086 else:
2087 self.band_stats = []
2088 return
2089
2090 def pack(self):
2091 packed = []
2092 packed.append(struct.pack("!L", self.meter_id))
2093 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2094 packed.append('\x00' * 6)
2095 packed.append(struct.pack("!L", self.flow_count))
2096 packed.append(struct.pack("!Q", self.packet_in_count))
2097 packed.append(struct.pack("!Q", self.byte_in_count))
2098 packed.append(struct.pack("!L", self.duration_sec))
2099 packed.append(struct.pack("!L", self.duration_nsec))
Rich Lane7dcdf022013-12-11 14:45:27 -08002100 packed.append(loxi.generic_util.pack_list(self.band_stats))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002101 length = sum([len(x) for x in packed])
2102 packed[1] = struct.pack("!H", length)
2103 return ''.join(packed)
2104
2105 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002106 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002107 obj = meter_stats()
Dan Talaycof6202252013-07-02 01:00:29 -07002108 obj.meter_id = reader.read("!L")[0]
2109 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002110 orig_reader = reader
2111 reader = orig_reader.slice(_len - (4 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002112 reader.skip(6)
Dan Talaycof6202252013-07-02 01:00:29 -07002113 obj.flow_count = reader.read("!L")[0]
2114 obj.packet_in_count = reader.read("!Q")[0]
2115 obj.byte_in_count = reader.read("!Q")[0]
2116 obj.duration_sec = reader.read("!L")[0]
2117 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002118 obj.band_stats = loxi.generic_util.unpack_list(reader, common.meter_band_stats.unpack)
2119 return obj
2120
2121 def __eq__(self, other):
2122 if type(self) != type(other): return False
2123 if self.meter_id != other.meter_id: return False
2124 if self.flow_count != other.flow_count: return False
2125 if self.packet_in_count != other.packet_in_count: return False
2126 if self.byte_in_count != other.byte_in_count: return False
2127 if self.duration_sec != other.duration_sec: return False
2128 if self.duration_nsec != other.duration_nsec: return False
2129 if self.band_stats != other.band_stats: return False
2130 return True
2131
Rich Lanec2ee4b82013-04-24 17:12:38 -07002132 def pretty_print(self, q):
2133 q.text("meter_stats {")
2134 with q.group():
2135 with q.indent(2):
2136 q.breakable()
2137 q.text("meter_id = ");
2138 q.text("%#x" % self.meter_id)
2139 q.text(","); q.breakable()
2140 q.text("flow_count = ");
2141 q.text("%#x" % self.flow_count)
2142 q.text(","); q.breakable()
2143 q.text("packet_in_count = ");
2144 q.text("%#x" % self.packet_in_count)
2145 q.text(","); q.breakable()
2146 q.text("byte_in_count = ");
2147 q.text("%#x" % self.byte_in_count)
2148 q.text(","); q.breakable()
2149 q.text("duration_sec = ");
2150 q.text("%#x" % self.duration_sec)
2151 q.text(","); q.breakable()
2152 q.text("duration_nsec = ");
2153 q.text("%#x" % self.duration_nsec)
2154 q.text(","); q.breakable()
2155 q.text("band_stats = ");
2156 q.pp(self.band_stats)
2157 q.breakable()
2158 q.text('}')
2159
Rich Lane7dcdf022013-12-11 14:45:27 -08002160
2161class packet_queue(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002162
2163 def __init__(self, queue_id=None, port=None, properties=None):
2164 if queue_id != None:
2165 self.queue_id = queue_id
2166 else:
2167 self.queue_id = 0
2168 if port != None:
2169 self.port = port
2170 else:
2171 self.port = 0
2172 if properties != None:
2173 self.properties = properties
2174 else:
2175 self.properties = []
2176 return
2177
2178 def pack(self):
2179 packed = []
2180 packed.append(struct.pack("!L", self.queue_id))
Dan Talaycof6202252013-07-02 01:00:29 -07002181 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002182 packed.append(struct.pack("!H", 0)) # placeholder for len at index 2
2183 packed.append('\x00' * 6)
Rich Lane7dcdf022013-12-11 14:45:27 -08002184 packed.append(loxi.generic_util.pack_list(self.properties))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002185 length = sum([len(x) for x in packed])
2186 packed[2] = struct.pack("!H", length)
2187 return ''.join(packed)
2188
2189 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002190 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002191 obj = packet_queue()
Dan Talaycof6202252013-07-02 01:00:29 -07002192 obj.queue_id = reader.read("!L")[0]
2193 obj.port = util.unpack_port_no(reader)
2194 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002195 orig_reader = reader
2196 reader = orig_reader.slice(_len - (8 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002197 reader.skip(6)
Rich Lane7dcdf022013-12-11 14:45:27 -08002198 obj.properties = loxi.generic_util.unpack_list(reader, common.queue_prop.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002199 return obj
2200
2201 def __eq__(self, other):
2202 if type(self) != type(other): return False
2203 if self.queue_id != other.queue_id: return False
2204 if self.port != other.port: return False
2205 if self.properties != other.properties: return False
2206 return True
2207
Rich Lanec2ee4b82013-04-24 17:12:38 -07002208 def pretty_print(self, q):
2209 q.text("packet_queue {")
2210 with q.group():
2211 with q.indent(2):
2212 q.breakable()
2213 q.text("queue_id = ");
2214 q.text("%#x" % self.queue_id)
2215 q.text(","); q.breakable()
2216 q.text("port = ");
2217 q.text(util.pretty_port(self.port))
2218 q.text(","); q.breakable()
2219 q.text("properties = ");
2220 q.pp(self.properties)
2221 q.breakable()
2222 q.text('}')
2223
Rich Lane7dcdf022013-12-11 14:45:27 -08002224
2225class port_desc(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002226
2227 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):
2228 if port_no != None:
2229 self.port_no = port_no
2230 else:
2231 self.port_no = 0
2232 if hw_addr != None:
2233 self.hw_addr = hw_addr
2234 else:
2235 self.hw_addr = [0,0,0,0,0,0]
2236 if name != None:
2237 self.name = name
2238 else:
2239 self.name = ""
2240 if config != None:
2241 self.config = config
2242 else:
2243 self.config = 0
2244 if state != None:
2245 self.state = state
2246 else:
2247 self.state = 0
2248 if curr != None:
2249 self.curr = curr
2250 else:
2251 self.curr = 0
2252 if advertised != None:
2253 self.advertised = advertised
2254 else:
2255 self.advertised = 0
2256 if supported != None:
2257 self.supported = supported
2258 else:
2259 self.supported = 0
2260 if peer != None:
2261 self.peer = peer
2262 else:
2263 self.peer = 0
2264 if curr_speed != None:
2265 self.curr_speed = curr_speed
2266 else:
2267 self.curr_speed = 0
2268 if max_speed != None:
2269 self.max_speed = max_speed
2270 else:
2271 self.max_speed = 0
2272 return
2273
2274 def pack(self):
2275 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07002276 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002277 packed.append('\x00' * 4)
2278 packed.append(struct.pack("!6B", *self.hw_addr))
2279 packed.append('\x00' * 2)
2280 packed.append(struct.pack("!16s", self.name))
2281 packed.append(struct.pack("!L", self.config))
2282 packed.append(struct.pack("!L", self.state))
2283 packed.append(struct.pack("!L", self.curr))
2284 packed.append(struct.pack("!L", self.advertised))
2285 packed.append(struct.pack("!L", self.supported))
2286 packed.append(struct.pack("!L", self.peer))
2287 packed.append(struct.pack("!L", self.curr_speed))
2288 packed.append(struct.pack("!L", self.max_speed))
2289 return ''.join(packed)
2290
2291 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002292 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002293 obj = port_desc()
Dan Talaycof6202252013-07-02 01:00:29 -07002294 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002295 reader.skip(4)
2296 obj.hw_addr = list(reader.read('!6B'))
2297 reader.skip(2)
2298 obj.name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -07002299 obj.config = reader.read("!L")[0]
2300 obj.state = reader.read("!L")[0]
2301 obj.curr = reader.read("!L")[0]
2302 obj.advertised = reader.read("!L")[0]
2303 obj.supported = reader.read("!L")[0]
2304 obj.peer = reader.read("!L")[0]
2305 obj.curr_speed = reader.read("!L")[0]
2306 obj.max_speed = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002307 return obj
2308
2309 def __eq__(self, other):
2310 if type(self) != type(other): return False
2311 if self.port_no != other.port_no: return False
2312 if self.hw_addr != other.hw_addr: return False
2313 if self.name != other.name: return False
2314 if self.config != other.config: return False
2315 if self.state != other.state: return False
2316 if self.curr != other.curr: return False
2317 if self.advertised != other.advertised: return False
2318 if self.supported != other.supported: return False
2319 if self.peer != other.peer: return False
2320 if self.curr_speed != other.curr_speed: return False
2321 if self.max_speed != other.max_speed: return False
2322 return True
2323
Rich Lanec2ee4b82013-04-24 17:12:38 -07002324 def pretty_print(self, q):
2325 q.text("port_desc {")
2326 with q.group():
2327 with q.indent(2):
2328 q.breakable()
2329 q.text("port_no = ");
2330 q.text(util.pretty_port(self.port_no))
2331 q.text(","); q.breakable()
2332 q.text("hw_addr = ");
2333 q.text(util.pretty_mac(self.hw_addr))
2334 q.text(","); q.breakable()
2335 q.text("name = ");
2336 q.pp(self.name)
2337 q.text(","); q.breakable()
2338 q.text("config = ");
2339 q.text("%#x" % self.config)
2340 q.text(","); q.breakable()
2341 q.text("state = ");
2342 q.text("%#x" % self.state)
2343 q.text(","); q.breakable()
2344 q.text("curr = ");
2345 q.text("%#x" % self.curr)
2346 q.text(","); q.breakable()
2347 q.text("advertised = ");
2348 q.text("%#x" % self.advertised)
2349 q.text(","); q.breakable()
2350 q.text("supported = ");
2351 q.text("%#x" % self.supported)
2352 q.text(","); q.breakable()
2353 q.text("peer = ");
2354 q.text("%#x" % self.peer)
2355 q.text(","); q.breakable()
2356 q.text("curr_speed = ");
2357 q.text("%#x" % self.curr_speed)
2358 q.text(","); q.breakable()
2359 q.text("max_speed = ");
2360 q.text("%#x" % self.max_speed)
2361 q.breakable()
2362 q.text('}')
2363
Rich Lane7dcdf022013-12-11 14:45:27 -08002364
2365class port_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002366
2367 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):
2368 if port_no != None:
2369 self.port_no = port_no
2370 else:
2371 self.port_no = 0
2372 if rx_packets != None:
2373 self.rx_packets = rx_packets
2374 else:
2375 self.rx_packets = 0
2376 if tx_packets != None:
2377 self.tx_packets = tx_packets
2378 else:
2379 self.tx_packets = 0
2380 if rx_bytes != None:
2381 self.rx_bytes = rx_bytes
2382 else:
2383 self.rx_bytes = 0
2384 if tx_bytes != None:
2385 self.tx_bytes = tx_bytes
2386 else:
2387 self.tx_bytes = 0
2388 if rx_dropped != None:
2389 self.rx_dropped = rx_dropped
2390 else:
2391 self.rx_dropped = 0
2392 if tx_dropped != None:
2393 self.tx_dropped = tx_dropped
2394 else:
2395 self.tx_dropped = 0
2396 if rx_errors != None:
2397 self.rx_errors = rx_errors
2398 else:
2399 self.rx_errors = 0
2400 if tx_errors != None:
2401 self.tx_errors = tx_errors
2402 else:
2403 self.tx_errors = 0
2404 if rx_frame_err != None:
2405 self.rx_frame_err = rx_frame_err
2406 else:
2407 self.rx_frame_err = 0
2408 if rx_over_err != None:
2409 self.rx_over_err = rx_over_err
2410 else:
2411 self.rx_over_err = 0
2412 if rx_crc_err != None:
2413 self.rx_crc_err = rx_crc_err
2414 else:
2415 self.rx_crc_err = 0
2416 if collisions != None:
2417 self.collisions = collisions
2418 else:
2419 self.collisions = 0
2420 if duration_sec != None:
2421 self.duration_sec = duration_sec
2422 else:
2423 self.duration_sec = 0
2424 if duration_nsec != None:
2425 self.duration_nsec = duration_nsec
2426 else:
2427 self.duration_nsec = 0
2428 return
2429
2430 def pack(self):
2431 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07002432 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002433 packed.append('\x00' * 4)
2434 packed.append(struct.pack("!Q", self.rx_packets))
2435 packed.append(struct.pack("!Q", self.tx_packets))
2436 packed.append(struct.pack("!Q", self.rx_bytes))
2437 packed.append(struct.pack("!Q", self.tx_bytes))
2438 packed.append(struct.pack("!Q", self.rx_dropped))
2439 packed.append(struct.pack("!Q", self.tx_dropped))
2440 packed.append(struct.pack("!Q", self.rx_errors))
2441 packed.append(struct.pack("!Q", self.tx_errors))
2442 packed.append(struct.pack("!Q", self.rx_frame_err))
2443 packed.append(struct.pack("!Q", self.rx_over_err))
2444 packed.append(struct.pack("!Q", self.rx_crc_err))
2445 packed.append(struct.pack("!Q", self.collisions))
2446 packed.append(struct.pack("!L", self.duration_sec))
2447 packed.append(struct.pack("!L", self.duration_nsec))
2448 return ''.join(packed)
2449
2450 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002451 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002452 obj = port_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07002453 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002454 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07002455 obj.rx_packets = reader.read("!Q")[0]
2456 obj.tx_packets = reader.read("!Q")[0]
2457 obj.rx_bytes = reader.read("!Q")[0]
2458 obj.tx_bytes = reader.read("!Q")[0]
2459 obj.rx_dropped = reader.read("!Q")[0]
2460 obj.tx_dropped = reader.read("!Q")[0]
2461 obj.rx_errors = reader.read("!Q")[0]
2462 obj.tx_errors = reader.read("!Q")[0]
2463 obj.rx_frame_err = reader.read("!Q")[0]
2464 obj.rx_over_err = reader.read("!Q")[0]
2465 obj.rx_crc_err = reader.read("!Q")[0]
2466 obj.collisions = reader.read("!Q")[0]
2467 obj.duration_sec = reader.read("!L")[0]
2468 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002469 return obj
2470
2471 def __eq__(self, other):
2472 if type(self) != type(other): return False
2473 if self.port_no != other.port_no: return False
2474 if self.rx_packets != other.rx_packets: return False
2475 if self.tx_packets != other.tx_packets: return False
2476 if self.rx_bytes != other.rx_bytes: return False
2477 if self.tx_bytes != other.tx_bytes: return False
2478 if self.rx_dropped != other.rx_dropped: return False
2479 if self.tx_dropped != other.tx_dropped: return False
2480 if self.rx_errors != other.rx_errors: return False
2481 if self.tx_errors != other.tx_errors: return False
2482 if self.rx_frame_err != other.rx_frame_err: return False
2483 if self.rx_over_err != other.rx_over_err: return False
2484 if self.rx_crc_err != other.rx_crc_err: return False
2485 if self.collisions != other.collisions: return False
2486 if self.duration_sec != other.duration_sec: return False
2487 if self.duration_nsec != other.duration_nsec: return False
2488 return True
2489
Rich Lanec2ee4b82013-04-24 17:12:38 -07002490 def pretty_print(self, q):
2491 q.text("port_stats_entry {")
2492 with q.group():
2493 with q.indent(2):
2494 q.breakable()
2495 q.text("port_no = ");
2496 q.text(util.pretty_port(self.port_no))
2497 q.text(","); q.breakable()
2498 q.text("rx_packets = ");
2499 q.text("%#x" % self.rx_packets)
2500 q.text(","); q.breakable()
2501 q.text("tx_packets = ");
2502 q.text("%#x" % self.tx_packets)
2503 q.text(","); q.breakable()
2504 q.text("rx_bytes = ");
2505 q.text("%#x" % self.rx_bytes)
2506 q.text(","); q.breakable()
2507 q.text("tx_bytes = ");
2508 q.text("%#x" % self.tx_bytes)
2509 q.text(","); q.breakable()
2510 q.text("rx_dropped = ");
2511 q.text("%#x" % self.rx_dropped)
2512 q.text(","); q.breakable()
2513 q.text("tx_dropped = ");
2514 q.text("%#x" % self.tx_dropped)
2515 q.text(","); q.breakable()
2516 q.text("rx_errors = ");
2517 q.text("%#x" % self.rx_errors)
2518 q.text(","); q.breakable()
2519 q.text("tx_errors = ");
2520 q.text("%#x" % self.tx_errors)
2521 q.text(","); q.breakable()
2522 q.text("rx_frame_err = ");
2523 q.text("%#x" % self.rx_frame_err)
2524 q.text(","); q.breakable()
2525 q.text("rx_over_err = ");
2526 q.text("%#x" % self.rx_over_err)
2527 q.text(","); q.breakable()
2528 q.text("rx_crc_err = ");
2529 q.text("%#x" % self.rx_crc_err)
2530 q.text(","); q.breakable()
2531 q.text("collisions = ");
2532 q.text("%#x" % self.collisions)
2533 q.text(","); q.breakable()
2534 q.text("duration_sec = ");
2535 q.text("%#x" % self.duration_sec)
2536 q.text(","); q.breakable()
2537 q.text("duration_nsec = ");
2538 q.text("%#x" % self.duration_nsec)
2539 q.breakable()
2540 q.text('}')
2541
Rich Lane7dcdf022013-12-11 14:45:27 -08002542
2543class queue_prop(loxi.OFObject):
2544 subtypes = {}
2545
Rich Lane95f7fc92014-01-27 17:08:16 -08002546
2547 def __init__(self, type=None):
2548 if type != None:
2549 self.type = type
2550 else:
2551 self.type = 0
2552 return
2553
2554 def pack(self):
2555 packed = []
2556 packed.append(struct.pack("!H", self.type))
2557 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2558 packed.append('\x00' * 4)
2559 length = sum([len(x) for x in packed])
2560 packed[1] = struct.pack("!H", length)
2561 return ''.join(packed)
2562
Rich Lane7dcdf022013-12-11 14:45:27 -08002563 @staticmethod
2564 def unpack(reader):
2565 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -08002566 subclass = queue_prop.subtypes.get(subtype)
2567 if subclass:
2568 return subclass.unpack(reader)
2569
2570 obj = queue_prop()
2571 obj.type = reader.read("!H")[0]
2572 _len = reader.read("!H")[0]
2573 orig_reader = reader
2574 reader = orig_reader.slice(_len - (2 + 2))
2575 reader.skip(4)
2576 return obj
2577
2578 def __eq__(self, other):
2579 if type(self) != type(other): return False
2580 if self.type != other.type: return False
2581 return True
2582
2583 def pretty_print(self, q):
2584 q.text("queue_prop {")
2585 with q.group():
2586 with q.indent(2):
2587 q.breakable()
2588 q.breakable()
2589 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002590
2591
2592class queue_prop_experimenter(queue_prop):
2593 subtypes = {}
2594
Rich Lane95f7fc92014-01-27 17:08:16 -08002595 type = 65535
2596
2597 def __init__(self, experimenter=None, data=None):
2598 if experimenter != None:
2599 self.experimenter = experimenter
2600 else:
2601 self.experimenter = 0
2602 if data != None:
2603 self.data = data
2604 else:
2605 self.data = ''
2606 return
2607
2608 def pack(self):
2609 packed = []
2610 packed.append(struct.pack("!H", self.type))
2611 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2612 packed.append('\x00' * 4)
2613 packed.append(struct.pack("!L", self.experimenter))
2614 packed.append('\x00' * 4)
2615 packed.append(self.data)
2616 length = sum([len(x) for x in packed])
2617 packed[1] = struct.pack("!H", length)
2618 return ''.join(packed)
2619
Rich Lane7dcdf022013-12-11 14:45:27 -08002620 @staticmethod
2621 def unpack(reader):
2622 subtype, = reader.peek('!L', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -08002623 subclass = queue_prop_experimenter.subtypes.get(subtype)
2624 if subclass:
2625 return subclass.unpack(reader)
2626
2627 obj = queue_prop_experimenter()
2628 _type = reader.read("!H")[0]
2629 assert(_type == 65535)
2630 _len = reader.read("!H")[0]
2631 orig_reader = reader
2632 reader = orig_reader.slice(_len - (2 + 2))
2633 reader.skip(4)
2634 obj.experimenter = reader.read("!L")[0]
2635 reader.skip(4)
2636 obj.data = str(reader.read_all())
2637 return obj
2638
2639 def __eq__(self, other):
2640 if type(self) != type(other): return False
2641 if self.experimenter != other.experimenter: return False
2642 if self.data != other.data: return False
2643 return True
2644
2645 def pretty_print(self, q):
2646 q.text("queue_prop_experimenter {")
2647 with q.group():
2648 with q.indent(2):
2649 q.breakable()
2650 q.text("data = ");
2651 q.pp(self.data)
2652 q.breakable()
2653 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002654
2655queue_prop.subtypes[65535] = queue_prop_experimenter
2656
2657class queue_prop_max_rate(queue_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002658 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07002659
2660 def __init__(self, rate=None):
2661 if rate != None:
2662 self.rate = rate
2663 else:
2664 self.rate = 0
2665 return
2666
2667 def pack(self):
2668 packed = []
2669 packed.append(struct.pack("!H", self.type))
2670 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2671 packed.append('\x00' * 4)
2672 packed.append(struct.pack("!H", self.rate))
2673 packed.append('\x00' * 6)
2674 length = sum([len(x) for x in packed])
2675 packed[1] = struct.pack("!H", length)
2676 return ''.join(packed)
2677
2678 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002679 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002680 obj = queue_prop_max_rate()
Dan Talaycof6202252013-07-02 01:00:29 -07002681 _type = reader.read("!H")[0]
2682 assert(_type == 2)
2683 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002684 orig_reader = reader
2685 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002686 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07002687 obj.rate = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002688 reader.skip(6)
2689 return obj
2690
2691 def __eq__(self, other):
2692 if type(self) != type(other): return False
2693 if self.rate != other.rate: return False
2694 return True
2695
Rich Lanec2ee4b82013-04-24 17:12:38 -07002696 def pretty_print(self, q):
2697 q.text("queue_prop_max_rate {")
2698 with q.group():
2699 with q.indent(2):
2700 q.breakable()
2701 q.text("rate = ");
2702 q.text("%#x" % self.rate)
2703 q.breakable()
2704 q.text('}')
2705
Rich Lane7dcdf022013-12-11 14:45:27 -08002706queue_prop.subtypes[2] = queue_prop_max_rate
2707
2708class queue_prop_min_rate(queue_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002709 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07002710
2711 def __init__(self, rate=None):
2712 if rate != None:
2713 self.rate = rate
2714 else:
2715 self.rate = 0
2716 return
2717
2718 def pack(self):
2719 packed = []
2720 packed.append(struct.pack("!H", self.type))
2721 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2722 packed.append('\x00' * 4)
2723 packed.append(struct.pack("!H", self.rate))
2724 packed.append('\x00' * 6)
2725 length = sum([len(x) for x in packed])
2726 packed[1] = struct.pack("!H", length)
2727 return ''.join(packed)
2728
2729 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002730 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002731 obj = queue_prop_min_rate()
Dan Talaycof6202252013-07-02 01:00:29 -07002732 _type = reader.read("!H")[0]
2733 assert(_type == 1)
2734 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002735 orig_reader = reader
2736 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002737 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07002738 obj.rate = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002739 reader.skip(6)
2740 return obj
2741
2742 def __eq__(self, other):
2743 if type(self) != type(other): return False
2744 if self.rate != other.rate: return False
2745 return True
2746
Rich Lanec2ee4b82013-04-24 17:12:38 -07002747 def pretty_print(self, q):
2748 q.text("queue_prop_min_rate {")
2749 with q.group():
2750 with q.indent(2):
2751 q.breakable()
2752 q.text("rate = ");
2753 q.text("%#x" % self.rate)
2754 q.breakable()
2755 q.text('}')
2756
Rich Lane7dcdf022013-12-11 14:45:27 -08002757queue_prop.subtypes[1] = queue_prop_min_rate
2758
2759class queue_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002760
2761 def __init__(self, port_no=None, queue_id=None, tx_bytes=None, tx_packets=None, tx_errors=None, duration_sec=None, duration_nsec=None):
2762 if port_no != None:
2763 self.port_no = port_no
2764 else:
2765 self.port_no = 0
2766 if queue_id != None:
2767 self.queue_id = queue_id
2768 else:
2769 self.queue_id = 0
2770 if tx_bytes != None:
2771 self.tx_bytes = tx_bytes
2772 else:
2773 self.tx_bytes = 0
2774 if tx_packets != None:
2775 self.tx_packets = tx_packets
2776 else:
2777 self.tx_packets = 0
2778 if tx_errors != None:
2779 self.tx_errors = tx_errors
2780 else:
2781 self.tx_errors = 0
2782 if duration_sec != None:
2783 self.duration_sec = duration_sec
2784 else:
2785 self.duration_sec = 0
2786 if duration_nsec != None:
2787 self.duration_nsec = duration_nsec
2788 else:
2789 self.duration_nsec = 0
2790 return
2791
2792 def pack(self):
2793 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07002794 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002795 packed.append(struct.pack("!L", self.queue_id))
2796 packed.append(struct.pack("!Q", self.tx_bytes))
2797 packed.append(struct.pack("!Q", self.tx_packets))
2798 packed.append(struct.pack("!Q", self.tx_errors))
2799 packed.append(struct.pack("!L", self.duration_sec))
2800 packed.append(struct.pack("!L", self.duration_nsec))
2801 return ''.join(packed)
2802
2803 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002804 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002805 obj = queue_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07002806 obj.port_no = util.unpack_port_no(reader)
2807 obj.queue_id = reader.read("!L")[0]
2808 obj.tx_bytes = reader.read("!Q")[0]
2809 obj.tx_packets = reader.read("!Q")[0]
2810 obj.tx_errors = reader.read("!Q")[0]
2811 obj.duration_sec = reader.read("!L")[0]
2812 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002813 return obj
2814
2815 def __eq__(self, other):
2816 if type(self) != type(other): return False
2817 if self.port_no != other.port_no: return False
2818 if self.queue_id != other.queue_id: return False
2819 if self.tx_bytes != other.tx_bytes: return False
2820 if self.tx_packets != other.tx_packets: return False
2821 if self.tx_errors != other.tx_errors: return False
2822 if self.duration_sec != other.duration_sec: return False
2823 if self.duration_nsec != other.duration_nsec: return False
2824 return True
2825
Rich Lanec2ee4b82013-04-24 17:12:38 -07002826 def pretty_print(self, q):
2827 q.text("queue_stats_entry {")
2828 with q.group():
2829 with q.indent(2):
2830 q.breakable()
2831 q.text("port_no = ");
2832 q.text(util.pretty_port(self.port_no))
2833 q.text(","); q.breakable()
2834 q.text("queue_id = ");
2835 q.text("%#x" % self.queue_id)
2836 q.text(","); q.breakable()
2837 q.text("tx_bytes = ");
2838 q.text("%#x" % self.tx_bytes)
2839 q.text(","); q.breakable()
2840 q.text("tx_packets = ");
2841 q.text("%#x" % self.tx_packets)
2842 q.text(","); q.breakable()
2843 q.text("tx_errors = ");
2844 q.text("%#x" % self.tx_errors)
2845 q.text(","); q.breakable()
2846 q.text("duration_sec = ");
2847 q.text("%#x" % self.duration_sec)
2848 q.text(","); q.breakable()
2849 q.text("duration_nsec = ");
2850 q.text("%#x" % self.duration_nsec)
2851 q.breakable()
2852 q.text('}')
2853
Rich Lane7dcdf022013-12-11 14:45:27 -08002854
2855class table_feature_prop(loxi.OFObject):
2856 subtypes = {}
2857
Rich Lane95f7fc92014-01-27 17:08:16 -08002858
2859 def __init__(self, type=None):
2860 if type != None:
2861 self.type = type
2862 else:
2863 self.type = 0
2864 return
2865
2866 def pack(self):
2867 packed = []
2868 packed.append(struct.pack("!H", self.type))
2869 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
2870 length = sum([len(x) for x in packed])
2871 packed[1] = struct.pack("!H", length)
2872 return ''.join(packed)
2873
Rich Lane7dcdf022013-12-11 14:45:27 -08002874 @staticmethod
2875 def unpack(reader):
2876 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -08002877 subclass = table_feature_prop.subtypes.get(subtype)
2878 if subclass:
2879 return subclass.unpack(reader)
2880
2881 obj = table_feature_prop()
2882 obj.type = reader.read("!H")[0]
2883 _length = reader.read("!H")[0]
2884 orig_reader = reader
2885 reader = orig_reader.slice(_length - (2 + 2))
2886 return obj
2887
2888 def __eq__(self, other):
2889 if type(self) != type(other): return False
2890 if self.type != other.type: return False
2891 return True
2892
2893 def pretty_print(self, q):
2894 q.text("table_feature_prop {")
2895 with q.group():
2896 with q.indent(2):
2897 q.breakable()
2898 q.breakable()
2899 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002900
2901
2902class table_feature_prop_apply_actions(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002903 type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07002904
Dan Talaycof6202252013-07-02 01:00:29 -07002905 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002906 if action_ids != None:
2907 self.action_ids = action_ids
2908 else:
2909 self.action_ids = []
2910 return
2911
2912 def pack(self):
2913 packed = []
2914 packed.append(struct.pack("!H", self.type))
2915 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002916 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002917 length = sum([len(x) for x in packed])
2918 packed[1] = struct.pack("!H", length)
2919 return ''.join(packed)
2920
2921 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002922 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002923 obj = table_feature_prop_apply_actions()
Dan Talaycof6202252013-07-02 01:00:29 -07002924 _type = reader.read("!H")[0]
2925 assert(_type == 6)
2926 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002927 orig_reader = reader
2928 reader = orig_reader.slice(_length - (2 + 2))
2929 obj.action_ids = loxi.generic_util.unpack_list(reader, action_id.action_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002930 return obj
2931
2932 def __eq__(self, other):
2933 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002934 if self.action_ids != other.action_ids: return False
2935 return True
2936
Rich Lanec2ee4b82013-04-24 17:12:38 -07002937 def pretty_print(self, q):
2938 q.text("table_feature_prop_apply_actions {")
2939 with q.group():
2940 with q.indent(2):
2941 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002942 q.text("action_ids = ");
2943 q.pp(self.action_ids)
2944 q.breakable()
2945 q.text('}')
2946
Rich Lane7dcdf022013-12-11 14:45:27 -08002947table_feature_prop.subtypes[6] = table_feature_prop_apply_actions
2948
2949class table_feature_prop_apply_actions_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002950 type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07002951
Dan Talaycof6202252013-07-02 01:00:29 -07002952 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002953 if action_ids != None:
2954 self.action_ids = action_ids
2955 else:
2956 self.action_ids = []
2957 return
2958
2959 def pack(self):
2960 packed = []
2961 packed.append(struct.pack("!H", self.type))
2962 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002963 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002964 length = sum([len(x) for x in packed])
2965 packed[1] = struct.pack("!H", length)
2966 return ''.join(packed)
2967
2968 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002969 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002970 obj = table_feature_prop_apply_actions_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07002971 _type = reader.read("!H")[0]
2972 assert(_type == 7)
2973 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002974 orig_reader = reader
2975 reader = orig_reader.slice(_length - (2 + 2))
2976 obj.action_ids = loxi.generic_util.unpack_list(reader, action_id.action_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002977 return obj
2978
2979 def __eq__(self, other):
2980 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002981 if self.action_ids != other.action_ids: return False
2982 return True
2983
Rich Lanec2ee4b82013-04-24 17:12:38 -07002984 def pretty_print(self, q):
2985 q.text("table_feature_prop_apply_actions_miss {")
2986 with q.group():
2987 with q.indent(2):
2988 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002989 q.text("action_ids = ");
2990 q.pp(self.action_ids)
2991 q.breakable()
2992 q.text('}')
2993
Rich Lane7dcdf022013-12-11 14:45:27 -08002994table_feature_prop.subtypes[7] = table_feature_prop_apply_actions_miss
2995
2996class table_feature_prop_apply_setfield(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002997 type = 14
Rich Lanec2ee4b82013-04-24 17:12:38 -07002998
Dan Talaycof6202252013-07-02 01:00:29 -07002999 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003000 if oxm_ids != None:
3001 self.oxm_ids = oxm_ids
3002 else:
3003 self.oxm_ids = []
3004 return
3005
3006 def pack(self):
3007 packed = []
3008 packed.append(struct.pack("!H", self.type))
3009 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003010 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003011 length = sum([len(x) for x in packed])
3012 packed[1] = struct.pack("!H", length)
3013 return ''.join(packed)
3014
3015 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003016 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003017 obj = table_feature_prop_apply_setfield()
Dan Talaycof6202252013-07-02 01:00:29 -07003018 _type = reader.read("!H")[0]
3019 assert(_type == 14)
3020 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003021 orig_reader = reader
3022 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003023 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
3024 return obj
3025
3026 def __eq__(self, other):
3027 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003028 if self.oxm_ids != other.oxm_ids: return False
3029 return True
3030
Rich Lanec2ee4b82013-04-24 17:12:38 -07003031 def pretty_print(self, q):
3032 q.text("table_feature_prop_apply_setfield {")
3033 with q.group():
3034 with q.indent(2):
3035 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003036 q.text("oxm_ids = ");
3037 q.pp(self.oxm_ids)
3038 q.breakable()
3039 q.text('}')
3040
Rich Lane7dcdf022013-12-11 14:45:27 -08003041table_feature_prop.subtypes[14] = table_feature_prop_apply_setfield
3042
3043class table_feature_prop_apply_setfield_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003044 type = 15
Rich Lanec2ee4b82013-04-24 17:12:38 -07003045
Dan Talaycof6202252013-07-02 01:00:29 -07003046 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003047 if oxm_ids != None:
3048 self.oxm_ids = oxm_ids
3049 else:
3050 self.oxm_ids = []
3051 return
3052
3053 def pack(self):
3054 packed = []
3055 packed.append(struct.pack("!H", self.type))
3056 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003057 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003058 length = sum([len(x) for x in packed])
3059 packed[1] = struct.pack("!H", length)
3060 return ''.join(packed)
3061
3062 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003063 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003064 obj = table_feature_prop_apply_setfield_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07003065 _type = reader.read("!H")[0]
3066 assert(_type == 15)
3067 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003068 orig_reader = reader
3069 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003070 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
3071 return obj
3072
3073 def __eq__(self, other):
3074 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003075 if self.oxm_ids != other.oxm_ids: return False
3076 return True
3077
Rich Lanec2ee4b82013-04-24 17:12:38 -07003078 def pretty_print(self, q):
3079 q.text("table_feature_prop_apply_setfield_miss {")
3080 with q.group():
3081 with q.indent(2):
3082 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003083 q.text("oxm_ids = ");
3084 q.pp(self.oxm_ids)
3085 q.breakable()
3086 q.text('}')
3087
Rich Lane7dcdf022013-12-11 14:45:27 -08003088table_feature_prop.subtypes[15] = table_feature_prop_apply_setfield_miss
3089
3090class table_feature_prop_experimenter(table_feature_prop):
Rich Lane9ec3fca2014-02-26 16:22:56 -08003091 type = 65534
Rich Lanec2ee4b82013-04-24 17:12:38 -07003092
Dan Talaycof6202252013-07-02 01:00:29 -07003093 def __init__(self, experimenter=None, subtype=None, experimenter_data=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003094 if experimenter != None:
3095 self.experimenter = experimenter
3096 else:
3097 self.experimenter = 0
3098 if subtype != None:
3099 self.subtype = subtype
3100 else:
3101 self.subtype = 0
3102 if experimenter_data != None:
3103 self.experimenter_data = experimenter_data
3104 else:
Dan Talaycof6202252013-07-02 01:00:29 -07003105 self.experimenter_data = ''
Rich Lanec2ee4b82013-04-24 17:12:38 -07003106 return
3107
3108 def pack(self):
3109 packed = []
3110 packed.append(struct.pack("!H", self.type))
3111 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
3112 packed.append(struct.pack("!L", self.experimenter))
3113 packed.append(struct.pack("!L", self.subtype))
3114 packed.append(self.experimenter_data)
3115 length = sum([len(x) for x in packed])
3116 packed[1] = struct.pack("!H", length)
3117 return ''.join(packed)
3118
3119 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003120 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003121 obj = table_feature_prop_experimenter()
Dan Talaycof6202252013-07-02 01:00:29 -07003122 _type = reader.read("!H")[0]
Rich Lane9ec3fca2014-02-26 16:22:56 -08003123 assert(_type == 65534)
Dan Talaycof6202252013-07-02 01:00:29 -07003124 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003125 orig_reader = reader
3126 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003127 obj.experimenter = reader.read("!L")[0]
3128 obj.subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003129 obj.experimenter_data = str(reader.read_all())
3130 return obj
3131
3132 def __eq__(self, other):
3133 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003134 if self.experimenter != other.experimenter: return False
3135 if self.subtype != other.subtype: return False
3136 if self.experimenter_data != other.experimenter_data: return False
3137 return True
3138
Rich Lanec2ee4b82013-04-24 17:12:38 -07003139 def pretty_print(self, q):
3140 q.text("table_feature_prop_experimenter {")
3141 with q.group():
3142 with q.indent(2):
3143 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003144 q.text("experimenter = ");
3145 q.text("%#x" % self.experimenter)
3146 q.text(","); q.breakable()
3147 q.text("subtype = ");
3148 q.text("%#x" % self.subtype)
3149 q.text(","); q.breakable()
3150 q.text("experimenter_data = ");
3151 q.pp(self.experimenter_data)
3152 q.breakable()
3153 q.text('}')
3154
Rich Lane9ec3fca2014-02-26 16:22:56 -08003155table_feature_prop.subtypes[65534] = table_feature_prop_experimenter
3156
3157class table_feature_prop_experimenter_miss(table_feature_prop):
3158 type = 65535
3159
3160 def __init__(self, experimenter=None, subtype=None, experimenter_data=None):
3161 if experimenter != None:
3162 self.experimenter = experimenter
3163 else:
3164 self.experimenter = 0
3165 if subtype != None:
3166 self.subtype = subtype
3167 else:
3168 self.subtype = 0
3169 if experimenter_data != None:
3170 self.experimenter_data = experimenter_data
3171 else:
3172 self.experimenter_data = ''
3173 return
3174
3175 def pack(self):
3176 packed = []
3177 packed.append(struct.pack("!H", self.type))
3178 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
3179 packed.append(struct.pack("!L", self.experimenter))
3180 packed.append(struct.pack("!L", self.subtype))
3181 packed.append(self.experimenter_data)
3182 length = sum([len(x) for x in packed])
3183 packed[1] = struct.pack("!H", length)
3184 return ''.join(packed)
3185
3186 @staticmethod
3187 def unpack(reader):
3188 obj = table_feature_prop_experimenter_miss()
3189 _type = reader.read("!H")[0]
3190 assert(_type == 65535)
3191 _length = reader.read("!H")[0]
3192 orig_reader = reader
3193 reader = orig_reader.slice(_length - (2 + 2))
3194 obj.experimenter = reader.read("!L")[0]
3195 obj.subtype = reader.read("!L")[0]
3196 obj.experimenter_data = str(reader.read_all())
3197 return obj
3198
3199 def __eq__(self, other):
3200 if type(self) != type(other): return False
3201 if self.experimenter != other.experimenter: return False
3202 if self.subtype != other.subtype: return False
3203 if self.experimenter_data != other.experimenter_data: return False
3204 return True
3205
3206 def pretty_print(self, q):
3207 q.text("table_feature_prop_experimenter_miss {")
3208 with q.group():
3209 with q.indent(2):
3210 q.breakable()
3211 q.text("experimenter = ");
3212 q.text("%#x" % self.experimenter)
3213 q.text(","); q.breakable()
3214 q.text("subtype = ");
3215 q.text("%#x" % self.subtype)
3216 q.text(","); q.breakable()
3217 q.text("experimenter_data = ");
3218 q.pp(self.experimenter_data)
3219 q.breakable()
3220 q.text('}')
3221
3222table_feature_prop.subtypes[65535] = table_feature_prop_experimenter_miss
Rich Lane7dcdf022013-12-11 14:45:27 -08003223
3224class table_feature_prop_instructions(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003225 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07003226
Dan Talaycof6202252013-07-02 01:00:29 -07003227 def __init__(self, instruction_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003228 if instruction_ids != None:
3229 self.instruction_ids = instruction_ids
3230 else:
3231 self.instruction_ids = []
3232 return
3233
3234 def pack(self):
3235 packed = []
3236 packed.append(struct.pack("!H", self.type))
3237 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003238 packed.append(loxi.generic_util.pack_list(self.instruction_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003239 length = sum([len(x) for x in packed])
3240 packed[1] = struct.pack("!H", length)
3241 return ''.join(packed)
3242
3243 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003244 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003245 obj = table_feature_prop_instructions()
Dan Talaycof6202252013-07-02 01:00:29 -07003246 _type = reader.read("!H")[0]
3247 assert(_type == 0)
3248 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003249 orig_reader = reader
3250 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec0d05d12014-03-11 18:02:24 -07003251 obj.instruction_ids = loxi.generic_util.unpack_list(reader, instruction_id.instruction_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003252 return obj
3253
3254 def __eq__(self, other):
3255 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003256 if self.instruction_ids != other.instruction_ids: return False
3257 return True
3258
Rich Lanec2ee4b82013-04-24 17:12:38 -07003259 def pretty_print(self, q):
3260 q.text("table_feature_prop_instructions {")
3261 with q.group():
3262 with q.indent(2):
3263 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003264 q.text("instruction_ids = ");
3265 q.pp(self.instruction_ids)
3266 q.breakable()
3267 q.text('}')
3268
Rich Lane7dcdf022013-12-11 14:45:27 -08003269table_feature_prop.subtypes[0] = table_feature_prop_instructions
3270
3271class table_feature_prop_instructions_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003272 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07003273
Dan Talaycof6202252013-07-02 01:00:29 -07003274 def __init__(self, instruction_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003275 if instruction_ids != None:
3276 self.instruction_ids = instruction_ids
3277 else:
3278 self.instruction_ids = []
3279 return
3280
3281 def pack(self):
3282 packed = []
3283 packed.append(struct.pack("!H", self.type))
3284 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003285 packed.append(loxi.generic_util.pack_list(self.instruction_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003286 length = sum([len(x) for x in packed])
3287 packed[1] = struct.pack("!H", length)
3288 return ''.join(packed)
3289
3290 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003291 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003292 obj = table_feature_prop_instructions_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07003293 _type = reader.read("!H")[0]
3294 assert(_type == 1)
3295 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003296 orig_reader = reader
3297 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec0d05d12014-03-11 18:02:24 -07003298 obj.instruction_ids = loxi.generic_util.unpack_list(reader, instruction_id.instruction_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003299 return obj
3300
3301 def __eq__(self, other):
3302 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003303 if self.instruction_ids != other.instruction_ids: return False
3304 return True
3305
Rich Lanec2ee4b82013-04-24 17:12:38 -07003306 def pretty_print(self, q):
3307 q.text("table_feature_prop_instructions_miss {")
3308 with q.group():
3309 with q.indent(2):
3310 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003311 q.text("instruction_ids = ");
3312 q.pp(self.instruction_ids)
3313 q.breakable()
3314 q.text('}')
3315
Rich Lane7dcdf022013-12-11 14:45:27 -08003316table_feature_prop.subtypes[1] = table_feature_prop_instructions_miss
3317
3318class table_feature_prop_match(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003319 type = 8
Rich Lanec2ee4b82013-04-24 17:12:38 -07003320
Dan Talaycof6202252013-07-02 01:00:29 -07003321 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003322 if oxm_ids != None:
3323 self.oxm_ids = oxm_ids
3324 else:
3325 self.oxm_ids = []
3326 return
3327
3328 def pack(self):
3329 packed = []
3330 packed.append(struct.pack("!H", self.type))
3331 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003332 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003333 length = sum([len(x) for x in packed])
3334 packed[1] = struct.pack("!H", length)
3335 return ''.join(packed)
3336
3337 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003338 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003339 obj = table_feature_prop_match()
Dan Talaycof6202252013-07-02 01:00:29 -07003340 _type = reader.read("!H")[0]
3341 assert(_type == 8)
3342 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003343 orig_reader = reader
3344 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003345 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
3346 return obj
3347
3348 def __eq__(self, other):
3349 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003350 if self.oxm_ids != other.oxm_ids: return False
3351 return True
3352
Rich Lanec2ee4b82013-04-24 17:12:38 -07003353 def pretty_print(self, q):
3354 q.text("table_feature_prop_match {")
3355 with q.group():
3356 with q.indent(2):
3357 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003358 q.text("oxm_ids = ");
3359 q.pp(self.oxm_ids)
3360 q.breakable()
3361 q.text('}')
3362
Rich Lane7dcdf022013-12-11 14:45:27 -08003363table_feature_prop.subtypes[8] = table_feature_prop_match
3364
3365class table_feature_prop_next_tables(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003366 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07003367
Dan Talaycof6202252013-07-02 01:00:29 -07003368 def __init__(self, next_table_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003369 if next_table_ids != None:
3370 self.next_table_ids = next_table_ids
3371 else:
3372 self.next_table_ids = []
3373 return
3374
3375 def pack(self):
3376 packed = []
3377 packed.append(struct.pack("!H", self.type))
3378 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003379 packed.append(loxi.generic_util.pack_list(self.next_table_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003380 length = sum([len(x) for x in packed])
3381 packed[1] = struct.pack("!H", length)
3382 return ''.join(packed)
3383
3384 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003385 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003386 obj = table_feature_prop_next_tables()
Dan Talaycof6202252013-07-02 01:00:29 -07003387 _type = reader.read("!H")[0]
3388 assert(_type == 2)
3389 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003390 orig_reader = reader
3391 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003392 obj.next_table_ids = loxi.generic_util.unpack_list(reader, common.uint8.unpack)
3393 return obj
3394
3395 def __eq__(self, other):
3396 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003397 if self.next_table_ids != other.next_table_ids: return False
3398 return True
3399
Rich Lanec2ee4b82013-04-24 17:12:38 -07003400 def pretty_print(self, q):
3401 q.text("table_feature_prop_next_tables {")
3402 with q.group():
3403 with q.indent(2):
3404 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003405 q.text("next_table_ids = ");
3406 q.pp(self.next_table_ids)
3407 q.breakable()
3408 q.text('}')
3409
Rich Lane7dcdf022013-12-11 14:45:27 -08003410table_feature_prop.subtypes[2] = table_feature_prop_next_tables
3411
3412class table_feature_prop_next_tables_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003413 type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07003414
Dan Talaycof6202252013-07-02 01:00:29 -07003415 def __init__(self, next_table_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003416 if next_table_ids != None:
3417 self.next_table_ids = next_table_ids
3418 else:
3419 self.next_table_ids = []
3420 return
3421
3422 def pack(self):
3423 packed = []
3424 packed.append(struct.pack("!H", self.type))
3425 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003426 packed.append(loxi.generic_util.pack_list(self.next_table_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003427 length = sum([len(x) for x in packed])
3428 packed[1] = struct.pack("!H", length)
3429 return ''.join(packed)
3430
3431 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003432 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003433 obj = table_feature_prop_next_tables_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07003434 _type = reader.read("!H")[0]
3435 assert(_type == 3)
3436 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003437 orig_reader = reader
3438 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003439 obj.next_table_ids = loxi.generic_util.unpack_list(reader, common.uint8.unpack)
3440 return obj
3441
3442 def __eq__(self, other):
3443 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003444 if self.next_table_ids != other.next_table_ids: return False
3445 return True
3446
Rich Lanec2ee4b82013-04-24 17:12:38 -07003447 def pretty_print(self, q):
3448 q.text("table_feature_prop_next_tables_miss {")
3449 with q.group():
3450 with q.indent(2):
3451 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003452 q.text("next_table_ids = ");
3453 q.pp(self.next_table_ids)
3454 q.breakable()
3455 q.text('}')
3456
Rich Lane7dcdf022013-12-11 14:45:27 -08003457table_feature_prop.subtypes[3] = table_feature_prop_next_tables_miss
3458
3459class table_feature_prop_wildcards(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003460 type = 10
Rich Lanec2ee4b82013-04-24 17:12:38 -07003461
Dan Talaycof6202252013-07-02 01:00:29 -07003462 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003463 if oxm_ids != None:
3464 self.oxm_ids = oxm_ids
3465 else:
3466 self.oxm_ids = []
3467 return
3468
3469 def pack(self):
3470 packed = []
3471 packed.append(struct.pack("!H", self.type))
3472 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003473 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003474 length = sum([len(x) for x in packed])
3475 packed[1] = struct.pack("!H", length)
3476 return ''.join(packed)
3477
3478 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003479 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003480 obj = table_feature_prop_wildcards()
Dan Talaycof6202252013-07-02 01:00:29 -07003481 _type = reader.read("!H")[0]
3482 assert(_type == 10)
3483 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003484 orig_reader = reader
3485 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003486 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
3487 return obj
3488
3489 def __eq__(self, other):
3490 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003491 if self.oxm_ids != other.oxm_ids: return False
3492 return True
3493
Rich Lanec2ee4b82013-04-24 17:12:38 -07003494 def pretty_print(self, q):
3495 q.text("table_feature_prop_wildcards {")
3496 with q.group():
3497 with q.indent(2):
3498 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003499 q.text("oxm_ids = ");
3500 q.pp(self.oxm_ids)
3501 q.breakable()
3502 q.text('}')
3503
Rich Lane7dcdf022013-12-11 14:45:27 -08003504table_feature_prop.subtypes[10] = table_feature_prop_wildcards
3505
3506class table_feature_prop_write_actions(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003507 type = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07003508
Dan Talaycof6202252013-07-02 01:00:29 -07003509 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003510 if action_ids != None:
3511 self.action_ids = action_ids
3512 else:
3513 self.action_ids = []
3514 return
3515
3516 def pack(self):
3517 packed = []
3518 packed.append(struct.pack("!H", self.type))
3519 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003520 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003521 length = sum([len(x) for x in packed])
3522 packed[1] = struct.pack("!H", length)
3523 return ''.join(packed)
3524
3525 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003526 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003527 obj = table_feature_prop_write_actions()
Dan Talaycof6202252013-07-02 01:00:29 -07003528 _type = reader.read("!H")[0]
3529 assert(_type == 4)
3530 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003531 orig_reader = reader
3532 reader = orig_reader.slice(_length - (2 + 2))
3533 obj.action_ids = loxi.generic_util.unpack_list(reader, action_id.action_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003534 return obj
3535
3536 def __eq__(self, other):
3537 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003538 if self.action_ids != other.action_ids: return False
3539 return True
3540
Rich Lanec2ee4b82013-04-24 17:12:38 -07003541 def pretty_print(self, q):
3542 q.text("table_feature_prop_write_actions {")
3543 with q.group():
3544 with q.indent(2):
3545 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003546 q.text("action_ids = ");
3547 q.pp(self.action_ids)
3548 q.breakable()
3549 q.text('}')
3550
Rich Lane7dcdf022013-12-11 14:45:27 -08003551table_feature_prop.subtypes[4] = table_feature_prop_write_actions
3552
3553class table_feature_prop_write_actions_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003554 type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07003555
Dan Talaycof6202252013-07-02 01:00:29 -07003556 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003557 if action_ids != None:
3558 self.action_ids = action_ids
3559 else:
3560 self.action_ids = []
3561 return
3562
3563 def pack(self):
3564 packed = []
3565 packed.append(struct.pack("!H", self.type))
3566 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003567 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003568 length = sum([len(x) for x in packed])
3569 packed[1] = struct.pack("!H", length)
3570 return ''.join(packed)
3571
3572 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003573 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003574 obj = table_feature_prop_write_actions_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07003575 _type = reader.read("!H")[0]
3576 assert(_type == 5)
3577 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003578 orig_reader = reader
3579 reader = orig_reader.slice(_length - (2 + 2))
3580 obj.action_ids = loxi.generic_util.unpack_list(reader, action_id.action_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003581 return obj
3582
3583 def __eq__(self, other):
3584 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003585 if self.action_ids != other.action_ids: return False
3586 return True
3587
Rich Lanec2ee4b82013-04-24 17:12:38 -07003588 def pretty_print(self, q):
3589 q.text("table_feature_prop_write_actions_miss {")
3590 with q.group():
3591 with q.indent(2):
3592 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003593 q.text("action_ids = ");
3594 q.pp(self.action_ids)
3595 q.breakable()
3596 q.text('}')
3597
Rich Lane7dcdf022013-12-11 14:45:27 -08003598table_feature_prop.subtypes[5] = table_feature_prop_write_actions_miss
3599
3600class table_feature_prop_write_setfield(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003601 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -07003602
Dan Talaycof6202252013-07-02 01:00:29 -07003603 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003604 if oxm_ids != None:
3605 self.oxm_ids = oxm_ids
3606 else:
3607 self.oxm_ids = []
3608 return
3609
3610 def pack(self):
3611 packed = []
3612 packed.append(struct.pack("!H", self.type))
3613 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003614 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003615 length = sum([len(x) for x in packed])
3616 packed[1] = struct.pack("!H", length)
3617 return ''.join(packed)
3618
3619 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003620 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003621 obj = table_feature_prop_write_setfield()
Dan Talaycof6202252013-07-02 01:00:29 -07003622 _type = reader.read("!H")[0]
3623 assert(_type == 12)
3624 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003625 orig_reader = reader
3626 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003627 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
3628 return obj
3629
3630 def __eq__(self, other):
3631 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003632 if self.oxm_ids != other.oxm_ids: return False
3633 return True
3634
Rich Lanec2ee4b82013-04-24 17:12:38 -07003635 def pretty_print(self, q):
3636 q.text("table_feature_prop_write_setfield {")
3637 with q.group():
3638 with q.indent(2):
3639 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003640 q.text("oxm_ids = ");
3641 q.pp(self.oxm_ids)
3642 q.breakable()
3643 q.text('}')
3644
Rich Lane7dcdf022013-12-11 14:45:27 -08003645table_feature_prop.subtypes[12] = table_feature_prop_write_setfield
3646
3647class table_feature_prop_write_setfield_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003648 type = 13
Rich Lanec2ee4b82013-04-24 17:12:38 -07003649
Dan Talaycof6202252013-07-02 01:00:29 -07003650 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003651 if oxm_ids != None:
3652 self.oxm_ids = oxm_ids
3653 else:
3654 self.oxm_ids = []
3655 return
3656
3657 def pack(self):
3658 packed = []
3659 packed.append(struct.pack("!H", self.type))
3660 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003661 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003662 length = sum([len(x) for x in packed])
3663 packed[1] = struct.pack("!H", length)
3664 return ''.join(packed)
3665
3666 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003667 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003668 obj = table_feature_prop_write_setfield_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07003669 _type = reader.read("!H")[0]
3670 assert(_type == 13)
3671 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003672 orig_reader = reader
3673 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003674 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
3675 return obj
3676
3677 def __eq__(self, other):
3678 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003679 if self.oxm_ids != other.oxm_ids: return False
3680 return True
3681
Rich Lanec2ee4b82013-04-24 17:12:38 -07003682 def pretty_print(self, q):
3683 q.text("table_feature_prop_write_setfield_miss {")
3684 with q.group():
3685 with q.indent(2):
3686 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003687 q.text("oxm_ids = ");
3688 q.pp(self.oxm_ids)
3689 q.breakable()
3690 q.text('}')
3691
Rich Lane7dcdf022013-12-11 14:45:27 -08003692table_feature_prop.subtypes[13] = table_feature_prop_write_setfield_miss
3693
3694class table_features(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003695
3696 def __init__(self, table_id=None, name=None, metadata_match=None, metadata_write=None, config=None, max_entries=None, properties=None):
3697 if table_id != None:
3698 self.table_id = table_id
3699 else:
3700 self.table_id = 0
3701 if name != None:
3702 self.name = name
3703 else:
3704 self.name = ""
3705 if metadata_match != None:
3706 self.metadata_match = metadata_match
3707 else:
3708 self.metadata_match = 0
3709 if metadata_write != None:
3710 self.metadata_write = metadata_write
3711 else:
3712 self.metadata_write = 0
3713 if config != None:
3714 self.config = config
3715 else:
3716 self.config = 0
3717 if max_entries != None:
3718 self.max_entries = max_entries
3719 else:
3720 self.max_entries = 0
3721 if properties != None:
3722 self.properties = properties
3723 else:
3724 self.properties = []
3725 return
3726
3727 def pack(self):
3728 packed = []
3729 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
3730 packed.append(struct.pack("!B", self.table_id))
3731 packed.append('\x00' * 5)
3732 packed.append(struct.pack("!32s", self.name))
3733 packed.append(struct.pack("!Q", self.metadata_match))
3734 packed.append(struct.pack("!Q", self.metadata_write))
3735 packed.append(struct.pack("!L", self.config))
3736 packed.append(struct.pack("!L", self.max_entries))
Rich Lane7dcdf022013-12-11 14:45:27 -08003737 packed.append(loxi.generic_util.pack_list(self.properties))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003738 length = sum([len(x) for x in packed])
3739 packed[0] = struct.pack("!H", length)
3740 return ''.join(packed)
3741
3742 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003743 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003744 obj = table_features()
Dan Talaycof6202252013-07-02 01:00:29 -07003745 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003746 orig_reader = reader
3747 reader = orig_reader.slice(_length - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003748 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003749 reader.skip(5)
3750 obj.name = reader.read("!32s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -07003751 obj.metadata_match = reader.read("!Q")[0]
3752 obj.metadata_write = reader.read("!Q")[0]
3753 obj.config = reader.read("!L")[0]
3754 obj.max_entries = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003755 obj.properties = loxi.generic_util.unpack_list(reader, common.table_feature_prop.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003756 return obj
3757
3758 def __eq__(self, other):
3759 if type(self) != type(other): return False
3760 if self.table_id != other.table_id: return False
3761 if self.name != other.name: return False
3762 if self.metadata_match != other.metadata_match: return False
3763 if self.metadata_write != other.metadata_write: return False
3764 if self.config != other.config: return False
3765 if self.max_entries != other.max_entries: return False
3766 if self.properties != other.properties: return False
3767 return True
3768
Rich Lanec2ee4b82013-04-24 17:12:38 -07003769 def pretty_print(self, q):
3770 q.text("table_features {")
3771 with q.group():
3772 with q.indent(2):
3773 q.breakable()
3774 q.text("table_id = ");
3775 q.text("%#x" % self.table_id)
3776 q.text(","); q.breakable()
3777 q.text("name = ");
3778 q.pp(self.name)
3779 q.text(","); q.breakable()
3780 q.text("metadata_match = ");
3781 q.text("%#x" % self.metadata_match)
3782 q.text(","); q.breakable()
3783 q.text("metadata_write = ");
3784 q.text("%#x" % self.metadata_write)
3785 q.text(","); q.breakable()
3786 q.text("config = ");
3787 q.text("%#x" % self.config)
3788 q.text(","); q.breakable()
3789 q.text("max_entries = ");
3790 q.text("%#x" % self.max_entries)
3791 q.text(","); q.breakable()
3792 q.text("properties = ");
3793 q.pp(self.properties)
3794 q.breakable()
3795 q.text('}')
3796
Rich Lane7dcdf022013-12-11 14:45:27 -08003797
3798class table_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003799
3800 def __init__(self, table_id=None, active_count=None, lookup_count=None, matched_count=None):
3801 if table_id != None:
3802 self.table_id = table_id
3803 else:
3804 self.table_id = 0
3805 if active_count != None:
3806 self.active_count = active_count
3807 else:
3808 self.active_count = 0
3809 if lookup_count != None:
3810 self.lookup_count = lookup_count
3811 else:
3812 self.lookup_count = 0
3813 if matched_count != None:
3814 self.matched_count = matched_count
3815 else:
3816 self.matched_count = 0
3817 return
3818
3819 def pack(self):
3820 packed = []
3821 packed.append(struct.pack("!B", self.table_id))
3822 packed.append('\x00' * 3)
3823 packed.append(struct.pack("!L", self.active_count))
3824 packed.append(struct.pack("!Q", self.lookup_count))
3825 packed.append(struct.pack("!Q", self.matched_count))
3826 return ''.join(packed)
3827
3828 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003829 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003830 obj = table_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07003831 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003832 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07003833 obj.active_count = reader.read("!L")[0]
3834 obj.lookup_count = reader.read("!Q")[0]
3835 obj.matched_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003836 return obj
3837
3838 def __eq__(self, other):
3839 if type(self) != type(other): return False
3840 if self.table_id != other.table_id: return False
3841 if self.active_count != other.active_count: return False
3842 if self.lookup_count != other.lookup_count: return False
3843 if self.matched_count != other.matched_count: return False
3844 return True
3845
Rich Lanec2ee4b82013-04-24 17:12:38 -07003846 def pretty_print(self, q):
3847 q.text("table_stats_entry {")
3848 with q.group():
3849 with q.indent(2):
3850 q.breakable()
3851 q.text("table_id = ");
3852 q.text("%#x" % self.table_id)
3853 q.text(","); q.breakable()
3854 q.text("active_count = ");
3855 q.text("%#x" % self.active_count)
3856 q.text(","); q.breakable()
3857 q.text("lookup_count = ");
3858 q.text("%#x" % self.lookup_count)
3859 q.text(","); q.breakable()
3860 q.text("matched_count = ");
3861 q.text("%#x" % self.matched_count)
3862 q.breakable()
3863 q.text('}')
3864
Rich Lane7dcdf022013-12-11 14:45:27 -08003865
3866class uint32(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003867
3868 def __init__(self, value=None):
3869 if value != None:
3870 self.value = value
3871 else:
3872 self.value = 0
3873 return
3874
3875 def pack(self):
3876 packed = []
3877 packed.append(struct.pack("!L", self.value))
3878 return ''.join(packed)
3879
3880 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003881 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003882 obj = uint32()
Dan Talaycof6202252013-07-02 01:00:29 -07003883 obj.value = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003884 return obj
3885
3886 def __eq__(self, other):
3887 if type(self) != type(other): return False
3888 if self.value != other.value: return False
3889 return True
3890
Rich Lanec2ee4b82013-04-24 17:12:38 -07003891 def pretty_print(self, q):
3892 q.text("uint32 {")
3893 with q.group():
3894 with q.indent(2):
3895 q.breakable()
3896 q.text("value = ");
3897 q.text("%#x" % self.value)
3898 q.breakable()
3899 q.text('}')
3900
Rich Lane7dcdf022013-12-11 14:45:27 -08003901
3902class uint64(loxi.OFObject):
3903
3904 def __init__(self, value=None):
3905 if value != None:
3906 self.value = value
3907 else:
3908 self.value = 0
3909 return
3910
3911 def pack(self):
3912 packed = []
3913 packed.append(struct.pack("!Q", self.value))
3914 return ''.join(packed)
3915
3916 @staticmethod
3917 def unpack(reader):
3918 obj = uint64()
3919 obj.value = reader.read("!Q")[0]
3920 return obj
3921
3922 def __eq__(self, other):
3923 if type(self) != type(other): return False
3924 if self.value != other.value: return False
3925 return True
3926
3927 def pretty_print(self, q):
3928 q.text("uint64 {")
3929 with q.group():
3930 with q.indent(2):
3931 q.breakable()
3932 q.text("value = ");
3933 q.text("%#x" % self.value)
3934 q.breakable()
3935 q.text('}')
3936
3937
3938class uint8(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003939
3940 def __init__(self, value=None):
3941 if value != None:
3942 self.value = value
3943 else:
3944 self.value = 0
3945 return
3946
3947 def pack(self):
3948 packed = []
3949 packed.append(struct.pack("!B", self.value))
3950 return ''.join(packed)
3951
3952 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003953 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003954 obj = uint8()
Dan Talaycof6202252013-07-02 01:00:29 -07003955 obj.value = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003956 return obj
3957
3958 def __eq__(self, other):
3959 if type(self) != type(other): return False
3960 if self.value != other.value: return False
3961 return True
3962
Rich Lanec2ee4b82013-04-24 17:12:38 -07003963 def pretty_print(self, q):
3964 q.text("uint8 {")
3965 with q.group():
3966 with q.indent(2):
3967 q.breakable()
3968 q.text("value = ");
3969 q.text("%#x" % self.value)
3970 q.breakable()
3971 q.text('}')
3972
3973
Rich Lane7dcdf022013-12-11 14:45:27 -08003974
Rich Lanec2ee4b82013-04-24 17:12:38 -07003975match = match_v3