blob: c206d24ddb4798dbc0491c90ef148bde6d90eac5 [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
Rich Lane7dcdf022013-12-11 14:45:27 -080012import common
13import action
14import instruction
15import oxm
16import action_id
17import instruction_id
18import meter_band
Rich Lane5454b682014-01-14 17:07:36 -080019import bsn_tlv
Rich Lanec2ee4b82013-04-24 17:12:38 -070020import util
21import loxi.generic_util
22
Rich Lane5454b682014-01-14 17:07:36 -080023class bsn_controller_connection(loxi.OFObject):
24
25 def __init__(self, state=None, auxiliary_id=None, role=None, uri=None):
26 if state != None:
27 self.state = state
28 else:
29 self.state = 0
30 if auxiliary_id != None:
31 self.auxiliary_id = auxiliary_id
32 else:
33 self.auxiliary_id = 0
34 if role != None:
35 self.role = role
36 else:
37 self.role = 0
38 if uri != None:
39 self.uri = uri
40 else:
41 self.uri = ""
42 return
43
44 def pack(self):
45 packed = []
46 packed.append(struct.pack("!B", self.state))
47 packed.append(struct.pack("!B", self.auxiliary_id))
48 packed.append('\x00' * 2)
49 packed.append(struct.pack("!L", self.role))
50 packed.append(struct.pack("!256s", self.uri))
51 return ''.join(packed)
52
53 @staticmethod
54 def unpack(reader):
55 obj = bsn_controller_connection()
56 obj.state = reader.read("!B")[0]
57 obj.auxiliary_id = reader.read("!B")[0]
58 reader.skip(2)
59 obj.role = reader.read("!L")[0]
60 obj.uri = reader.read("!256s")[0].rstrip("\x00")
61 return obj
62
63 def __eq__(self, other):
64 if type(self) != type(other): return False
65 if self.state != other.state: return False
66 if self.auxiliary_id != other.auxiliary_id: return False
67 if self.role != other.role: return False
68 if self.uri != other.uri: return False
69 return True
70
71 def pretty_print(self, q):
72 q.text("bsn_controller_connection {")
73 with q.group():
74 with q.indent(2):
75 q.breakable()
76 q.text("state = ");
77 q.text("%#x" % self.state)
78 q.text(","); q.breakable()
79 q.text("auxiliary_id = ");
80 q.text("%#x" % self.auxiliary_id)
81 q.text(","); q.breakable()
82 q.text("role = ");
83 q.text("%#x" % self.role)
84 q.text(","); q.breakable()
85 q.text("uri = ");
86 q.pp(self.uri)
87 q.breakable()
88 q.text('}')
89
90
Rich Lane9ec3fca2014-02-26 16:22:56 -080091class bsn_flow_checksum_bucket_stats_entry(loxi.OFObject):
92
93 def __init__(self, checksum=None):
94 if checksum != None:
95 self.checksum = checksum
96 else:
97 self.checksum = 0
98 return
99
100 def pack(self):
101 packed = []
102 packed.append(struct.pack("!Q", self.checksum))
103 return ''.join(packed)
104
105 @staticmethod
106 def unpack(reader):
107 obj = bsn_flow_checksum_bucket_stats_entry()
108 obj.checksum = reader.read("!Q")[0]
109 return obj
110
111 def __eq__(self, other):
112 if type(self) != type(other): return False
113 if self.checksum != other.checksum: return False
114 return True
115
116 def pretty_print(self, q):
117 q.text("bsn_flow_checksum_bucket_stats_entry {")
118 with q.group():
119 with q.indent(2):
120 q.breakable()
121 q.text("checksum = ");
122 q.text("%#x" % self.checksum)
123 q.breakable()
124 q.text('}')
125
126
Rich Lane5454b682014-01-14 17:07:36 -0800127class bsn_gentable_bucket_stats_entry(loxi.OFObject):
128
129 def __init__(self, checksum=None):
130 if checksum != None:
131 self.checksum = checksum
132 else:
133 self.checksum = 0
134 return
135
136 def pack(self):
137 packed = []
138 packed.append(util.pack_checksum_128(self.checksum))
139 return ''.join(packed)
140
141 @staticmethod
142 def unpack(reader):
143 obj = bsn_gentable_bucket_stats_entry()
144 obj.checksum = util.unpack_checksum_128(reader)
145 return obj
146
147 def __eq__(self, other):
148 if type(self) != type(other): return False
149 if self.checksum != other.checksum: return False
150 return True
151
152 def pretty_print(self, q):
153 q.text("bsn_gentable_bucket_stats_entry {")
154 with q.group():
155 with q.indent(2):
156 q.breakable()
157 q.text("checksum = ");
158 q.pp(self.checksum)
159 q.breakable()
160 q.text('}')
161
162
163class bsn_gentable_desc_stats_entry(loxi.OFObject):
164
165 def __init__(self, table_id=None, name=None, buckets_size=None, max_entries=None):
166 if table_id != None:
167 self.table_id = table_id
168 else:
169 self.table_id = 0
170 if name != None:
171 self.name = name
172 else:
173 self.name = ""
174 if buckets_size != None:
175 self.buckets_size = buckets_size
176 else:
177 self.buckets_size = 0
178 if max_entries != None:
179 self.max_entries = max_entries
180 else:
181 self.max_entries = 0
182 return
183
184 def pack(self):
185 packed = []
186 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
187 packed.append(struct.pack("!H", self.table_id))
188 packed.append(struct.pack("!32s", self.name))
189 packed.append(struct.pack("!L", self.buckets_size))
190 packed.append(struct.pack("!L", self.max_entries))
191 packed.append('\x00' * 4)
192 length = sum([len(x) for x in packed])
193 packed[0] = struct.pack("!H", length)
194 return ''.join(packed)
195
196 @staticmethod
197 def unpack(reader):
198 obj = bsn_gentable_desc_stats_entry()
199 _length = reader.read("!H")[0]
200 orig_reader = reader
201 reader = orig_reader.slice(_length - (0 + 2))
202 obj.table_id = reader.read("!H")[0]
203 obj.name = reader.read("!32s")[0].rstrip("\x00")
204 obj.buckets_size = reader.read("!L")[0]
205 obj.max_entries = reader.read("!L")[0]
206 reader.skip(4)
207 return obj
208
209 def __eq__(self, other):
210 if type(self) != type(other): return False
211 if self.table_id != other.table_id: return False
212 if self.name != other.name: return False
213 if self.buckets_size != other.buckets_size: return False
214 if self.max_entries != other.max_entries: return False
215 return True
216
217 def pretty_print(self, q):
218 q.text("bsn_gentable_desc_stats_entry {")
219 with q.group():
220 with q.indent(2):
221 q.breakable()
222 q.text("table_id = ");
223 q.text("%#x" % self.table_id)
224 q.text(","); q.breakable()
225 q.text("name = ");
226 q.pp(self.name)
227 q.text(","); q.breakable()
228 q.text("buckets_size = ");
229 q.text("%#x" % self.buckets_size)
230 q.text(","); q.breakable()
231 q.text("max_entries = ");
232 q.text("%#x" % self.max_entries)
233 q.breakable()
234 q.text('}')
235
236
237class bsn_gentable_entry_desc_stats_entry(loxi.OFObject):
238
239 def __init__(self, checksum=None, key=None, value=None):
240 if checksum != None:
241 self.checksum = checksum
242 else:
243 self.checksum = 0
244 if key != None:
245 self.key = key
246 else:
247 self.key = []
248 if value != None:
249 self.value = value
250 else:
251 self.value = []
252 return
253
254 def pack(self):
255 packed = []
256 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
257 packed.append(struct.pack("!H", 0)) # placeholder for key_length at index 1
258 packed.append(util.pack_checksum_128(self.checksum))
259 packed.append(loxi.generic_util.pack_list(self.key))
260 packed[1] = struct.pack("!H", len(packed[-1]))
261 packed.append(loxi.generic_util.pack_list(self.value))
262 length = sum([len(x) for x in packed])
263 packed[0] = struct.pack("!H", length)
264 return ''.join(packed)
265
266 @staticmethod
267 def unpack(reader):
268 obj = bsn_gentable_entry_desc_stats_entry()
269 _length = reader.read("!H")[0]
270 orig_reader = reader
271 reader = orig_reader.slice(_length - (0 + 2))
272 _key_length = reader.read("!H")[0]
273 obj.checksum = util.unpack_checksum_128(reader)
274 obj.key = loxi.generic_util.unpack_list(reader.slice(_key_length), bsn_tlv.bsn_tlv.unpack)
275 obj.value = loxi.generic_util.unpack_list(reader, bsn_tlv.bsn_tlv.unpack)
276 return obj
277
278 def __eq__(self, other):
279 if type(self) != type(other): return False
280 if self.checksum != other.checksum: return False
281 if self.key != other.key: return False
282 if self.value != other.value: return False
283 return True
284
285 def pretty_print(self, q):
286 q.text("bsn_gentable_entry_desc_stats_entry {")
287 with q.group():
288 with q.indent(2):
289 q.breakable()
290 q.text("checksum = ");
291 q.pp(self.checksum)
292 q.text(","); q.breakable()
293 q.text("key = ");
294 q.pp(self.key)
295 q.text(","); q.breakable()
296 q.text("value = ");
297 q.pp(self.value)
298 q.breakable()
299 q.text('}')
300
301
302class bsn_gentable_entry_stats_entry(loxi.OFObject):
303
304 def __init__(self, key=None, stats=None):
305 if key != None:
306 self.key = key
307 else:
308 self.key = []
309 if stats != None:
310 self.stats = stats
311 else:
312 self.stats = []
313 return
314
315 def pack(self):
316 packed = []
317 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
318 packed.append(struct.pack("!H", 0)) # placeholder for key_length at index 1
319 packed.append(loxi.generic_util.pack_list(self.key))
320 packed[1] = struct.pack("!H", len(packed[-1]))
321 packed.append(loxi.generic_util.pack_list(self.stats))
322 length = sum([len(x) for x in packed])
323 packed[0] = struct.pack("!H", length)
324 return ''.join(packed)
325
326 @staticmethod
327 def unpack(reader):
328 obj = bsn_gentable_entry_stats_entry()
329 _length = reader.read("!H")[0]
330 orig_reader = reader
331 reader = orig_reader.slice(_length - (0 + 2))
332 _key_length = reader.read("!H")[0]
333 obj.key = loxi.generic_util.unpack_list(reader.slice(_key_length), bsn_tlv.bsn_tlv.unpack)
334 obj.stats = loxi.generic_util.unpack_list(reader, bsn_tlv.bsn_tlv.unpack)
335 return obj
336
337 def __eq__(self, other):
338 if type(self) != type(other): return False
339 if self.key != other.key: return False
340 if self.stats != other.stats: return False
341 return True
342
343 def pretty_print(self, q):
344 q.text("bsn_gentable_entry_stats_entry {")
345 with q.group():
346 with q.indent(2):
347 q.breakable()
348 q.text("key = ");
349 q.pp(self.key)
350 q.text(","); q.breakable()
351 q.text("stats = ");
352 q.pp(self.stats)
353 q.breakable()
354 q.text('}')
355
356
357class bsn_gentable_stats_entry(loxi.OFObject):
358
359 def __init__(self, table_id=None, entry_count=None, checksum=None):
360 if table_id != None:
361 self.table_id = table_id
362 else:
363 self.table_id = 0
364 if entry_count != None:
365 self.entry_count = entry_count
366 else:
367 self.entry_count = 0
368 if checksum != None:
369 self.checksum = checksum
370 else:
371 self.checksum = 0
372 return
373
374 def pack(self):
375 packed = []
376 packed.append(struct.pack("!H", self.table_id))
377 packed.append('\x00' * 2)
378 packed.append(struct.pack("!L", self.entry_count))
379 packed.append(util.pack_checksum_128(self.checksum))
380 return ''.join(packed)
381
382 @staticmethod
383 def unpack(reader):
384 obj = bsn_gentable_stats_entry()
385 obj.table_id = reader.read("!H")[0]
386 reader.skip(2)
387 obj.entry_count = reader.read("!L")[0]
388 obj.checksum = util.unpack_checksum_128(reader)
389 return obj
390
391 def __eq__(self, other):
392 if type(self) != type(other): return False
393 if self.table_id != other.table_id: return False
394 if self.entry_count != other.entry_count: return False
395 if self.checksum != other.checksum: return False
396 return True
397
398 def pretty_print(self, q):
399 q.text("bsn_gentable_stats_entry {")
400 with q.group():
401 with q.indent(2):
402 q.breakable()
403 q.text("table_id = ");
404 q.text("%#x" % self.table_id)
405 q.text(","); q.breakable()
406 q.text("entry_count = ");
407 q.text("%#x" % self.entry_count)
408 q.text(","); q.breakable()
409 q.text("checksum = ");
410 q.pp(self.checksum)
411 q.breakable()
412 q.text('}')
413
414
Rich Lane7dcdf022013-12-11 14:45:27 -0800415class bsn_interface(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700416
417 def __init__(self, hw_addr=None, name=None, ipv4_addr=None, ipv4_netmask=None):
418 if hw_addr != None:
419 self.hw_addr = hw_addr
420 else:
421 self.hw_addr = [0,0,0,0,0,0]
422 if name != None:
423 self.name = name
424 else:
425 self.name = ""
426 if ipv4_addr != None:
427 self.ipv4_addr = ipv4_addr
428 else:
429 self.ipv4_addr = 0
430 if ipv4_netmask != None:
431 self.ipv4_netmask = ipv4_netmask
432 else:
433 self.ipv4_netmask = 0
434 return
435
436 def pack(self):
437 packed = []
438 packed.append(struct.pack("!6B", *self.hw_addr))
439 packed.append('\x00' * 2)
440 packed.append(struct.pack("!16s", self.name))
441 packed.append(struct.pack("!L", self.ipv4_addr))
442 packed.append(struct.pack("!L", self.ipv4_netmask))
443 return ''.join(packed)
444
445 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800446 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700447 obj = bsn_interface()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700448 obj.hw_addr = list(reader.read('!6B'))
449 reader.skip(2)
450 obj.name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -0700451 obj.ipv4_addr = reader.read("!L")[0]
452 obj.ipv4_netmask = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700453 return obj
454
455 def __eq__(self, other):
456 if type(self) != type(other): return False
457 if self.hw_addr != other.hw_addr: return False
458 if self.name != other.name: return False
459 if self.ipv4_addr != other.ipv4_addr: return False
460 if self.ipv4_netmask != other.ipv4_netmask: return False
461 return True
462
Rich Lanec2ee4b82013-04-24 17:12:38 -0700463 def pretty_print(self, q):
464 q.text("bsn_interface {")
465 with q.group():
466 with q.indent(2):
467 q.breakable()
468 q.text("hw_addr = ");
469 q.text(util.pretty_mac(self.hw_addr))
470 q.text(","); q.breakable()
471 q.text("name = ");
472 q.pp(self.name)
473 q.text(","); q.breakable()
474 q.text("ipv4_addr = ");
475 q.text(util.pretty_ipv4(self.ipv4_addr))
476 q.text(","); q.breakable()
477 q.text("ipv4_netmask = ");
478 q.text(util.pretty_ipv4(self.ipv4_netmask))
479 q.breakable()
480 q.text('}')
481
Rich Lane7dcdf022013-12-11 14:45:27 -0800482
483class bsn_lacp_stats_entry(loxi.OFObject):
Rich Lane7b0f2012013-11-22 14:15:26 -0800484
485 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):
486 if port_no != None:
487 self.port_no = port_no
488 else:
489 self.port_no = 0
490 if actor_sys_priority != None:
491 self.actor_sys_priority = actor_sys_priority
492 else:
493 self.actor_sys_priority = 0
494 if actor_sys_mac != None:
495 self.actor_sys_mac = actor_sys_mac
496 else:
497 self.actor_sys_mac = [0,0,0,0,0,0]
498 if actor_port_priority != None:
499 self.actor_port_priority = actor_port_priority
500 else:
501 self.actor_port_priority = 0
502 if actor_port_num != None:
503 self.actor_port_num = actor_port_num
504 else:
505 self.actor_port_num = 0
506 if actor_key != None:
507 self.actor_key = actor_key
508 else:
509 self.actor_key = 0
510 if convergence_status != None:
511 self.convergence_status = convergence_status
512 else:
513 self.convergence_status = 0
514 if partner_sys_priority != None:
515 self.partner_sys_priority = partner_sys_priority
516 else:
517 self.partner_sys_priority = 0
518 if partner_sys_mac != None:
519 self.partner_sys_mac = partner_sys_mac
520 else:
521 self.partner_sys_mac = [0,0,0,0,0,0]
522 if partner_port_priority != None:
523 self.partner_port_priority = partner_port_priority
524 else:
525 self.partner_port_priority = 0
526 if partner_port_num != None:
527 self.partner_port_num = partner_port_num
528 else:
529 self.partner_port_num = 0
530 if partner_key != None:
531 self.partner_key = partner_key
532 else:
533 self.partner_key = 0
534 return
535
536 def pack(self):
537 packed = []
538 packed.append(util.pack_port_no(self.port_no))
539 packed.append(struct.pack("!H", self.actor_sys_priority))
540 packed.append(struct.pack("!6B", *self.actor_sys_mac))
541 packed.append(struct.pack("!H", self.actor_port_priority))
542 packed.append(struct.pack("!H", self.actor_port_num))
543 packed.append(struct.pack("!H", self.actor_key))
544 packed.append(struct.pack("!B", self.convergence_status))
545 packed.append('\x00' * 1)
546 packed.append(struct.pack("!H", self.partner_sys_priority))
547 packed.append(struct.pack("!6B", *self.partner_sys_mac))
548 packed.append(struct.pack("!H", self.partner_port_priority))
549 packed.append(struct.pack("!H", self.partner_port_num))
550 packed.append(struct.pack("!H", self.partner_key))
551 packed.append('\x00' * 2)
552 return ''.join(packed)
553
554 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800555 def unpack(reader):
Rich Lane7b0f2012013-11-22 14:15:26 -0800556 obj = bsn_lacp_stats_entry()
Rich Lane7b0f2012013-11-22 14:15:26 -0800557 obj.port_no = util.unpack_port_no(reader)
558 obj.actor_sys_priority = reader.read("!H")[0]
559 obj.actor_sys_mac = list(reader.read('!6B'))
560 obj.actor_port_priority = reader.read("!H")[0]
561 obj.actor_port_num = reader.read("!H")[0]
562 obj.actor_key = reader.read("!H")[0]
563 obj.convergence_status = reader.read("!B")[0]
564 reader.skip(1)
565 obj.partner_sys_priority = reader.read("!H")[0]
566 obj.partner_sys_mac = list(reader.read('!6B'))
567 obj.partner_port_priority = reader.read("!H")[0]
568 obj.partner_port_num = reader.read("!H")[0]
569 obj.partner_key = reader.read("!H")[0]
570 reader.skip(2)
571 return obj
572
573 def __eq__(self, other):
574 if type(self) != type(other): return False
575 if self.port_no != other.port_no: return False
576 if self.actor_sys_priority != other.actor_sys_priority: return False
577 if self.actor_sys_mac != other.actor_sys_mac: return False
578 if self.actor_port_priority != other.actor_port_priority: return False
579 if self.actor_port_num != other.actor_port_num: return False
580 if self.actor_key != other.actor_key: return False
581 if self.convergence_status != other.convergence_status: return False
582 if self.partner_sys_priority != other.partner_sys_priority: return False
583 if self.partner_sys_mac != other.partner_sys_mac: return False
584 if self.partner_port_priority != other.partner_port_priority: return False
585 if self.partner_port_num != other.partner_port_num: return False
586 if self.partner_key != other.partner_key: return False
587 return True
588
Rich Lane7b0f2012013-11-22 14:15:26 -0800589 def pretty_print(self, q):
590 q.text("bsn_lacp_stats_entry {")
591 with q.group():
592 with q.indent(2):
593 q.breakable()
594 q.text("port_no = ");
595 q.text(util.pretty_port(self.port_no))
596 q.text(","); q.breakable()
597 q.text("actor_sys_priority = ");
598 q.text("%#x" % self.actor_sys_priority)
599 q.text(","); q.breakable()
600 q.text("actor_sys_mac = ");
601 q.text(util.pretty_mac(self.actor_sys_mac))
602 q.text(","); q.breakable()
603 q.text("actor_port_priority = ");
604 q.text("%#x" % self.actor_port_priority)
605 q.text(","); q.breakable()
606 q.text("actor_port_num = ");
607 q.text("%#x" % self.actor_port_num)
608 q.text(","); q.breakable()
609 q.text("actor_key = ");
610 q.text("%#x" % self.actor_key)
611 q.text(","); q.breakable()
612 q.text("convergence_status = ");
613 q.text("%#x" % self.convergence_status)
614 q.text(","); q.breakable()
615 q.text("partner_sys_priority = ");
616 q.text("%#x" % self.partner_sys_priority)
617 q.text(","); q.breakable()
618 q.text("partner_sys_mac = ");
619 q.text(util.pretty_mac(self.partner_sys_mac))
620 q.text(","); q.breakable()
621 q.text("partner_port_priority = ");
622 q.text("%#x" % self.partner_port_priority)
623 q.text(","); q.breakable()
624 q.text("partner_port_num = ");
625 q.text("%#x" % self.partner_port_num)
626 q.text(","); q.breakable()
627 q.text("partner_key = ");
628 q.text("%#x" % self.partner_key)
629 q.breakable()
630 q.text('}')
631
Rich Lane7dcdf022013-12-11 14:45:27 -0800632
633class bsn_port_counter_stats_entry(loxi.OFObject):
634
635 def __init__(self, port_no=None, values=None):
636 if port_no != None:
637 self.port_no = port_no
638 else:
639 self.port_no = 0
640 if values != None:
641 self.values = values
642 else:
643 self.values = []
644 return
645
646 def pack(self):
647 packed = []
648 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
649 packed.append('\x00' * 2)
650 packed.append(util.pack_port_no(self.port_no))
651 packed.append(loxi.generic_util.pack_list(self.values))
652 length = sum([len(x) for x in packed])
653 packed[0] = struct.pack("!H", length)
654 return ''.join(packed)
655
656 @staticmethod
657 def unpack(reader):
658 obj = bsn_port_counter_stats_entry()
659 _length = reader.read("!H")[0]
660 orig_reader = reader
661 reader = orig_reader.slice(_length - (0 + 2))
662 reader.skip(2)
663 obj.port_no = util.unpack_port_no(reader)
664 obj.values = loxi.generic_util.unpack_list(reader, common.uint64.unpack)
665 return obj
666
667 def __eq__(self, other):
668 if type(self) != type(other): return False
669 if self.port_no != other.port_no: return False
670 if self.values != other.values: return False
671 return True
672
673 def pretty_print(self, q):
674 q.text("bsn_port_counter_stats_entry {")
675 with q.group():
676 with q.indent(2):
677 q.breakable()
678 q.text("port_no = ");
679 q.text(util.pretty_port(self.port_no))
680 q.text(","); q.breakable()
681 q.text("values = ");
682 q.pp(self.values)
683 q.breakable()
684 q.text('}')
685
686
687class bsn_switch_pipeline_stats_entry(loxi.OFObject):
688
689 def __init__(self, pipeline=None):
690 if pipeline != None:
691 self.pipeline = pipeline
692 else:
693 self.pipeline = ""
694 return
695
696 def pack(self):
697 packed = []
698 packed.append(struct.pack("!256s", self.pipeline))
699 return ''.join(packed)
700
701 @staticmethod
702 def unpack(reader):
703 obj = bsn_switch_pipeline_stats_entry()
704 obj.pipeline = reader.read("!256s")[0].rstrip("\x00")
705 return obj
706
707 def __eq__(self, other):
708 if type(self) != type(other): return False
709 if self.pipeline != other.pipeline: return False
710 return True
711
712 def pretty_print(self, q):
713 q.text("bsn_switch_pipeline_stats_entry {")
714 with q.group():
715 with q.indent(2):
716 q.breakable()
717 q.text("pipeline = ");
718 q.pp(self.pipeline)
719 q.breakable()
720 q.text('}')
721
722
Rich Lane9ec3fca2014-02-26 16:22:56 -0800723class bsn_table_checksum_stats_entry(loxi.OFObject):
724
725 def __init__(self, table_id=None, checksum=None):
726 if table_id != None:
727 self.table_id = table_id
728 else:
729 self.table_id = 0
730 if checksum != None:
731 self.checksum = checksum
732 else:
733 self.checksum = 0
734 return
735
736 def pack(self):
737 packed = []
738 packed.append(struct.pack("!B", self.table_id))
739 packed.append(struct.pack("!Q", self.checksum))
740 return ''.join(packed)
741
742 @staticmethod
743 def unpack(reader):
744 obj = bsn_table_checksum_stats_entry()
745 obj.table_id = reader.read("!B")[0]
746 obj.checksum = reader.read("!Q")[0]
747 return obj
748
749 def __eq__(self, other):
750 if type(self) != type(other): return False
751 if self.table_id != other.table_id: return False
752 if self.checksum != other.checksum: return False
753 return True
754
755 def pretty_print(self, q):
756 q.text("bsn_table_checksum_stats_entry {")
757 with q.group():
758 with q.indent(2):
759 q.breakable()
760 q.text("table_id = ");
761 q.text("%#x" % self.table_id)
762 q.text(","); q.breakable()
763 q.text("checksum = ");
764 q.text("%#x" % self.checksum)
765 q.breakable()
766 q.text('}')
767
768
Rich Lane7dcdf022013-12-11 14:45:27 -0800769class bsn_vport(loxi.OFObject):
770 subtypes = {}
771
Rich Lane95f7fc92014-01-27 17:08:16 -0800772
773 def __init__(self, type=None):
774 if type != None:
775 self.type = type
776 else:
777 self.type = 0
778 return
779
780 def pack(self):
781 packed = []
782 packed.append(struct.pack("!H", self.type))
783 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
784 length = sum([len(x) for x in packed])
785 packed[1] = struct.pack("!H", length)
786 return ''.join(packed)
787
Rich Lane7dcdf022013-12-11 14:45:27 -0800788 @staticmethod
789 def unpack(reader):
790 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -0800791 subclass = bsn_vport.subtypes.get(subtype)
792 if subclass:
793 return subclass.unpack(reader)
794
795 obj = bsn_vport()
796 obj.type = reader.read("!H")[0]
797 _length = reader.read("!H")[0]
798 orig_reader = reader
799 reader = orig_reader.slice(_length - (2 + 2))
800 return obj
801
802 def __eq__(self, other):
803 if type(self) != type(other): return False
804 if self.type != other.type: return False
805 return True
806
807 def pretty_print(self, q):
808 q.text("bsn_vport {")
809 with q.group():
810 with q.indent(2):
811 q.breakable()
812 q.breakable()
813 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800814
815
816class bsn_vport_q_in_q(bsn_vport):
Dan Talaycof6202252013-07-02 01:00:29 -0700817 type = 0
818
Kiran Poola150d8b02013-09-20 13:30:39 -0700819 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 -0700820 if port_no != None:
821 self.port_no = port_no
822 else:
823 self.port_no = 0
824 if ingress_tpid != None:
825 self.ingress_tpid = ingress_tpid
826 else:
827 self.ingress_tpid = 0
828 if ingress_vlan_id != None:
829 self.ingress_vlan_id = ingress_vlan_id
830 else:
831 self.ingress_vlan_id = 0
832 if egress_tpid != None:
833 self.egress_tpid = egress_tpid
834 else:
835 self.egress_tpid = 0
836 if egress_vlan_id != None:
837 self.egress_vlan_id = egress_vlan_id
838 else:
839 self.egress_vlan_id = 0
Kiran Poola150d8b02013-09-20 13:30:39 -0700840 if if_name != None:
841 self.if_name = if_name
842 else:
843 self.if_name = ""
Dan Talaycof6202252013-07-02 01:00:29 -0700844 return
845
846 def pack(self):
847 packed = []
848 packed.append(struct.pack("!H", self.type))
Kiran Poola150d8b02013-09-20 13:30:39 -0700849 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700850 packed.append(struct.pack("!L", self.port_no))
851 packed.append(struct.pack("!H", self.ingress_tpid))
852 packed.append(struct.pack("!H", self.ingress_vlan_id))
853 packed.append(struct.pack("!H", self.egress_tpid))
854 packed.append(struct.pack("!H", self.egress_vlan_id))
Kiran Poola150d8b02013-09-20 13:30:39 -0700855 packed.append(struct.pack("!16s", self.if_name))
Dan Talaycof6202252013-07-02 01:00:29 -0700856 length = sum([len(x) for x in packed])
Kiran Poola150d8b02013-09-20 13:30:39 -0700857 packed[1] = struct.pack("!H", length)
Dan Talaycof6202252013-07-02 01:00:29 -0700858 return ''.join(packed)
859
860 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800861 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -0700862 obj = bsn_vport_q_in_q()
Dan Talaycof6202252013-07-02 01:00:29 -0700863 _type = reader.read("!H")[0]
864 assert(_type == 0)
865 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800866 orig_reader = reader
867 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700868 obj.port_no = reader.read("!L")[0]
869 obj.ingress_tpid = reader.read("!H")[0]
870 obj.ingress_vlan_id = reader.read("!H")[0]
871 obj.egress_tpid = reader.read("!H")[0]
872 obj.egress_vlan_id = reader.read("!H")[0]
Kiran Poola150d8b02013-09-20 13:30:39 -0700873 obj.if_name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -0700874 return obj
875
876 def __eq__(self, other):
877 if type(self) != type(other): return False
878 if self.port_no != other.port_no: return False
879 if self.ingress_tpid != other.ingress_tpid: return False
880 if self.ingress_vlan_id != other.ingress_vlan_id: return False
881 if self.egress_tpid != other.egress_tpid: return False
882 if self.egress_vlan_id != other.egress_vlan_id: return False
Kiran Poola150d8b02013-09-20 13:30:39 -0700883 if self.if_name != other.if_name: return False
Dan Talaycof6202252013-07-02 01:00:29 -0700884 return True
885
Dan Talaycof6202252013-07-02 01:00:29 -0700886 def pretty_print(self, q):
887 q.text("bsn_vport_q_in_q {")
888 with q.group():
889 with q.indent(2):
890 q.breakable()
891 q.text("port_no = ");
892 q.text("%#x" % self.port_no)
893 q.text(","); q.breakable()
894 q.text("ingress_tpid = ");
895 q.text("%#x" % self.ingress_tpid)
896 q.text(","); q.breakable()
897 q.text("ingress_vlan_id = ");
898 q.text("%#x" % self.ingress_vlan_id)
899 q.text(","); q.breakable()
900 q.text("egress_tpid = ");
901 q.text("%#x" % self.egress_tpid)
902 q.text(","); q.breakable()
903 q.text("egress_vlan_id = ");
904 q.text("%#x" % self.egress_vlan_id)
Kiran Poola150d8b02013-09-20 13:30:39 -0700905 q.text(","); q.breakable()
906 q.text("if_name = ");
907 q.pp(self.if_name)
Dan Talaycof6202252013-07-02 01:00:29 -0700908 q.breakable()
909 q.text('}')
910
Rich Lane7dcdf022013-12-11 14:45:27 -0800911bsn_vport.subtypes[0] = bsn_vport_q_in_q
912
913class bsn_vlan_counter_stats_entry(loxi.OFObject):
914
915 def __init__(self, vlan_vid=None, values=None):
916 if vlan_vid != None:
917 self.vlan_vid = vlan_vid
918 else:
919 self.vlan_vid = 0
920 if values != None:
921 self.values = values
922 else:
923 self.values = []
924 return
925
926 def pack(self):
927 packed = []
928 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
929 packed.append(struct.pack("!H", self.vlan_vid))
930 packed.append('\x00' * 4)
931 packed.append(loxi.generic_util.pack_list(self.values))
932 length = sum([len(x) for x in packed])
933 packed[0] = struct.pack("!H", length)
934 return ''.join(packed)
935
936 @staticmethod
937 def unpack(reader):
938 obj = bsn_vlan_counter_stats_entry()
939 _length = reader.read("!H")[0]
940 orig_reader = reader
941 reader = orig_reader.slice(_length - (0 + 2))
942 obj.vlan_vid = reader.read("!H")[0]
943 reader.skip(4)
944 obj.values = loxi.generic_util.unpack_list(reader, common.uint64.unpack)
945 return obj
946
947 def __eq__(self, other):
948 if type(self) != type(other): return False
949 if self.vlan_vid != other.vlan_vid: return False
950 if self.values != other.values: return False
951 return True
952
953 def pretty_print(self, q):
954 q.text("bsn_vlan_counter_stats_entry {")
955 with q.group():
956 with q.indent(2):
957 q.breakable()
958 q.text("vlan_vid = ");
959 q.text("%#x" % self.vlan_vid)
960 q.text(","); q.breakable()
961 q.text("values = ");
962 q.pp(self.values)
963 q.breakable()
964 q.text('}')
965
966
967class bucket(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700968
969 def __init__(self, weight=None, watch_port=None, watch_group=None, actions=None):
970 if weight != None:
971 self.weight = weight
972 else:
973 self.weight = 0
974 if watch_port != None:
975 self.watch_port = watch_port
976 else:
977 self.watch_port = 0
978 if watch_group != None:
979 self.watch_group = watch_group
980 else:
981 self.watch_group = 0
982 if actions != None:
983 self.actions = actions
984 else:
985 self.actions = []
986 return
987
988 def pack(self):
989 packed = []
990 packed.append(struct.pack("!H", 0)) # placeholder for len at index 0
991 packed.append(struct.pack("!H", self.weight))
Dan Talaycof6202252013-07-02 01:00:29 -0700992 packed.append(util.pack_port_no(self.watch_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700993 packed.append(struct.pack("!L", self.watch_group))
994 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -0800995 packed.append(loxi.generic_util.pack_list(self.actions))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700996 length = sum([len(x) for x in packed])
997 packed[0] = struct.pack("!H", length)
998 return ''.join(packed)
999
1000 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001001 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001002 obj = bucket()
Dan Talaycof6202252013-07-02 01:00:29 -07001003 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001004 orig_reader = reader
1005 reader = orig_reader.slice(_len - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001006 obj.weight = reader.read("!H")[0]
1007 obj.watch_port = util.unpack_port_no(reader)
1008 obj.watch_group = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001009 reader.skip(4)
Rich Lane7dcdf022013-12-11 14:45:27 -08001010 obj.actions = loxi.generic_util.unpack_list(reader, action.action.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001011 return obj
1012
1013 def __eq__(self, other):
1014 if type(self) != type(other): return False
1015 if self.weight != other.weight: return False
1016 if self.watch_port != other.watch_port: return False
1017 if self.watch_group != other.watch_group: return False
1018 if self.actions != other.actions: return False
1019 return True
1020
Rich Lanec2ee4b82013-04-24 17:12:38 -07001021 def pretty_print(self, q):
1022 q.text("bucket {")
1023 with q.group():
1024 with q.indent(2):
1025 q.breakable()
1026 q.text("weight = ");
1027 q.text("%#x" % self.weight)
1028 q.text(","); q.breakable()
1029 q.text("watch_port = ");
1030 q.text(util.pretty_port(self.watch_port))
1031 q.text(","); q.breakable()
1032 q.text("watch_group = ");
1033 q.text("%#x" % self.watch_group)
1034 q.text(","); q.breakable()
1035 q.text("actions = ");
1036 q.pp(self.actions)
1037 q.breakable()
1038 q.text('}')
1039
Rich Lane7dcdf022013-12-11 14:45:27 -08001040
1041class bucket_counter(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001042
1043 def __init__(self, packet_count=None, byte_count=None):
1044 if packet_count != None:
1045 self.packet_count = packet_count
1046 else:
1047 self.packet_count = 0
1048 if byte_count != None:
1049 self.byte_count = byte_count
1050 else:
1051 self.byte_count = 0
1052 return
1053
1054 def pack(self):
1055 packed = []
1056 packed.append(struct.pack("!Q", self.packet_count))
1057 packed.append(struct.pack("!Q", self.byte_count))
1058 return ''.join(packed)
1059
1060 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001061 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001062 obj = bucket_counter()
Dan Talaycof6202252013-07-02 01:00:29 -07001063 obj.packet_count = reader.read("!Q")[0]
1064 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001065 return obj
1066
1067 def __eq__(self, other):
1068 if type(self) != type(other): return False
1069 if self.packet_count != other.packet_count: return False
1070 if self.byte_count != other.byte_count: return False
1071 return True
1072
Rich Lanec2ee4b82013-04-24 17:12:38 -07001073 def pretty_print(self, q):
1074 q.text("bucket_counter {")
1075 with q.group():
1076 with q.indent(2):
1077 q.breakable()
1078 q.text("packet_count = ");
1079 q.text("%#x" % self.packet_count)
1080 q.text(","); q.breakable()
1081 q.text("byte_count = ");
1082 q.text("%#x" % self.byte_count)
1083 q.breakable()
1084 q.text('}')
1085
Rich Lane7dcdf022013-12-11 14:45:27 -08001086
Rich Lane7dcdf022013-12-11 14:45:27 -08001087class flow_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001088
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001089 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 -07001090 if table_id != None:
1091 self.table_id = table_id
1092 else:
1093 self.table_id = 0
1094 if duration_sec != None:
1095 self.duration_sec = duration_sec
1096 else:
1097 self.duration_sec = 0
1098 if duration_nsec != None:
1099 self.duration_nsec = duration_nsec
1100 else:
1101 self.duration_nsec = 0
1102 if priority != None:
1103 self.priority = priority
1104 else:
1105 self.priority = 0
1106 if idle_timeout != None:
1107 self.idle_timeout = idle_timeout
1108 else:
1109 self.idle_timeout = 0
1110 if hard_timeout != None:
1111 self.hard_timeout = hard_timeout
1112 else:
1113 self.hard_timeout = 0
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001114 if flags != None:
1115 self.flags = flags
1116 else:
1117 self.flags = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07001118 if cookie != None:
1119 self.cookie = cookie
1120 else:
1121 self.cookie = 0
1122 if packet_count != None:
1123 self.packet_count = packet_count
1124 else:
1125 self.packet_count = 0
1126 if byte_count != None:
1127 self.byte_count = byte_count
1128 else:
1129 self.byte_count = 0
1130 if match != None:
1131 self.match = match
1132 else:
1133 self.match = common.match()
1134 if instructions != None:
1135 self.instructions = instructions
1136 else:
1137 self.instructions = []
1138 return
1139
1140 def pack(self):
1141 packed = []
1142 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
1143 packed.append(struct.pack("!B", self.table_id))
1144 packed.append('\x00' * 1)
1145 packed.append(struct.pack("!L", self.duration_sec))
1146 packed.append(struct.pack("!L", self.duration_nsec))
1147 packed.append(struct.pack("!H", self.priority))
1148 packed.append(struct.pack("!H", self.idle_timeout))
1149 packed.append(struct.pack("!H", self.hard_timeout))
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001150 packed.append(struct.pack("!H", self.flags))
1151 packed.append('\x00' * 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001152 packed.append(struct.pack("!Q", self.cookie))
1153 packed.append(struct.pack("!Q", self.packet_count))
1154 packed.append(struct.pack("!Q", self.byte_count))
1155 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08001156 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001157 length = sum([len(x) for x in packed])
1158 packed[0] = struct.pack("!H", length)
1159 return ''.join(packed)
1160
1161 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001162 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001163 obj = flow_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001164 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001165 orig_reader = reader
1166 reader = orig_reader.slice(_length - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001167 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001168 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -07001169 obj.duration_sec = reader.read("!L")[0]
1170 obj.duration_nsec = reader.read("!L")[0]
1171 obj.priority = reader.read("!H")[0]
1172 obj.idle_timeout = reader.read("!H")[0]
1173 obj.hard_timeout = reader.read("!H")[0]
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001174 obj.flags = reader.read("!H")[0]
1175 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001176 obj.cookie = reader.read("!Q")[0]
1177 obj.packet_count = reader.read("!Q")[0]
1178 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001179 obj.match = common.match.unpack(reader)
Rich Lane7dcdf022013-12-11 14:45:27 -08001180 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001181 return obj
1182
1183 def __eq__(self, other):
1184 if type(self) != type(other): return False
1185 if self.table_id != other.table_id: return False
1186 if self.duration_sec != other.duration_sec: return False
1187 if self.duration_nsec != other.duration_nsec: return False
1188 if self.priority != other.priority: return False
1189 if self.idle_timeout != other.idle_timeout: return False
1190 if self.hard_timeout != other.hard_timeout: return False
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001191 if self.flags != other.flags: return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001192 if self.cookie != other.cookie: return False
1193 if self.packet_count != other.packet_count: return False
1194 if self.byte_count != other.byte_count: return False
1195 if self.match != other.match: return False
1196 if self.instructions != other.instructions: return False
1197 return True
1198
Rich Lanec2ee4b82013-04-24 17:12:38 -07001199 def pretty_print(self, q):
1200 q.text("flow_stats_entry {")
1201 with q.group():
1202 with q.indent(2):
1203 q.breakable()
1204 q.text("table_id = ");
1205 q.text("%#x" % self.table_id)
1206 q.text(","); q.breakable()
1207 q.text("duration_sec = ");
1208 q.text("%#x" % self.duration_sec)
1209 q.text(","); q.breakable()
1210 q.text("duration_nsec = ");
1211 q.text("%#x" % self.duration_nsec)
1212 q.text(","); q.breakable()
1213 q.text("priority = ");
1214 q.text("%#x" % self.priority)
1215 q.text(","); q.breakable()
1216 q.text("idle_timeout = ");
1217 q.text("%#x" % self.idle_timeout)
1218 q.text(","); q.breakable()
1219 q.text("hard_timeout = ");
1220 q.text("%#x" % self.hard_timeout)
1221 q.text(","); q.breakable()
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001222 q.text("flags = ");
1223 q.text("%#x" % self.flags)
1224 q.text(","); q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001225 q.text("cookie = ");
1226 q.text("%#x" % self.cookie)
1227 q.text(","); q.breakable()
1228 q.text("packet_count = ");
1229 q.text("%#x" % self.packet_count)
1230 q.text(","); q.breakable()
1231 q.text("byte_count = ");
1232 q.text("%#x" % self.byte_count)
1233 q.text(","); q.breakable()
1234 q.text("match = ");
1235 q.pp(self.match)
1236 q.text(","); q.breakable()
1237 q.text("instructions = ");
1238 q.pp(self.instructions)
1239 q.breakable()
1240 q.text('}')
1241
Rich Lane7dcdf022013-12-11 14:45:27 -08001242
1243class group_desc_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001244
Rich Lane6f4978c2013-10-20 21:33:52 -07001245 def __init__(self, group_type=None, group_id=None, buckets=None):
1246 if group_type != None:
1247 self.group_type = group_type
Rich Lanec2ee4b82013-04-24 17:12:38 -07001248 else:
Rich Lane6f4978c2013-10-20 21:33:52 -07001249 self.group_type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07001250 if group_id != None:
1251 self.group_id = group_id
1252 else:
1253 self.group_id = 0
1254 if buckets != None:
1255 self.buckets = buckets
1256 else:
1257 self.buckets = []
1258 return
1259
1260 def pack(self):
1261 packed = []
1262 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
Rich Lane6f4978c2013-10-20 21:33:52 -07001263 packed.append(struct.pack("!B", self.group_type))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001264 packed.append('\x00' * 1)
1265 packed.append(struct.pack("!L", self.group_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08001266 packed.append(loxi.generic_util.pack_list(self.buckets))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001267 length = sum([len(x) for x in packed])
1268 packed[0] = struct.pack("!H", length)
1269 return ''.join(packed)
1270
1271 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001272 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001273 obj = group_desc_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001274 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001275 orig_reader = reader
1276 reader = orig_reader.slice(_length - (0 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07001277 obj.group_type = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001278 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -07001279 obj.group_id = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001280 obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001281 return obj
1282
1283 def __eq__(self, other):
1284 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001285 if self.group_type != other.group_type: return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001286 if self.group_id != other.group_id: return False
1287 if self.buckets != other.buckets: return False
1288 return True
1289
Rich Lanec2ee4b82013-04-24 17:12:38 -07001290 def pretty_print(self, q):
1291 q.text("group_desc_stats_entry {")
1292 with q.group():
1293 with q.indent(2):
1294 q.breakable()
Rich Lane6f4978c2013-10-20 21:33:52 -07001295 q.text("group_type = ");
1296 q.text("%#x" % self.group_type)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001297 q.text(","); q.breakable()
1298 q.text("group_id = ");
1299 q.text("%#x" % self.group_id)
1300 q.text(","); q.breakable()
1301 q.text("buckets = ");
1302 q.pp(self.buckets)
1303 q.breakable()
1304 q.text('}')
1305
Rich Lane7dcdf022013-12-11 14:45:27 -08001306
1307class group_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001308
1309 def __init__(self, group_id=None, ref_count=None, packet_count=None, byte_count=None, duration_sec=None, duration_nsec=None, bucket_stats=None):
1310 if group_id != None:
1311 self.group_id = group_id
1312 else:
1313 self.group_id = 0
1314 if ref_count != None:
1315 self.ref_count = ref_count
1316 else:
1317 self.ref_count = 0
1318 if packet_count != None:
1319 self.packet_count = packet_count
1320 else:
1321 self.packet_count = 0
1322 if byte_count != None:
1323 self.byte_count = byte_count
1324 else:
1325 self.byte_count = 0
1326 if duration_sec != None:
1327 self.duration_sec = duration_sec
1328 else:
1329 self.duration_sec = 0
1330 if duration_nsec != None:
1331 self.duration_nsec = duration_nsec
1332 else:
1333 self.duration_nsec = 0
1334 if bucket_stats != None:
1335 self.bucket_stats = bucket_stats
1336 else:
1337 self.bucket_stats = []
1338 return
1339
1340 def pack(self):
1341 packed = []
1342 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
1343 packed.append('\x00' * 2)
1344 packed.append(struct.pack("!L", self.group_id))
1345 packed.append(struct.pack("!L", self.ref_count))
1346 packed.append('\x00' * 4)
1347 packed.append(struct.pack("!Q", self.packet_count))
1348 packed.append(struct.pack("!Q", self.byte_count))
1349 packed.append(struct.pack("!L", self.duration_sec))
1350 packed.append(struct.pack("!L", self.duration_nsec))
Rich Lane7dcdf022013-12-11 14:45:27 -08001351 packed.append(loxi.generic_util.pack_list(self.bucket_stats))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001352 length = sum([len(x) for x in packed])
1353 packed[0] = struct.pack("!H", length)
1354 return ''.join(packed)
1355
1356 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001357 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001358 obj = group_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001359 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001360 orig_reader = reader
1361 reader = orig_reader.slice(_length - (0 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001362 reader.skip(2)
Dan Talaycof6202252013-07-02 01:00:29 -07001363 obj.group_id = reader.read("!L")[0]
1364 obj.ref_count = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001365 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001366 obj.packet_count = reader.read("!Q")[0]
1367 obj.byte_count = reader.read("!Q")[0]
1368 obj.duration_sec = reader.read("!L")[0]
1369 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001370 obj.bucket_stats = loxi.generic_util.unpack_list(reader, common.bucket_counter.unpack)
1371 return obj
1372
1373 def __eq__(self, other):
1374 if type(self) != type(other): return False
1375 if self.group_id != other.group_id: return False
1376 if self.ref_count != other.ref_count: return False
1377 if self.packet_count != other.packet_count: return False
1378 if self.byte_count != other.byte_count: return False
1379 if self.duration_sec != other.duration_sec: return False
1380 if self.duration_nsec != other.duration_nsec: return False
1381 if self.bucket_stats != other.bucket_stats: return False
1382 return True
1383
Rich Lanec2ee4b82013-04-24 17:12:38 -07001384 def pretty_print(self, q):
1385 q.text("group_stats_entry {")
1386 with q.group():
1387 with q.indent(2):
1388 q.breakable()
1389 q.text("group_id = ");
1390 q.text("%#x" % self.group_id)
1391 q.text(","); q.breakable()
1392 q.text("ref_count = ");
1393 q.text("%#x" % self.ref_count)
1394 q.text(","); q.breakable()
1395 q.text("packet_count = ");
1396 q.text("%#x" % self.packet_count)
1397 q.text(","); q.breakable()
1398 q.text("byte_count = ");
1399 q.text("%#x" % self.byte_count)
1400 q.text(","); q.breakable()
1401 q.text("duration_sec = ");
1402 q.text("%#x" % self.duration_sec)
1403 q.text(","); q.breakable()
1404 q.text("duration_nsec = ");
1405 q.text("%#x" % self.duration_nsec)
1406 q.text(","); q.breakable()
1407 q.text("bucket_stats = ");
1408 q.pp(self.bucket_stats)
1409 q.breakable()
1410 q.text('}')
1411
Rich Lane7dcdf022013-12-11 14:45:27 -08001412
1413class hello_elem(loxi.OFObject):
1414 subtypes = {}
1415
Rich Lane95f7fc92014-01-27 17:08:16 -08001416
1417 def __init__(self, type=None):
1418 if type != None:
1419 self.type = type
1420 else:
1421 self.type = 0
1422 return
1423
1424 def pack(self):
1425 packed = []
1426 packed.append(struct.pack("!H", self.type))
1427 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
1428 length = sum([len(x) for x in packed])
1429 packed[1] = struct.pack("!H", length)
1430 return ''.join(packed)
1431
Rich Lane7dcdf022013-12-11 14:45:27 -08001432 @staticmethod
1433 def unpack(reader):
1434 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -08001435 subclass = hello_elem.subtypes.get(subtype)
1436 if subclass:
1437 return subclass.unpack(reader)
1438
1439 obj = hello_elem()
1440 obj.type = reader.read("!H")[0]
1441 _length = reader.read("!H")[0]
1442 orig_reader = reader
1443 reader = orig_reader.slice(_length - (2 + 2))
1444 return obj
1445
1446 def __eq__(self, other):
1447 if type(self) != type(other): return False
1448 if self.type != other.type: return False
1449 return True
1450
1451 def pretty_print(self, q):
1452 q.text("hello_elem {")
1453 with q.group():
1454 with q.indent(2):
1455 q.breakable()
1456 q.breakable()
1457 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08001458
1459
1460class hello_elem_versionbitmap(hello_elem):
Dan Talaycof6202252013-07-02 01:00:29 -07001461 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07001462
1463 def __init__(self, bitmaps=None):
1464 if bitmaps != None:
1465 self.bitmaps = bitmaps
1466 else:
1467 self.bitmaps = []
1468 return
1469
1470 def pack(self):
1471 packed = []
1472 packed.append(struct.pack("!H", self.type))
1473 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08001474 packed.append(loxi.generic_util.pack_list(self.bitmaps))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001475 length = sum([len(x) for x in packed])
1476 packed[1] = struct.pack("!H", length)
1477 return ''.join(packed)
1478
1479 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001480 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001481 obj = hello_elem_versionbitmap()
Dan Talaycof6202252013-07-02 01:00:29 -07001482 _type = reader.read("!H")[0]
1483 assert(_type == 1)
1484 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001485 orig_reader = reader
1486 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001487 obj.bitmaps = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
1488 return obj
1489
1490 def __eq__(self, other):
1491 if type(self) != type(other): return False
1492 if self.bitmaps != other.bitmaps: return False
1493 return True
1494
Rich Lanec2ee4b82013-04-24 17:12:38 -07001495 def pretty_print(self, q):
1496 q.text("hello_elem_versionbitmap {")
1497 with q.group():
1498 with q.indent(2):
1499 q.breakable()
1500 q.text("bitmaps = ");
1501 q.pp(self.bitmaps)
1502 q.breakable()
1503 q.text('}')
1504
Rich Lane7dcdf022013-12-11 14:45:27 -08001505hello_elem.subtypes[1] = hello_elem_versionbitmap
1506
1507class match_v3(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001508 type = 1
1509
1510 def __init__(self, oxm_list=None):
1511 if oxm_list != None:
1512 self.oxm_list = oxm_list
1513 else:
1514 self.oxm_list = []
1515 return
1516
1517 def pack(self):
1518 packed = []
1519 packed.append(struct.pack("!H", self.type))
1520 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08001521 packed.append(loxi.generic_util.pack_list(self.oxm_list))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001522 length = sum([len(x) for x in packed])
1523 packed[1] = struct.pack("!H", length)
Rich Laned53156a2013-08-05 17:17:33 -07001524 packed.append(loxi.generic_util.pad_to(8, length))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001525 return ''.join(packed)
1526
1527 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001528 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001529 obj = match_v3()
Dan Talaycof6202252013-07-02 01:00:29 -07001530 _type = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001531 assert(_type == 1)
Dan Talaycof6202252013-07-02 01:00:29 -07001532 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001533 orig_reader = reader
1534 reader = orig_reader.slice(_length - (2 + 2))
1535 obj.oxm_list = loxi.generic_util.unpack_list(reader, oxm.oxm.unpack)
1536 orig_reader.skip_align()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001537 return obj
1538
1539 def __eq__(self, other):
1540 if type(self) != type(other): return False
1541 if self.oxm_list != other.oxm_list: return False
1542 return True
1543
Rich Lanec2ee4b82013-04-24 17:12:38 -07001544 def pretty_print(self, q):
1545 q.text("match_v3 {")
1546 with q.group():
1547 with q.indent(2):
1548 q.breakable()
1549 q.text("oxm_list = ");
1550 q.pp(self.oxm_list)
1551 q.breakable()
1552 q.text('}')
1553
Rich Lane7dcdf022013-12-11 14:45:27 -08001554
1555class meter_band_stats(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001556
1557 def __init__(self, packet_band_count=None, byte_band_count=None):
1558 if packet_band_count != None:
1559 self.packet_band_count = packet_band_count
1560 else:
1561 self.packet_band_count = 0
1562 if byte_band_count != None:
1563 self.byte_band_count = byte_band_count
1564 else:
1565 self.byte_band_count = 0
1566 return
1567
1568 def pack(self):
1569 packed = []
1570 packed.append(struct.pack("!Q", self.packet_band_count))
1571 packed.append(struct.pack("!Q", self.byte_band_count))
1572 return ''.join(packed)
1573
1574 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001575 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001576 obj = meter_band_stats()
Dan Talaycof6202252013-07-02 01:00:29 -07001577 obj.packet_band_count = reader.read("!Q")[0]
1578 obj.byte_band_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001579 return obj
1580
1581 def __eq__(self, other):
1582 if type(self) != type(other): return False
1583 if self.packet_band_count != other.packet_band_count: return False
1584 if self.byte_band_count != other.byte_band_count: return False
1585 return True
1586
Rich Lanec2ee4b82013-04-24 17:12:38 -07001587 def pretty_print(self, q):
1588 q.text("meter_band_stats {")
1589 with q.group():
1590 with q.indent(2):
1591 q.breakable()
1592 q.text("packet_band_count = ");
1593 q.text("%#x" % self.packet_band_count)
1594 q.text(","); q.breakable()
1595 q.text("byte_band_count = ");
1596 q.text("%#x" % self.byte_band_count)
1597 q.breakable()
1598 q.text('}')
1599
Rich Lane7dcdf022013-12-11 14:45:27 -08001600
1601class meter_config(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001602
1603 def __init__(self, flags=None, meter_id=None, entries=None):
1604 if flags != None:
1605 self.flags = flags
1606 else:
1607 self.flags = 0
1608 if meter_id != None:
1609 self.meter_id = meter_id
1610 else:
1611 self.meter_id = 0
1612 if entries != None:
1613 self.entries = entries
1614 else:
1615 self.entries = []
1616 return
1617
1618 def pack(self):
1619 packed = []
1620 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
1621 packed.append(struct.pack("!H", self.flags))
1622 packed.append(struct.pack("!L", self.meter_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08001623 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001624 length = sum([len(x) for x in packed])
1625 packed[0] = struct.pack("!H", length)
1626 return ''.join(packed)
1627
1628 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001629 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001630 obj = meter_config()
Dan Talaycof6202252013-07-02 01:00:29 -07001631 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001632 orig_reader = reader
1633 reader = orig_reader.slice(_length - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001634 obj.flags = reader.read("!H")[0]
1635 obj.meter_id = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001636 obj.entries = loxi.generic_util.unpack_list(reader, meter_band.meter_band.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001637 return obj
1638
1639 def __eq__(self, other):
1640 if type(self) != type(other): return False
1641 if self.flags != other.flags: return False
1642 if self.meter_id != other.meter_id: return False
1643 if self.entries != other.entries: return False
1644 return True
1645
Rich Lanec2ee4b82013-04-24 17:12:38 -07001646 def pretty_print(self, q):
1647 q.text("meter_config {")
1648 with q.group():
1649 with q.indent(2):
1650 q.breakable()
1651 q.text("flags = ");
1652 q.text("%#x" % self.flags)
1653 q.text(","); q.breakable()
1654 q.text("meter_id = ");
1655 q.text("%#x" % self.meter_id)
1656 q.text(","); q.breakable()
1657 q.text("entries = ");
1658 q.pp(self.entries)
1659 q.breakable()
1660 q.text('}')
1661
Rich Lane7dcdf022013-12-11 14:45:27 -08001662
1663class meter_features(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001664
1665 def __init__(self, max_meter=None, band_types=None, capabilities=None, max_bands=None, max_color=None):
1666 if max_meter != None:
1667 self.max_meter = max_meter
1668 else:
1669 self.max_meter = 0
1670 if band_types != None:
1671 self.band_types = band_types
1672 else:
1673 self.band_types = 0
1674 if capabilities != None:
1675 self.capabilities = capabilities
1676 else:
1677 self.capabilities = 0
1678 if max_bands != None:
1679 self.max_bands = max_bands
1680 else:
1681 self.max_bands = 0
1682 if max_color != None:
1683 self.max_color = max_color
1684 else:
1685 self.max_color = 0
1686 return
1687
1688 def pack(self):
1689 packed = []
1690 packed.append(struct.pack("!L", self.max_meter))
1691 packed.append(struct.pack("!L", self.band_types))
1692 packed.append(struct.pack("!L", self.capabilities))
1693 packed.append(struct.pack("!B", self.max_bands))
1694 packed.append(struct.pack("!B", self.max_color))
1695 packed.append('\x00' * 2)
1696 return ''.join(packed)
1697
1698 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001699 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001700 obj = meter_features()
Dan Talaycof6202252013-07-02 01:00:29 -07001701 obj.max_meter = reader.read("!L")[0]
1702 obj.band_types = reader.read("!L")[0]
1703 obj.capabilities = reader.read("!L")[0]
1704 obj.max_bands = reader.read("!B")[0]
1705 obj.max_color = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001706 reader.skip(2)
1707 return obj
1708
1709 def __eq__(self, other):
1710 if type(self) != type(other): return False
1711 if self.max_meter != other.max_meter: return False
1712 if self.band_types != other.band_types: return False
1713 if self.capabilities != other.capabilities: return False
1714 if self.max_bands != other.max_bands: return False
1715 if self.max_color != other.max_color: return False
1716 return True
1717
Rich Lanec2ee4b82013-04-24 17:12:38 -07001718 def pretty_print(self, q):
1719 q.text("meter_features {")
1720 with q.group():
1721 with q.indent(2):
1722 q.breakable()
1723 q.text("max_meter = ");
1724 q.text("%#x" % self.max_meter)
1725 q.text(","); q.breakable()
1726 q.text("band_types = ");
1727 q.text("%#x" % self.band_types)
1728 q.text(","); q.breakable()
1729 q.text("capabilities = ");
1730 q.text("%#x" % self.capabilities)
1731 q.text(","); q.breakable()
1732 q.text("max_bands = ");
1733 q.text("%#x" % self.max_bands)
1734 q.text(","); q.breakable()
1735 q.text("max_color = ");
1736 q.text("%#x" % self.max_color)
1737 q.breakable()
1738 q.text('}')
1739
Rich Lane7dcdf022013-12-11 14:45:27 -08001740
1741class meter_stats(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001742
1743 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):
1744 if meter_id != None:
1745 self.meter_id = meter_id
1746 else:
1747 self.meter_id = 0
1748 if flow_count != None:
1749 self.flow_count = flow_count
1750 else:
1751 self.flow_count = 0
1752 if packet_in_count != None:
1753 self.packet_in_count = packet_in_count
1754 else:
1755 self.packet_in_count = 0
1756 if byte_in_count != None:
1757 self.byte_in_count = byte_in_count
1758 else:
1759 self.byte_in_count = 0
1760 if duration_sec != None:
1761 self.duration_sec = duration_sec
1762 else:
1763 self.duration_sec = 0
1764 if duration_nsec != None:
1765 self.duration_nsec = duration_nsec
1766 else:
1767 self.duration_nsec = 0
1768 if band_stats != None:
1769 self.band_stats = band_stats
1770 else:
1771 self.band_stats = []
1772 return
1773
1774 def pack(self):
1775 packed = []
1776 packed.append(struct.pack("!L", self.meter_id))
1777 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1778 packed.append('\x00' * 6)
1779 packed.append(struct.pack("!L", self.flow_count))
1780 packed.append(struct.pack("!Q", self.packet_in_count))
1781 packed.append(struct.pack("!Q", self.byte_in_count))
1782 packed.append(struct.pack("!L", self.duration_sec))
1783 packed.append(struct.pack("!L", self.duration_nsec))
Rich Lane7dcdf022013-12-11 14:45:27 -08001784 packed.append(loxi.generic_util.pack_list(self.band_stats))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001785 length = sum([len(x) for x in packed])
1786 packed[1] = struct.pack("!H", length)
1787 return ''.join(packed)
1788
1789 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001790 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001791 obj = meter_stats()
Dan Talaycof6202252013-07-02 01:00:29 -07001792 obj.meter_id = reader.read("!L")[0]
1793 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001794 orig_reader = reader
1795 reader = orig_reader.slice(_len - (4 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001796 reader.skip(6)
Dan Talaycof6202252013-07-02 01:00:29 -07001797 obj.flow_count = reader.read("!L")[0]
1798 obj.packet_in_count = reader.read("!Q")[0]
1799 obj.byte_in_count = reader.read("!Q")[0]
1800 obj.duration_sec = reader.read("!L")[0]
1801 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001802 obj.band_stats = loxi.generic_util.unpack_list(reader, common.meter_band_stats.unpack)
1803 return obj
1804
1805 def __eq__(self, other):
1806 if type(self) != type(other): return False
1807 if self.meter_id != other.meter_id: return False
1808 if self.flow_count != other.flow_count: return False
1809 if self.packet_in_count != other.packet_in_count: return False
1810 if self.byte_in_count != other.byte_in_count: return False
1811 if self.duration_sec != other.duration_sec: return False
1812 if self.duration_nsec != other.duration_nsec: return False
1813 if self.band_stats != other.band_stats: return False
1814 return True
1815
Rich Lanec2ee4b82013-04-24 17:12:38 -07001816 def pretty_print(self, q):
1817 q.text("meter_stats {")
1818 with q.group():
1819 with q.indent(2):
1820 q.breakable()
1821 q.text("meter_id = ");
1822 q.text("%#x" % self.meter_id)
1823 q.text(","); q.breakable()
1824 q.text("flow_count = ");
1825 q.text("%#x" % self.flow_count)
1826 q.text(","); q.breakable()
1827 q.text("packet_in_count = ");
1828 q.text("%#x" % self.packet_in_count)
1829 q.text(","); q.breakable()
1830 q.text("byte_in_count = ");
1831 q.text("%#x" % self.byte_in_count)
1832 q.text(","); q.breakable()
1833 q.text("duration_sec = ");
1834 q.text("%#x" % self.duration_sec)
1835 q.text(","); q.breakable()
1836 q.text("duration_nsec = ");
1837 q.text("%#x" % self.duration_nsec)
1838 q.text(","); q.breakable()
1839 q.text("band_stats = ");
1840 q.pp(self.band_stats)
1841 q.breakable()
1842 q.text('}')
1843
Rich Lane7dcdf022013-12-11 14:45:27 -08001844
1845class packet_queue(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001846
1847 def __init__(self, queue_id=None, port=None, properties=None):
1848 if queue_id != None:
1849 self.queue_id = queue_id
1850 else:
1851 self.queue_id = 0
1852 if port != None:
1853 self.port = port
1854 else:
1855 self.port = 0
1856 if properties != None:
1857 self.properties = properties
1858 else:
1859 self.properties = []
1860 return
1861
1862 def pack(self):
1863 packed = []
1864 packed.append(struct.pack("!L", self.queue_id))
Dan Talaycof6202252013-07-02 01:00:29 -07001865 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001866 packed.append(struct.pack("!H", 0)) # placeholder for len at index 2
1867 packed.append('\x00' * 6)
Rich Lane7dcdf022013-12-11 14:45:27 -08001868 packed.append(loxi.generic_util.pack_list(self.properties))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001869 length = sum([len(x) for x in packed])
1870 packed[2] = struct.pack("!H", length)
1871 return ''.join(packed)
1872
1873 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001874 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001875 obj = packet_queue()
Dan Talaycof6202252013-07-02 01:00:29 -07001876 obj.queue_id = reader.read("!L")[0]
1877 obj.port = util.unpack_port_no(reader)
1878 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001879 orig_reader = reader
1880 reader = orig_reader.slice(_len - (8 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001881 reader.skip(6)
Rich Lane7dcdf022013-12-11 14:45:27 -08001882 obj.properties = loxi.generic_util.unpack_list(reader, common.queue_prop.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001883 return obj
1884
1885 def __eq__(self, other):
1886 if type(self) != type(other): return False
1887 if self.queue_id != other.queue_id: return False
1888 if self.port != other.port: return False
1889 if self.properties != other.properties: return False
1890 return True
1891
Rich Lanec2ee4b82013-04-24 17:12:38 -07001892 def pretty_print(self, q):
1893 q.text("packet_queue {")
1894 with q.group():
1895 with q.indent(2):
1896 q.breakable()
1897 q.text("queue_id = ");
1898 q.text("%#x" % self.queue_id)
1899 q.text(","); q.breakable()
1900 q.text("port = ");
1901 q.text(util.pretty_port(self.port))
1902 q.text(","); q.breakable()
1903 q.text("properties = ");
1904 q.pp(self.properties)
1905 q.breakable()
1906 q.text('}')
1907
Rich Lane7dcdf022013-12-11 14:45:27 -08001908
1909class port_desc(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001910
1911 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):
1912 if port_no != None:
1913 self.port_no = port_no
1914 else:
1915 self.port_no = 0
1916 if hw_addr != None:
1917 self.hw_addr = hw_addr
1918 else:
1919 self.hw_addr = [0,0,0,0,0,0]
1920 if name != None:
1921 self.name = name
1922 else:
1923 self.name = ""
1924 if config != None:
1925 self.config = config
1926 else:
1927 self.config = 0
1928 if state != None:
1929 self.state = state
1930 else:
1931 self.state = 0
1932 if curr != None:
1933 self.curr = curr
1934 else:
1935 self.curr = 0
1936 if advertised != None:
1937 self.advertised = advertised
1938 else:
1939 self.advertised = 0
1940 if supported != None:
1941 self.supported = supported
1942 else:
1943 self.supported = 0
1944 if peer != None:
1945 self.peer = peer
1946 else:
1947 self.peer = 0
1948 if curr_speed != None:
1949 self.curr_speed = curr_speed
1950 else:
1951 self.curr_speed = 0
1952 if max_speed != None:
1953 self.max_speed = max_speed
1954 else:
1955 self.max_speed = 0
1956 return
1957
1958 def pack(self):
1959 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07001960 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001961 packed.append('\x00' * 4)
1962 packed.append(struct.pack("!6B", *self.hw_addr))
1963 packed.append('\x00' * 2)
1964 packed.append(struct.pack("!16s", self.name))
1965 packed.append(struct.pack("!L", self.config))
1966 packed.append(struct.pack("!L", self.state))
1967 packed.append(struct.pack("!L", self.curr))
1968 packed.append(struct.pack("!L", self.advertised))
1969 packed.append(struct.pack("!L", self.supported))
1970 packed.append(struct.pack("!L", self.peer))
1971 packed.append(struct.pack("!L", self.curr_speed))
1972 packed.append(struct.pack("!L", self.max_speed))
1973 return ''.join(packed)
1974
1975 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001976 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001977 obj = port_desc()
Dan Talaycof6202252013-07-02 01:00:29 -07001978 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001979 reader.skip(4)
1980 obj.hw_addr = list(reader.read('!6B'))
1981 reader.skip(2)
1982 obj.name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -07001983 obj.config = reader.read("!L")[0]
1984 obj.state = reader.read("!L")[0]
1985 obj.curr = reader.read("!L")[0]
1986 obj.advertised = reader.read("!L")[0]
1987 obj.supported = reader.read("!L")[0]
1988 obj.peer = reader.read("!L")[0]
1989 obj.curr_speed = reader.read("!L")[0]
1990 obj.max_speed = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001991 return obj
1992
1993 def __eq__(self, other):
1994 if type(self) != type(other): return False
1995 if self.port_no != other.port_no: return False
1996 if self.hw_addr != other.hw_addr: return False
1997 if self.name != other.name: return False
1998 if self.config != other.config: return False
1999 if self.state != other.state: return False
2000 if self.curr != other.curr: return False
2001 if self.advertised != other.advertised: return False
2002 if self.supported != other.supported: return False
2003 if self.peer != other.peer: return False
2004 if self.curr_speed != other.curr_speed: return False
2005 if self.max_speed != other.max_speed: return False
2006 return True
2007
Rich Lanec2ee4b82013-04-24 17:12:38 -07002008 def pretty_print(self, q):
2009 q.text("port_desc {")
2010 with q.group():
2011 with q.indent(2):
2012 q.breakable()
2013 q.text("port_no = ");
2014 q.text(util.pretty_port(self.port_no))
2015 q.text(","); q.breakable()
2016 q.text("hw_addr = ");
2017 q.text(util.pretty_mac(self.hw_addr))
2018 q.text(","); q.breakable()
2019 q.text("name = ");
2020 q.pp(self.name)
2021 q.text(","); q.breakable()
2022 q.text("config = ");
2023 q.text("%#x" % self.config)
2024 q.text(","); q.breakable()
2025 q.text("state = ");
2026 q.text("%#x" % self.state)
2027 q.text(","); q.breakable()
2028 q.text("curr = ");
2029 q.text("%#x" % self.curr)
2030 q.text(","); q.breakable()
2031 q.text("advertised = ");
2032 q.text("%#x" % self.advertised)
2033 q.text(","); q.breakable()
2034 q.text("supported = ");
2035 q.text("%#x" % self.supported)
2036 q.text(","); q.breakable()
2037 q.text("peer = ");
2038 q.text("%#x" % self.peer)
2039 q.text(","); q.breakable()
2040 q.text("curr_speed = ");
2041 q.text("%#x" % self.curr_speed)
2042 q.text(","); q.breakable()
2043 q.text("max_speed = ");
2044 q.text("%#x" % self.max_speed)
2045 q.breakable()
2046 q.text('}')
2047
Rich Lane7dcdf022013-12-11 14:45:27 -08002048
2049class port_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002050
2051 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):
2052 if port_no != None:
2053 self.port_no = port_no
2054 else:
2055 self.port_no = 0
2056 if rx_packets != None:
2057 self.rx_packets = rx_packets
2058 else:
2059 self.rx_packets = 0
2060 if tx_packets != None:
2061 self.tx_packets = tx_packets
2062 else:
2063 self.tx_packets = 0
2064 if rx_bytes != None:
2065 self.rx_bytes = rx_bytes
2066 else:
2067 self.rx_bytes = 0
2068 if tx_bytes != None:
2069 self.tx_bytes = tx_bytes
2070 else:
2071 self.tx_bytes = 0
2072 if rx_dropped != None:
2073 self.rx_dropped = rx_dropped
2074 else:
2075 self.rx_dropped = 0
2076 if tx_dropped != None:
2077 self.tx_dropped = tx_dropped
2078 else:
2079 self.tx_dropped = 0
2080 if rx_errors != None:
2081 self.rx_errors = rx_errors
2082 else:
2083 self.rx_errors = 0
2084 if tx_errors != None:
2085 self.tx_errors = tx_errors
2086 else:
2087 self.tx_errors = 0
2088 if rx_frame_err != None:
2089 self.rx_frame_err = rx_frame_err
2090 else:
2091 self.rx_frame_err = 0
2092 if rx_over_err != None:
2093 self.rx_over_err = rx_over_err
2094 else:
2095 self.rx_over_err = 0
2096 if rx_crc_err != None:
2097 self.rx_crc_err = rx_crc_err
2098 else:
2099 self.rx_crc_err = 0
2100 if collisions != None:
2101 self.collisions = collisions
2102 else:
2103 self.collisions = 0
2104 if duration_sec != None:
2105 self.duration_sec = duration_sec
2106 else:
2107 self.duration_sec = 0
2108 if duration_nsec != None:
2109 self.duration_nsec = duration_nsec
2110 else:
2111 self.duration_nsec = 0
2112 return
2113
2114 def pack(self):
2115 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07002116 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002117 packed.append('\x00' * 4)
2118 packed.append(struct.pack("!Q", self.rx_packets))
2119 packed.append(struct.pack("!Q", self.tx_packets))
2120 packed.append(struct.pack("!Q", self.rx_bytes))
2121 packed.append(struct.pack("!Q", self.tx_bytes))
2122 packed.append(struct.pack("!Q", self.rx_dropped))
2123 packed.append(struct.pack("!Q", self.tx_dropped))
2124 packed.append(struct.pack("!Q", self.rx_errors))
2125 packed.append(struct.pack("!Q", self.tx_errors))
2126 packed.append(struct.pack("!Q", self.rx_frame_err))
2127 packed.append(struct.pack("!Q", self.rx_over_err))
2128 packed.append(struct.pack("!Q", self.rx_crc_err))
2129 packed.append(struct.pack("!Q", self.collisions))
2130 packed.append(struct.pack("!L", self.duration_sec))
2131 packed.append(struct.pack("!L", self.duration_nsec))
2132 return ''.join(packed)
2133
2134 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002135 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002136 obj = port_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07002137 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002138 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07002139 obj.rx_packets = reader.read("!Q")[0]
2140 obj.tx_packets = reader.read("!Q")[0]
2141 obj.rx_bytes = reader.read("!Q")[0]
2142 obj.tx_bytes = reader.read("!Q")[0]
2143 obj.rx_dropped = reader.read("!Q")[0]
2144 obj.tx_dropped = reader.read("!Q")[0]
2145 obj.rx_errors = reader.read("!Q")[0]
2146 obj.tx_errors = reader.read("!Q")[0]
2147 obj.rx_frame_err = reader.read("!Q")[0]
2148 obj.rx_over_err = reader.read("!Q")[0]
2149 obj.rx_crc_err = reader.read("!Q")[0]
2150 obj.collisions = reader.read("!Q")[0]
2151 obj.duration_sec = reader.read("!L")[0]
2152 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002153 return obj
2154
2155 def __eq__(self, other):
2156 if type(self) != type(other): return False
2157 if self.port_no != other.port_no: return False
2158 if self.rx_packets != other.rx_packets: return False
2159 if self.tx_packets != other.tx_packets: return False
2160 if self.rx_bytes != other.rx_bytes: return False
2161 if self.tx_bytes != other.tx_bytes: return False
2162 if self.rx_dropped != other.rx_dropped: return False
2163 if self.tx_dropped != other.tx_dropped: return False
2164 if self.rx_errors != other.rx_errors: return False
2165 if self.tx_errors != other.tx_errors: return False
2166 if self.rx_frame_err != other.rx_frame_err: return False
2167 if self.rx_over_err != other.rx_over_err: return False
2168 if self.rx_crc_err != other.rx_crc_err: return False
2169 if self.collisions != other.collisions: return False
2170 if self.duration_sec != other.duration_sec: return False
2171 if self.duration_nsec != other.duration_nsec: return False
2172 return True
2173
Rich Lanec2ee4b82013-04-24 17:12:38 -07002174 def pretty_print(self, q):
2175 q.text("port_stats_entry {")
2176 with q.group():
2177 with q.indent(2):
2178 q.breakable()
2179 q.text("port_no = ");
2180 q.text(util.pretty_port(self.port_no))
2181 q.text(","); q.breakable()
2182 q.text("rx_packets = ");
2183 q.text("%#x" % self.rx_packets)
2184 q.text(","); q.breakable()
2185 q.text("tx_packets = ");
2186 q.text("%#x" % self.tx_packets)
2187 q.text(","); q.breakable()
2188 q.text("rx_bytes = ");
2189 q.text("%#x" % self.rx_bytes)
2190 q.text(","); q.breakable()
2191 q.text("tx_bytes = ");
2192 q.text("%#x" % self.tx_bytes)
2193 q.text(","); q.breakable()
2194 q.text("rx_dropped = ");
2195 q.text("%#x" % self.rx_dropped)
2196 q.text(","); q.breakable()
2197 q.text("tx_dropped = ");
2198 q.text("%#x" % self.tx_dropped)
2199 q.text(","); q.breakable()
2200 q.text("rx_errors = ");
2201 q.text("%#x" % self.rx_errors)
2202 q.text(","); q.breakable()
2203 q.text("tx_errors = ");
2204 q.text("%#x" % self.tx_errors)
2205 q.text(","); q.breakable()
2206 q.text("rx_frame_err = ");
2207 q.text("%#x" % self.rx_frame_err)
2208 q.text(","); q.breakable()
2209 q.text("rx_over_err = ");
2210 q.text("%#x" % self.rx_over_err)
2211 q.text(","); q.breakable()
2212 q.text("rx_crc_err = ");
2213 q.text("%#x" % self.rx_crc_err)
2214 q.text(","); q.breakable()
2215 q.text("collisions = ");
2216 q.text("%#x" % self.collisions)
2217 q.text(","); q.breakable()
2218 q.text("duration_sec = ");
2219 q.text("%#x" % self.duration_sec)
2220 q.text(","); q.breakable()
2221 q.text("duration_nsec = ");
2222 q.text("%#x" % self.duration_nsec)
2223 q.breakable()
2224 q.text('}')
2225
Rich Lane7dcdf022013-12-11 14:45:27 -08002226
2227class queue_prop(loxi.OFObject):
2228 subtypes = {}
2229
Rich Lane95f7fc92014-01-27 17:08:16 -08002230
2231 def __init__(self, type=None):
2232 if type != None:
2233 self.type = type
2234 else:
2235 self.type = 0
2236 return
2237
2238 def pack(self):
2239 packed = []
2240 packed.append(struct.pack("!H", self.type))
2241 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2242 packed.append('\x00' * 4)
2243 length = sum([len(x) for x in packed])
2244 packed[1] = struct.pack("!H", length)
2245 return ''.join(packed)
2246
Rich Lane7dcdf022013-12-11 14:45:27 -08002247 @staticmethod
2248 def unpack(reader):
2249 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -08002250 subclass = queue_prop.subtypes.get(subtype)
2251 if subclass:
2252 return subclass.unpack(reader)
2253
2254 obj = queue_prop()
2255 obj.type = reader.read("!H")[0]
2256 _len = reader.read("!H")[0]
2257 orig_reader = reader
2258 reader = orig_reader.slice(_len - (2 + 2))
2259 reader.skip(4)
2260 return obj
2261
2262 def __eq__(self, other):
2263 if type(self) != type(other): return False
2264 if self.type != other.type: return False
2265 return True
2266
2267 def pretty_print(self, q):
2268 q.text("queue_prop {")
2269 with q.group():
2270 with q.indent(2):
2271 q.breakable()
2272 q.breakable()
2273 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002274
2275
2276class queue_prop_experimenter(queue_prop):
2277 subtypes = {}
2278
Rich Lane95f7fc92014-01-27 17:08:16 -08002279 type = 65535
2280
2281 def __init__(self, experimenter=None, data=None):
2282 if experimenter != None:
2283 self.experimenter = experimenter
2284 else:
2285 self.experimenter = 0
2286 if data != None:
2287 self.data = data
2288 else:
2289 self.data = ''
2290 return
2291
2292 def pack(self):
2293 packed = []
2294 packed.append(struct.pack("!H", self.type))
2295 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2296 packed.append('\x00' * 4)
2297 packed.append(struct.pack("!L", self.experimenter))
2298 packed.append('\x00' * 4)
2299 packed.append(self.data)
2300 length = sum([len(x) for x in packed])
2301 packed[1] = struct.pack("!H", length)
2302 return ''.join(packed)
2303
Rich Lane7dcdf022013-12-11 14:45:27 -08002304 @staticmethod
2305 def unpack(reader):
2306 subtype, = reader.peek('!L', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -08002307 subclass = queue_prop_experimenter.subtypes.get(subtype)
2308 if subclass:
2309 return subclass.unpack(reader)
2310
2311 obj = queue_prop_experimenter()
2312 _type = reader.read("!H")[0]
2313 assert(_type == 65535)
2314 _len = reader.read("!H")[0]
2315 orig_reader = reader
2316 reader = orig_reader.slice(_len - (2 + 2))
2317 reader.skip(4)
2318 obj.experimenter = reader.read("!L")[0]
2319 reader.skip(4)
2320 obj.data = str(reader.read_all())
2321 return obj
2322
2323 def __eq__(self, other):
2324 if type(self) != type(other): return False
2325 if self.experimenter != other.experimenter: return False
2326 if self.data != other.data: return False
2327 return True
2328
2329 def pretty_print(self, q):
2330 q.text("queue_prop_experimenter {")
2331 with q.group():
2332 with q.indent(2):
2333 q.breakable()
2334 q.text("data = ");
2335 q.pp(self.data)
2336 q.breakable()
2337 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002338
2339queue_prop.subtypes[65535] = queue_prop_experimenter
2340
2341class queue_prop_max_rate(queue_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002342 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07002343
2344 def __init__(self, rate=None):
2345 if rate != None:
2346 self.rate = rate
2347 else:
2348 self.rate = 0
2349 return
2350
2351 def pack(self):
2352 packed = []
2353 packed.append(struct.pack("!H", self.type))
2354 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2355 packed.append('\x00' * 4)
2356 packed.append(struct.pack("!H", self.rate))
2357 packed.append('\x00' * 6)
2358 length = sum([len(x) for x in packed])
2359 packed[1] = struct.pack("!H", length)
2360 return ''.join(packed)
2361
2362 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002363 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002364 obj = queue_prop_max_rate()
Dan Talaycof6202252013-07-02 01:00:29 -07002365 _type = reader.read("!H")[0]
2366 assert(_type == 2)
2367 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002368 orig_reader = reader
2369 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002370 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07002371 obj.rate = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002372 reader.skip(6)
2373 return obj
2374
2375 def __eq__(self, other):
2376 if type(self) != type(other): return False
2377 if self.rate != other.rate: return False
2378 return True
2379
Rich Lanec2ee4b82013-04-24 17:12:38 -07002380 def pretty_print(self, q):
2381 q.text("queue_prop_max_rate {")
2382 with q.group():
2383 with q.indent(2):
2384 q.breakable()
2385 q.text("rate = ");
2386 q.text("%#x" % self.rate)
2387 q.breakable()
2388 q.text('}')
2389
Rich Lane7dcdf022013-12-11 14:45:27 -08002390queue_prop.subtypes[2] = queue_prop_max_rate
2391
2392class queue_prop_min_rate(queue_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002393 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07002394
2395 def __init__(self, rate=None):
2396 if rate != None:
2397 self.rate = rate
2398 else:
2399 self.rate = 0
2400 return
2401
2402 def pack(self):
2403 packed = []
2404 packed.append(struct.pack("!H", self.type))
2405 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2406 packed.append('\x00' * 4)
2407 packed.append(struct.pack("!H", self.rate))
2408 packed.append('\x00' * 6)
2409 length = sum([len(x) for x in packed])
2410 packed[1] = struct.pack("!H", length)
2411 return ''.join(packed)
2412
2413 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002414 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002415 obj = queue_prop_min_rate()
Dan Talaycof6202252013-07-02 01:00:29 -07002416 _type = reader.read("!H")[0]
2417 assert(_type == 1)
2418 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002419 orig_reader = reader
2420 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002421 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07002422 obj.rate = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002423 reader.skip(6)
2424 return obj
2425
2426 def __eq__(self, other):
2427 if type(self) != type(other): return False
2428 if self.rate != other.rate: return False
2429 return True
2430
Rich Lanec2ee4b82013-04-24 17:12:38 -07002431 def pretty_print(self, q):
2432 q.text("queue_prop_min_rate {")
2433 with q.group():
2434 with q.indent(2):
2435 q.breakable()
2436 q.text("rate = ");
2437 q.text("%#x" % self.rate)
2438 q.breakable()
2439 q.text('}')
2440
Rich Lane7dcdf022013-12-11 14:45:27 -08002441queue_prop.subtypes[1] = queue_prop_min_rate
2442
2443class queue_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002444
2445 def __init__(self, port_no=None, queue_id=None, tx_bytes=None, tx_packets=None, tx_errors=None, duration_sec=None, duration_nsec=None):
2446 if port_no != None:
2447 self.port_no = port_no
2448 else:
2449 self.port_no = 0
2450 if queue_id != None:
2451 self.queue_id = queue_id
2452 else:
2453 self.queue_id = 0
2454 if tx_bytes != None:
2455 self.tx_bytes = tx_bytes
2456 else:
2457 self.tx_bytes = 0
2458 if tx_packets != None:
2459 self.tx_packets = tx_packets
2460 else:
2461 self.tx_packets = 0
2462 if tx_errors != None:
2463 self.tx_errors = tx_errors
2464 else:
2465 self.tx_errors = 0
2466 if duration_sec != None:
2467 self.duration_sec = duration_sec
2468 else:
2469 self.duration_sec = 0
2470 if duration_nsec != None:
2471 self.duration_nsec = duration_nsec
2472 else:
2473 self.duration_nsec = 0
2474 return
2475
2476 def pack(self):
2477 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07002478 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002479 packed.append(struct.pack("!L", self.queue_id))
2480 packed.append(struct.pack("!Q", self.tx_bytes))
2481 packed.append(struct.pack("!Q", self.tx_packets))
2482 packed.append(struct.pack("!Q", self.tx_errors))
2483 packed.append(struct.pack("!L", self.duration_sec))
2484 packed.append(struct.pack("!L", self.duration_nsec))
2485 return ''.join(packed)
2486
2487 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002488 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002489 obj = queue_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07002490 obj.port_no = util.unpack_port_no(reader)
2491 obj.queue_id = reader.read("!L")[0]
2492 obj.tx_bytes = reader.read("!Q")[0]
2493 obj.tx_packets = reader.read("!Q")[0]
2494 obj.tx_errors = reader.read("!Q")[0]
2495 obj.duration_sec = reader.read("!L")[0]
2496 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002497 return obj
2498
2499 def __eq__(self, other):
2500 if type(self) != type(other): return False
2501 if self.port_no != other.port_no: return False
2502 if self.queue_id != other.queue_id: return False
2503 if self.tx_bytes != other.tx_bytes: return False
2504 if self.tx_packets != other.tx_packets: return False
2505 if self.tx_errors != other.tx_errors: return False
2506 if self.duration_sec != other.duration_sec: return False
2507 if self.duration_nsec != other.duration_nsec: return False
2508 return True
2509
Rich Lanec2ee4b82013-04-24 17:12:38 -07002510 def pretty_print(self, q):
2511 q.text("queue_stats_entry {")
2512 with q.group():
2513 with q.indent(2):
2514 q.breakable()
2515 q.text("port_no = ");
2516 q.text(util.pretty_port(self.port_no))
2517 q.text(","); q.breakable()
2518 q.text("queue_id = ");
2519 q.text("%#x" % self.queue_id)
2520 q.text(","); q.breakable()
2521 q.text("tx_bytes = ");
2522 q.text("%#x" % self.tx_bytes)
2523 q.text(","); q.breakable()
2524 q.text("tx_packets = ");
2525 q.text("%#x" % self.tx_packets)
2526 q.text(","); q.breakable()
2527 q.text("tx_errors = ");
2528 q.text("%#x" % self.tx_errors)
2529 q.text(","); q.breakable()
2530 q.text("duration_sec = ");
2531 q.text("%#x" % self.duration_sec)
2532 q.text(","); q.breakable()
2533 q.text("duration_nsec = ");
2534 q.text("%#x" % self.duration_nsec)
2535 q.breakable()
2536 q.text('}')
2537
Rich Lane7dcdf022013-12-11 14:45:27 -08002538
2539class table_feature_prop(loxi.OFObject):
2540 subtypes = {}
2541
Rich Lane95f7fc92014-01-27 17:08:16 -08002542
2543 def __init__(self, type=None):
2544 if type != None:
2545 self.type = type
2546 else:
2547 self.type = 0
2548 return
2549
2550 def pack(self):
2551 packed = []
2552 packed.append(struct.pack("!H", self.type))
2553 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
2554 length = sum([len(x) for x in packed])
2555 packed[1] = struct.pack("!H", length)
2556 return ''.join(packed)
2557
Rich Lane7dcdf022013-12-11 14:45:27 -08002558 @staticmethod
2559 def unpack(reader):
2560 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -08002561 subclass = table_feature_prop.subtypes.get(subtype)
2562 if subclass:
2563 return subclass.unpack(reader)
2564
2565 obj = table_feature_prop()
2566 obj.type = reader.read("!H")[0]
2567 _length = reader.read("!H")[0]
2568 orig_reader = reader
2569 reader = orig_reader.slice(_length - (2 + 2))
2570 return obj
2571
2572 def __eq__(self, other):
2573 if type(self) != type(other): return False
2574 if self.type != other.type: return False
2575 return True
2576
2577 def pretty_print(self, q):
2578 q.text("table_feature_prop {")
2579 with q.group():
2580 with q.indent(2):
2581 q.breakable()
2582 q.breakable()
2583 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002584
2585
2586class table_feature_prop_apply_actions(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002587 type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07002588
Dan Talaycof6202252013-07-02 01:00:29 -07002589 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002590 if action_ids != None:
2591 self.action_ids = action_ids
2592 else:
2593 self.action_ids = []
2594 return
2595
2596 def pack(self):
2597 packed = []
2598 packed.append(struct.pack("!H", self.type))
2599 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002600 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002601 length = sum([len(x) for x in packed])
2602 packed[1] = struct.pack("!H", length)
2603 return ''.join(packed)
2604
2605 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002606 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002607 obj = table_feature_prop_apply_actions()
Dan Talaycof6202252013-07-02 01:00:29 -07002608 _type = reader.read("!H")[0]
2609 assert(_type == 6)
2610 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002611 orig_reader = reader
2612 reader = orig_reader.slice(_length - (2 + 2))
2613 obj.action_ids = loxi.generic_util.unpack_list(reader, action_id.action_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002614 return obj
2615
2616 def __eq__(self, other):
2617 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002618 if self.action_ids != other.action_ids: return False
2619 return True
2620
Rich Lanec2ee4b82013-04-24 17:12:38 -07002621 def pretty_print(self, q):
2622 q.text("table_feature_prop_apply_actions {")
2623 with q.group():
2624 with q.indent(2):
2625 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002626 q.text("action_ids = ");
2627 q.pp(self.action_ids)
2628 q.breakable()
2629 q.text('}')
2630
Rich Lane7dcdf022013-12-11 14:45:27 -08002631table_feature_prop.subtypes[6] = table_feature_prop_apply_actions
2632
2633class table_feature_prop_apply_actions_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002634 type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07002635
Dan Talaycof6202252013-07-02 01:00:29 -07002636 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002637 if action_ids != None:
2638 self.action_ids = action_ids
2639 else:
2640 self.action_ids = []
2641 return
2642
2643 def pack(self):
2644 packed = []
2645 packed.append(struct.pack("!H", self.type))
2646 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002647 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002648 length = sum([len(x) for x in packed])
2649 packed[1] = struct.pack("!H", length)
2650 return ''.join(packed)
2651
2652 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002653 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002654 obj = table_feature_prop_apply_actions_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07002655 _type = reader.read("!H")[0]
2656 assert(_type == 7)
2657 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002658 orig_reader = reader
2659 reader = orig_reader.slice(_length - (2 + 2))
2660 obj.action_ids = loxi.generic_util.unpack_list(reader, action_id.action_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002661 return obj
2662
2663 def __eq__(self, other):
2664 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002665 if self.action_ids != other.action_ids: return False
2666 return True
2667
Rich Lanec2ee4b82013-04-24 17:12:38 -07002668 def pretty_print(self, q):
2669 q.text("table_feature_prop_apply_actions_miss {")
2670 with q.group():
2671 with q.indent(2):
2672 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002673 q.text("action_ids = ");
2674 q.pp(self.action_ids)
2675 q.breakable()
2676 q.text('}')
2677
Rich Lane7dcdf022013-12-11 14:45:27 -08002678table_feature_prop.subtypes[7] = table_feature_prop_apply_actions_miss
2679
2680class table_feature_prop_apply_setfield(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002681 type = 14
Rich Lanec2ee4b82013-04-24 17:12:38 -07002682
Dan Talaycof6202252013-07-02 01:00:29 -07002683 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002684 if oxm_ids != None:
2685 self.oxm_ids = oxm_ids
2686 else:
2687 self.oxm_ids = []
2688 return
2689
2690 def pack(self):
2691 packed = []
2692 packed.append(struct.pack("!H", self.type))
2693 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002694 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002695 length = sum([len(x) for x in packed])
2696 packed[1] = struct.pack("!H", length)
2697 return ''.join(packed)
2698
2699 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002700 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002701 obj = table_feature_prop_apply_setfield()
Dan Talaycof6202252013-07-02 01:00:29 -07002702 _type = reader.read("!H")[0]
2703 assert(_type == 14)
2704 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002705 orig_reader = reader
2706 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002707 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
2708 return obj
2709
2710 def __eq__(self, other):
2711 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002712 if self.oxm_ids != other.oxm_ids: return False
2713 return True
2714
Rich Lanec2ee4b82013-04-24 17:12:38 -07002715 def pretty_print(self, q):
2716 q.text("table_feature_prop_apply_setfield {")
2717 with q.group():
2718 with q.indent(2):
2719 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002720 q.text("oxm_ids = ");
2721 q.pp(self.oxm_ids)
2722 q.breakable()
2723 q.text('}')
2724
Rich Lane7dcdf022013-12-11 14:45:27 -08002725table_feature_prop.subtypes[14] = table_feature_prop_apply_setfield
2726
2727class table_feature_prop_apply_setfield_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002728 type = 15
Rich Lanec2ee4b82013-04-24 17:12:38 -07002729
Dan Talaycof6202252013-07-02 01:00:29 -07002730 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002731 if oxm_ids != None:
2732 self.oxm_ids = oxm_ids
2733 else:
2734 self.oxm_ids = []
2735 return
2736
2737 def pack(self):
2738 packed = []
2739 packed.append(struct.pack("!H", self.type))
2740 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002741 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002742 length = sum([len(x) for x in packed])
2743 packed[1] = struct.pack("!H", length)
2744 return ''.join(packed)
2745
2746 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002747 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002748 obj = table_feature_prop_apply_setfield_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07002749 _type = reader.read("!H")[0]
2750 assert(_type == 15)
2751 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002752 orig_reader = reader
2753 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002754 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
2755 return obj
2756
2757 def __eq__(self, other):
2758 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002759 if self.oxm_ids != other.oxm_ids: return False
2760 return True
2761
Rich Lanec2ee4b82013-04-24 17:12:38 -07002762 def pretty_print(self, q):
2763 q.text("table_feature_prop_apply_setfield_miss {")
2764 with q.group():
2765 with q.indent(2):
2766 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002767 q.text("oxm_ids = ");
2768 q.pp(self.oxm_ids)
2769 q.breakable()
2770 q.text('}')
2771
Rich Lane7dcdf022013-12-11 14:45:27 -08002772table_feature_prop.subtypes[15] = table_feature_prop_apply_setfield_miss
2773
2774class table_feature_prop_experimenter(table_feature_prop):
Rich Lane9ec3fca2014-02-26 16:22:56 -08002775 type = 65534
Rich Lanec2ee4b82013-04-24 17:12:38 -07002776
Dan Talaycof6202252013-07-02 01:00:29 -07002777 def __init__(self, experimenter=None, subtype=None, experimenter_data=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002778 if experimenter != None:
2779 self.experimenter = experimenter
2780 else:
2781 self.experimenter = 0
2782 if subtype != None:
2783 self.subtype = subtype
2784 else:
2785 self.subtype = 0
2786 if experimenter_data != None:
2787 self.experimenter_data = experimenter_data
2788 else:
Dan Talaycof6202252013-07-02 01:00:29 -07002789 self.experimenter_data = ''
Rich Lanec2ee4b82013-04-24 17:12:38 -07002790 return
2791
2792 def pack(self):
2793 packed = []
2794 packed.append(struct.pack("!H", self.type))
2795 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
2796 packed.append(struct.pack("!L", self.experimenter))
2797 packed.append(struct.pack("!L", self.subtype))
2798 packed.append(self.experimenter_data)
2799 length = sum([len(x) for x in packed])
2800 packed[1] = struct.pack("!H", length)
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 = table_feature_prop_experimenter()
Dan Talaycof6202252013-07-02 01:00:29 -07002806 _type = reader.read("!H")[0]
Rich Lane9ec3fca2014-02-26 16:22:56 -08002807 assert(_type == 65534)
Dan Talaycof6202252013-07-02 01:00:29 -07002808 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002809 orig_reader = reader
2810 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002811 obj.experimenter = reader.read("!L")[0]
2812 obj.subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002813 obj.experimenter_data = str(reader.read_all())
2814 return obj
2815
2816 def __eq__(self, other):
2817 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002818 if self.experimenter != other.experimenter: return False
2819 if self.subtype != other.subtype: return False
2820 if self.experimenter_data != other.experimenter_data: return False
2821 return True
2822
Rich Lanec2ee4b82013-04-24 17:12:38 -07002823 def pretty_print(self, q):
2824 q.text("table_feature_prop_experimenter {")
2825 with q.group():
2826 with q.indent(2):
2827 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002828 q.text("experimenter = ");
2829 q.text("%#x" % self.experimenter)
2830 q.text(","); q.breakable()
2831 q.text("subtype = ");
2832 q.text("%#x" % self.subtype)
2833 q.text(","); q.breakable()
2834 q.text("experimenter_data = ");
2835 q.pp(self.experimenter_data)
2836 q.breakable()
2837 q.text('}')
2838
Rich Lane9ec3fca2014-02-26 16:22:56 -08002839table_feature_prop.subtypes[65534] = table_feature_prop_experimenter
2840
2841class table_feature_prop_experimenter_miss(table_feature_prop):
2842 type = 65535
2843
2844 def __init__(self, experimenter=None, subtype=None, experimenter_data=None):
2845 if experimenter != None:
2846 self.experimenter = experimenter
2847 else:
2848 self.experimenter = 0
2849 if subtype != None:
2850 self.subtype = subtype
2851 else:
2852 self.subtype = 0
2853 if experimenter_data != None:
2854 self.experimenter_data = experimenter_data
2855 else:
2856 self.experimenter_data = ''
2857 return
2858
2859 def pack(self):
2860 packed = []
2861 packed.append(struct.pack("!H", self.type))
2862 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
2863 packed.append(struct.pack("!L", self.experimenter))
2864 packed.append(struct.pack("!L", self.subtype))
2865 packed.append(self.experimenter_data)
2866 length = sum([len(x) for x in packed])
2867 packed[1] = struct.pack("!H", length)
2868 return ''.join(packed)
2869
2870 @staticmethod
2871 def unpack(reader):
2872 obj = table_feature_prop_experimenter_miss()
2873 _type = reader.read("!H")[0]
2874 assert(_type == 65535)
2875 _length = reader.read("!H")[0]
2876 orig_reader = reader
2877 reader = orig_reader.slice(_length - (2 + 2))
2878 obj.experimenter = reader.read("!L")[0]
2879 obj.subtype = reader.read("!L")[0]
2880 obj.experimenter_data = str(reader.read_all())
2881 return obj
2882
2883 def __eq__(self, other):
2884 if type(self) != type(other): return False
2885 if self.experimenter != other.experimenter: return False
2886 if self.subtype != other.subtype: return False
2887 if self.experimenter_data != other.experimenter_data: return False
2888 return True
2889
2890 def pretty_print(self, q):
2891 q.text("table_feature_prop_experimenter_miss {")
2892 with q.group():
2893 with q.indent(2):
2894 q.breakable()
2895 q.text("experimenter = ");
2896 q.text("%#x" % self.experimenter)
2897 q.text(","); q.breakable()
2898 q.text("subtype = ");
2899 q.text("%#x" % self.subtype)
2900 q.text(","); q.breakable()
2901 q.text("experimenter_data = ");
2902 q.pp(self.experimenter_data)
2903 q.breakable()
2904 q.text('}')
2905
2906table_feature_prop.subtypes[65535] = table_feature_prop_experimenter_miss
Rich Lane7dcdf022013-12-11 14:45:27 -08002907
2908class table_feature_prop_instructions(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002909 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07002910
Dan Talaycof6202252013-07-02 01:00:29 -07002911 def __init__(self, instruction_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002912 if instruction_ids != None:
2913 self.instruction_ids = instruction_ids
2914 else:
2915 self.instruction_ids = []
2916 return
2917
2918 def pack(self):
2919 packed = []
2920 packed.append(struct.pack("!H", self.type))
2921 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002922 packed.append(loxi.generic_util.pack_list(self.instruction_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002923 length = sum([len(x) for x in packed])
2924 packed[1] = struct.pack("!H", length)
2925 return ''.join(packed)
2926
2927 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002928 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002929 obj = table_feature_prop_instructions()
Dan Talaycof6202252013-07-02 01:00:29 -07002930 _type = reader.read("!H")[0]
2931 assert(_type == 0)
2932 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002933 orig_reader = reader
2934 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec0d05d12014-03-11 18:02:24 -07002935 obj.instruction_ids = loxi.generic_util.unpack_list(reader, instruction_id.instruction_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002936 return obj
2937
2938 def __eq__(self, other):
2939 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002940 if self.instruction_ids != other.instruction_ids: return False
2941 return True
2942
Rich Lanec2ee4b82013-04-24 17:12:38 -07002943 def pretty_print(self, q):
2944 q.text("table_feature_prop_instructions {")
2945 with q.group():
2946 with q.indent(2):
2947 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002948 q.text("instruction_ids = ");
2949 q.pp(self.instruction_ids)
2950 q.breakable()
2951 q.text('}')
2952
Rich Lane7dcdf022013-12-11 14:45:27 -08002953table_feature_prop.subtypes[0] = table_feature_prop_instructions
2954
2955class table_feature_prop_instructions_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002956 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07002957
Dan Talaycof6202252013-07-02 01:00:29 -07002958 def __init__(self, instruction_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002959 if instruction_ids != None:
2960 self.instruction_ids = instruction_ids
2961 else:
2962 self.instruction_ids = []
2963 return
2964
2965 def pack(self):
2966 packed = []
2967 packed.append(struct.pack("!H", self.type))
2968 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002969 packed.append(loxi.generic_util.pack_list(self.instruction_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002970 length = sum([len(x) for x in packed])
2971 packed[1] = struct.pack("!H", length)
2972 return ''.join(packed)
2973
2974 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002975 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002976 obj = table_feature_prop_instructions_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07002977 _type = reader.read("!H")[0]
2978 assert(_type == 1)
2979 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002980 orig_reader = reader
2981 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec0d05d12014-03-11 18:02:24 -07002982 obj.instruction_ids = loxi.generic_util.unpack_list(reader, instruction_id.instruction_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002983 return obj
2984
2985 def __eq__(self, other):
2986 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002987 if self.instruction_ids != other.instruction_ids: return False
2988 return True
2989
Rich Lanec2ee4b82013-04-24 17:12:38 -07002990 def pretty_print(self, q):
2991 q.text("table_feature_prop_instructions_miss {")
2992 with q.group():
2993 with q.indent(2):
2994 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002995 q.text("instruction_ids = ");
2996 q.pp(self.instruction_ids)
2997 q.breakable()
2998 q.text('}')
2999
Rich Lane7dcdf022013-12-11 14:45:27 -08003000table_feature_prop.subtypes[1] = table_feature_prop_instructions_miss
3001
3002class table_feature_prop_match(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003003 type = 8
Rich Lanec2ee4b82013-04-24 17:12:38 -07003004
Dan Talaycof6202252013-07-02 01:00:29 -07003005 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003006 if oxm_ids != None:
3007 self.oxm_ids = oxm_ids
3008 else:
3009 self.oxm_ids = []
3010 return
3011
3012 def pack(self):
3013 packed = []
3014 packed.append(struct.pack("!H", self.type))
3015 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003016 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003017 length = sum([len(x) for x in packed])
3018 packed[1] = struct.pack("!H", length)
3019 return ''.join(packed)
3020
3021 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003022 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003023 obj = table_feature_prop_match()
Dan Talaycof6202252013-07-02 01:00:29 -07003024 _type = reader.read("!H")[0]
3025 assert(_type == 8)
3026 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003027 orig_reader = reader
3028 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003029 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
3030 return obj
3031
3032 def __eq__(self, other):
3033 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003034 if self.oxm_ids != other.oxm_ids: return False
3035 return True
3036
Rich Lanec2ee4b82013-04-24 17:12:38 -07003037 def pretty_print(self, q):
3038 q.text("table_feature_prop_match {")
3039 with q.group():
3040 with q.indent(2):
3041 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003042 q.text("oxm_ids = ");
3043 q.pp(self.oxm_ids)
3044 q.breakable()
3045 q.text('}')
3046
Rich Lane7dcdf022013-12-11 14:45:27 -08003047table_feature_prop.subtypes[8] = table_feature_prop_match
3048
3049class table_feature_prop_next_tables(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003050 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07003051
Dan Talaycof6202252013-07-02 01:00:29 -07003052 def __init__(self, next_table_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003053 if next_table_ids != None:
3054 self.next_table_ids = next_table_ids
3055 else:
3056 self.next_table_ids = []
3057 return
3058
3059 def pack(self):
3060 packed = []
3061 packed.append(struct.pack("!H", self.type))
3062 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003063 packed.append(loxi.generic_util.pack_list(self.next_table_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003064 length = sum([len(x) for x in packed])
3065 packed[1] = struct.pack("!H", length)
3066 return ''.join(packed)
3067
3068 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003069 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003070 obj = table_feature_prop_next_tables()
Dan Talaycof6202252013-07-02 01:00:29 -07003071 _type = reader.read("!H")[0]
3072 assert(_type == 2)
3073 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003074 orig_reader = reader
3075 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003076 obj.next_table_ids = loxi.generic_util.unpack_list(reader, common.uint8.unpack)
3077 return obj
3078
3079 def __eq__(self, other):
3080 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003081 if self.next_table_ids != other.next_table_ids: return False
3082 return True
3083
Rich Lanec2ee4b82013-04-24 17:12:38 -07003084 def pretty_print(self, q):
3085 q.text("table_feature_prop_next_tables {")
3086 with q.group():
3087 with q.indent(2):
3088 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003089 q.text("next_table_ids = ");
3090 q.pp(self.next_table_ids)
3091 q.breakable()
3092 q.text('}')
3093
Rich Lane7dcdf022013-12-11 14:45:27 -08003094table_feature_prop.subtypes[2] = table_feature_prop_next_tables
3095
3096class table_feature_prop_next_tables_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003097 type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07003098
Dan Talaycof6202252013-07-02 01:00:29 -07003099 def __init__(self, next_table_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003100 if next_table_ids != None:
3101 self.next_table_ids = next_table_ids
3102 else:
3103 self.next_table_ids = []
3104 return
3105
3106 def pack(self):
3107 packed = []
3108 packed.append(struct.pack("!H", self.type))
3109 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003110 packed.append(loxi.generic_util.pack_list(self.next_table_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003111 length = sum([len(x) for x in packed])
3112 packed[1] = struct.pack("!H", length)
3113 return ''.join(packed)
3114
3115 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003116 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003117 obj = table_feature_prop_next_tables_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07003118 _type = reader.read("!H")[0]
3119 assert(_type == 3)
3120 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003121 orig_reader = reader
3122 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003123 obj.next_table_ids = loxi.generic_util.unpack_list(reader, common.uint8.unpack)
3124 return obj
3125
3126 def __eq__(self, other):
3127 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003128 if self.next_table_ids != other.next_table_ids: return False
3129 return True
3130
Rich Lanec2ee4b82013-04-24 17:12:38 -07003131 def pretty_print(self, q):
3132 q.text("table_feature_prop_next_tables_miss {")
3133 with q.group():
3134 with q.indent(2):
3135 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003136 q.text("next_table_ids = ");
3137 q.pp(self.next_table_ids)
3138 q.breakable()
3139 q.text('}')
3140
Rich Lane7dcdf022013-12-11 14:45:27 -08003141table_feature_prop.subtypes[3] = table_feature_prop_next_tables_miss
3142
3143class table_feature_prop_wildcards(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003144 type = 10
Rich Lanec2ee4b82013-04-24 17:12:38 -07003145
Dan Talaycof6202252013-07-02 01:00:29 -07003146 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003147 if oxm_ids != None:
3148 self.oxm_ids = oxm_ids
3149 else:
3150 self.oxm_ids = []
3151 return
3152
3153 def pack(self):
3154 packed = []
3155 packed.append(struct.pack("!H", self.type))
3156 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003157 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003158 length = sum([len(x) for x in packed])
3159 packed[1] = struct.pack("!H", length)
3160 return ''.join(packed)
3161
3162 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003163 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003164 obj = table_feature_prop_wildcards()
Dan Talaycof6202252013-07-02 01:00:29 -07003165 _type = reader.read("!H")[0]
3166 assert(_type == 10)
3167 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003168 orig_reader = reader
3169 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003170 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
3171 return obj
3172
3173 def __eq__(self, other):
3174 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003175 if self.oxm_ids != other.oxm_ids: return False
3176 return True
3177
Rich Lanec2ee4b82013-04-24 17:12:38 -07003178 def pretty_print(self, q):
3179 q.text("table_feature_prop_wildcards {")
3180 with q.group():
3181 with q.indent(2):
3182 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003183 q.text("oxm_ids = ");
3184 q.pp(self.oxm_ids)
3185 q.breakable()
3186 q.text('}')
3187
Rich Lane7dcdf022013-12-11 14:45:27 -08003188table_feature_prop.subtypes[10] = table_feature_prop_wildcards
3189
3190class table_feature_prop_write_actions(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003191 type = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07003192
Dan Talaycof6202252013-07-02 01:00:29 -07003193 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003194 if action_ids != None:
3195 self.action_ids = action_ids
3196 else:
3197 self.action_ids = []
3198 return
3199
3200 def pack(self):
3201 packed = []
3202 packed.append(struct.pack("!H", self.type))
3203 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003204 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003205 length = sum([len(x) for x in packed])
3206 packed[1] = struct.pack("!H", length)
3207 return ''.join(packed)
3208
3209 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003210 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003211 obj = table_feature_prop_write_actions()
Dan Talaycof6202252013-07-02 01:00:29 -07003212 _type = reader.read("!H")[0]
3213 assert(_type == 4)
3214 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003215 orig_reader = reader
3216 reader = orig_reader.slice(_length - (2 + 2))
3217 obj.action_ids = loxi.generic_util.unpack_list(reader, action_id.action_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003218 return obj
3219
3220 def __eq__(self, other):
3221 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003222 if self.action_ids != other.action_ids: return False
3223 return True
3224
Rich Lanec2ee4b82013-04-24 17:12:38 -07003225 def pretty_print(self, q):
3226 q.text("table_feature_prop_write_actions {")
3227 with q.group():
3228 with q.indent(2):
3229 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003230 q.text("action_ids = ");
3231 q.pp(self.action_ids)
3232 q.breakable()
3233 q.text('}')
3234
Rich Lane7dcdf022013-12-11 14:45:27 -08003235table_feature_prop.subtypes[4] = table_feature_prop_write_actions
3236
3237class table_feature_prop_write_actions_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003238 type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07003239
Dan Talaycof6202252013-07-02 01:00:29 -07003240 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003241 if action_ids != None:
3242 self.action_ids = action_ids
3243 else:
3244 self.action_ids = []
3245 return
3246
3247 def pack(self):
3248 packed = []
3249 packed.append(struct.pack("!H", self.type))
3250 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003251 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003252 length = sum([len(x) for x in packed])
3253 packed[1] = struct.pack("!H", length)
3254 return ''.join(packed)
3255
3256 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003257 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003258 obj = table_feature_prop_write_actions_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07003259 _type = reader.read("!H")[0]
3260 assert(_type == 5)
3261 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003262 orig_reader = reader
3263 reader = orig_reader.slice(_length - (2 + 2))
3264 obj.action_ids = loxi.generic_util.unpack_list(reader, action_id.action_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003265 return obj
3266
3267 def __eq__(self, other):
3268 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003269 if self.action_ids != other.action_ids: return False
3270 return True
3271
Rich Lanec2ee4b82013-04-24 17:12:38 -07003272 def pretty_print(self, q):
3273 q.text("table_feature_prop_write_actions_miss {")
3274 with q.group():
3275 with q.indent(2):
3276 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003277 q.text("action_ids = ");
3278 q.pp(self.action_ids)
3279 q.breakable()
3280 q.text('}')
3281
Rich Lane7dcdf022013-12-11 14:45:27 -08003282table_feature_prop.subtypes[5] = table_feature_prop_write_actions_miss
3283
3284class table_feature_prop_write_setfield(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003285 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -07003286
Dan Talaycof6202252013-07-02 01:00:29 -07003287 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003288 if oxm_ids != None:
3289 self.oxm_ids = oxm_ids
3290 else:
3291 self.oxm_ids = []
3292 return
3293
3294 def pack(self):
3295 packed = []
3296 packed.append(struct.pack("!H", self.type))
3297 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003298 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003299 length = sum([len(x) for x in packed])
3300 packed[1] = struct.pack("!H", length)
3301 return ''.join(packed)
3302
3303 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003304 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003305 obj = table_feature_prop_write_setfield()
Dan Talaycof6202252013-07-02 01:00:29 -07003306 _type = reader.read("!H")[0]
3307 assert(_type == 12)
3308 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003309 orig_reader = reader
3310 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003311 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
3312 return obj
3313
3314 def __eq__(self, other):
3315 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003316 if self.oxm_ids != other.oxm_ids: return False
3317 return True
3318
Rich Lanec2ee4b82013-04-24 17:12:38 -07003319 def pretty_print(self, q):
3320 q.text("table_feature_prop_write_setfield {")
3321 with q.group():
3322 with q.indent(2):
3323 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003324 q.text("oxm_ids = ");
3325 q.pp(self.oxm_ids)
3326 q.breakable()
3327 q.text('}')
3328
Rich Lane7dcdf022013-12-11 14:45:27 -08003329table_feature_prop.subtypes[12] = table_feature_prop_write_setfield
3330
3331class table_feature_prop_write_setfield_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003332 type = 13
Rich Lanec2ee4b82013-04-24 17:12:38 -07003333
Dan Talaycof6202252013-07-02 01:00:29 -07003334 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003335 if oxm_ids != None:
3336 self.oxm_ids = oxm_ids
3337 else:
3338 self.oxm_ids = []
3339 return
3340
3341 def pack(self):
3342 packed = []
3343 packed.append(struct.pack("!H", self.type))
3344 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003345 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003346 length = sum([len(x) for x in packed])
3347 packed[1] = struct.pack("!H", length)
3348 return ''.join(packed)
3349
3350 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003351 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003352 obj = table_feature_prop_write_setfield_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07003353 _type = reader.read("!H")[0]
3354 assert(_type == 13)
3355 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003356 orig_reader = reader
3357 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003358 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
3359 return obj
3360
3361 def __eq__(self, other):
3362 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003363 if self.oxm_ids != other.oxm_ids: return False
3364 return True
3365
Rich Lanec2ee4b82013-04-24 17:12:38 -07003366 def pretty_print(self, q):
3367 q.text("table_feature_prop_write_setfield_miss {")
3368 with q.group():
3369 with q.indent(2):
3370 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003371 q.text("oxm_ids = ");
3372 q.pp(self.oxm_ids)
3373 q.breakable()
3374 q.text('}')
3375
Rich Lane7dcdf022013-12-11 14:45:27 -08003376table_feature_prop.subtypes[13] = table_feature_prop_write_setfield_miss
3377
3378class table_features(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003379
3380 def __init__(self, table_id=None, name=None, metadata_match=None, metadata_write=None, config=None, max_entries=None, properties=None):
3381 if table_id != None:
3382 self.table_id = table_id
3383 else:
3384 self.table_id = 0
3385 if name != None:
3386 self.name = name
3387 else:
3388 self.name = ""
3389 if metadata_match != None:
3390 self.metadata_match = metadata_match
3391 else:
3392 self.metadata_match = 0
3393 if metadata_write != None:
3394 self.metadata_write = metadata_write
3395 else:
3396 self.metadata_write = 0
3397 if config != None:
3398 self.config = config
3399 else:
3400 self.config = 0
3401 if max_entries != None:
3402 self.max_entries = max_entries
3403 else:
3404 self.max_entries = 0
3405 if properties != None:
3406 self.properties = properties
3407 else:
3408 self.properties = []
3409 return
3410
3411 def pack(self):
3412 packed = []
3413 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
3414 packed.append(struct.pack("!B", self.table_id))
3415 packed.append('\x00' * 5)
3416 packed.append(struct.pack("!32s", self.name))
3417 packed.append(struct.pack("!Q", self.metadata_match))
3418 packed.append(struct.pack("!Q", self.metadata_write))
3419 packed.append(struct.pack("!L", self.config))
3420 packed.append(struct.pack("!L", self.max_entries))
Rich Lane7dcdf022013-12-11 14:45:27 -08003421 packed.append(loxi.generic_util.pack_list(self.properties))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003422 length = sum([len(x) for x in packed])
3423 packed[0] = struct.pack("!H", length)
3424 return ''.join(packed)
3425
3426 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003427 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003428 obj = table_features()
Dan Talaycof6202252013-07-02 01:00:29 -07003429 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003430 orig_reader = reader
3431 reader = orig_reader.slice(_length - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003432 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003433 reader.skip(5)
3434 obj.name = reader.read("!32s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -07003435 obj.metadata_match = reader.read("!Q")[0]
3436 obj.metadata_write = reader.read("!Q")[0]
3437 obj.config = reader.read("!L")[0]
3438 obj.max_entries = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003439 obj.properties = loxi.generic_util.unpack_list(reader, common.table_feature_prop.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003440 return obj
3441
3442 def __eq__(self, other):
3443 if type(self) != type(other): return False
3444 if self.table_id != other.table_id: return False
3445 if self.name != other.name: return False
3446 if self.metadata_match != other.metadata_match: return False
3447 if self.metadata_write != other.metadata_write: return False
3448 if self.config != other.config: return False
3449 if self.max_entries != other.max_entries: return False
3450 if self.properties != other.properties: return False
3451 return True
3452
Rich Lanec2ee4b82013-04-24 17:12:38 -07003453 def pretty_print(self, q):
3454 q.text("table_features {")
3455 with q.group():
3456 with q.indent(2):
3457 q.breakable()
3458 q.text("table_id = ");
3459 q.text("%#x" % self.table_id)
3460 q.text(","); q.breakable()
3461 q.text("name = ");
3462 q.pp(self.name)
3463 q.text(","); q.breakable()
3464 q.text("metadata_match = ");
3465 q.text("%#x" % self.metadata_match)
3466 q.text(","); q.breakable()
3467 q.text("metadata_write = ");
3468 q.text("%#x" % self.metadata_write)
3469 q.text(","); q.breakable()
3470 q.text("config = ");
3471 q.text("%#x" % self.config)
3472 q.text(","); q.breakable()
3473 q.text("max_entries = ");
3474 q.text("%#x" % self.max_entries)
3475 q.text(","); q.breakable()
3476 q.text("properties = ");
3477 q.pp(self.properties)
3478 q.breakable()
3479 q.text('}')
3480
Rich Lane7dcdf022013-12-11 14:45:27 -08003481
3482class table_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003483
3484 def __init__(self, table_id=None, active_count=None, lookup_count=None, matched_count=None):
3485 if table_id != None:
3486 self.table_id = table_id
3487 else:
3488 self.table_id = 0
3489 if active_count != None:
3490 self.active_count = active_count
3491 else:
3492 self.active_count = 0
3493 if lookup_count != None:
3494 self.lookup_count = lookup_count
3495 else:
3496 self.lookup_count = 0
3497 if matched_count != None:
3498 self.matched_count = matched_count
3499 else:
3500 self.matched_count = 0
3501 return
3502
3503 def pack(self):
3504 packed = []
3505 packed.append(struct.pack("!B", self.table_id))
3506 packed.append('\x00' * 3)
3507 packed.append(struct.pack("!L", self.active_count))
3508 packed.append(struct.pack("!Q", self.lookup_count))
3509 packed.append(struct.pack("!Q", self.matched_count))
3510 return ''.join(packed)
3511
3512 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003513 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003514 obj = table_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07003515 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003516 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07003517 obj.active_count = reader.read("!L")[0]
3518 obj.lookup_count = reader.read("!Q")[0]
3519 obj.matched_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003520 return obj
3521
3522 def __eq__(self, other):
3523 if type(self) != type(other): return False
3524 if self.table_id != other.table_id: return False
3525 if self.active_count != other.active_count: return False
3526 if self.lookup_count != other.lookup_count: return False
3527 if self.matched_count != other.matched_count: return False
3528 return True
3529
Rich Lanec2ee4b82013-04-24 17:12:38 -07003530 def pretty_print(self, q):
3531 q.text("table_stats_entry {")
3532 with q.group():
3533 with q.indent(2):
3534 q.breakable()
3535 q.text("table_id = ");
3536 q.text("%#x" % self.table_id)
3537 q.text(","); q.breakable()
3538 q.text("active_count = ");
3539 q.text("%#x" % self.active_count)
3540 q.text(","); q.breakable()
3541 q.text("lookup_count = ");
3542 q.text("%#x" % self.lookup_count)
3543 q.text(","); q.breakable()
3544 q.text("matched_count = ");
3545 q.text("%#x" % self.matched_count)
3546 q.breakable()
3547 q.text('}')
3548
Rich Lane7dcdf022013-12-11 14:45:27 -08003549
3550class uint32(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003551
3552 def __init__(self, value=None):
3553 if value != None:
3554 self.value = value
3555 else:
3556 self.value = 0
3557 return
3558
3559 def pack(self):
3560 packed = []
3561 packed.append(struct.pack("!L", self.value))
3562 return ''.join(packed)
3563
3564 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003565 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003566 obj = uint32()
Dan Talaycof6202252013-07-02 01:00:29 -07003567 obj.value = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003568 return obj
3569
3570 def __eq__(self, other):
3571 if type(self) != type(other): return False
3572 if self.value != other.value: return False
3573 return True
3574
Rich Lanec2ee4b82013-04-24 17:12:38 -07003575 def pretty_print(self, q):
3576 q.text("uint32 {")
3577 with q.group():
3578 with q.indent(2):
3579 q.breakable()
3580 q.text("value = ");
3581 q.text("%#x" % self.value)
3582 q.breakable()
3583 q.text('}')
3584
Rich Lane7dcdf022013-12-11 14:45:27 -08003585
3586class uint64(loxi.OFObject):
3587
3588 def __init__(self, value=None):
3589 if value != None:
3590 self.value = value
3591 else:
3592 self.value = 0
3593 return
3594
3595 def pack(self):
3596 packed = []
3597 packed.append(struct.pack("!Q", self.value))
3598 return ''.join(packed)
3599
3600 @staticmethod
3601 def unpack(reader):
3602 obj = uint64()
3603 obj.value = reader.read("!Q")[0]
3604 return obj
3605
3606 def __eq__(self, other):
3607 if type(self) != type(other): return False
3608 if self.value != other.value: return False
3609 return True
3610
3611 def pretty_print(self, q):
3612 q.text("uint64 {")
3613 with q.group():
3614 with q.indent(2):
3615 q.breakable()
3616 q.text("value = ");
3617 q.text("%#x" % self.value)
3618 q.breakable()
3619 q.text('}')
3620
3621
3622class uint8(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003623
3624 def __init__(self, value=None):
3625 if value != None:
3626 self.value = value
3627 else:
3628 self.value = 0
3629 return
3630
3631 def pack(self):
3632 packed = []
3633 packed.append(struct.pack("!B", self.value))
3634 return ''.join(packed)
3635
3636 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003637 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003638 obj = uint8()
Dan Talaycof6202252013-07-02 01:00:29 -07003639 obj.value = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003640 return obj
3641
3642 def __eq__(self, other):
3643 if type(self) != type(other): return False
3644 if self.value != other.value: return False
3645 return True
3646
Rich Lanec2ee4b82013-04-24 17:12:38 -07003647 def pretty_print(self, q):
3648 q.text("uint8 {")
3649 with q.group():
3650 with q.indent(2):
3651 q.breakable()
3652 q.text("value = ");
3653 q.text("%#x" % self.value)
3654 q.breakable()
3655 q.text('}')
3656
3657
Rich Lane7dcdf022013-12-11 14:45:27 -08003658
Rich Lanec2ee4b82013-04-24 17:12:38 -07003659match = match_v3