blob: be5f8cd6b99569b406874110eca8231cf653d83b [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
91class bsn_gentable_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(util.pack_checksum_128(self.checksum))
103 return ''.join(packed)
104
105 @staticmethod
106 def unpack(reader):
107 obj = bsn_gentable_bucket_stats_entry()
108 obj.checksum = util.unpack_checksum_128(reader)
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_gentable_bucket_stats_entry {")
118 with q.group():
119 with q.indent(2):
120 q.breakable()
121 q.text("checksum = ");
122 q.pp(self.checksum)
123 q.breakable()
124 q.text('}')
125
126
127class bsn_gentable_desc_stats_entry(loxi.OFObject):
128
129 def __init__(self, table_id=None, name=None, buckets_size=None, max_entries=None):
130 if table_id != None:
131 self.table_id = table_id
132 else:
133 self.table_id = 0
134 if name != None:
135 self.name = name
136 else:
137 self.name = ""
138 if buckets_size != None:
139 self.buckets_size = buckets_size
140 else:
141 self.buckets_size = 0
142 if max_entries != None:
143 self.max_entries = max_entries
144 else:
145 self.max_entries = 0
146 return
147
148 def pack(self):
149 packed = []
150 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
151 packed.append(struct.pack("!H", self.table_id))
152 packed.append(struct.pack("!32s", self.name))
153 packed.append(struct.pack("!L", self.buckets_size))
154 packed.append(struct.pack("!L", self.max_entries))
155 packed.append('\x00' * 4)
156 length = sum([len(x) for x in packed])
157 packed[0] = struct.pack("!H", length)
158 return ''.join(packed)
159
160 @staticmethod
161 def unpack(reader):
162 obj = bsn_gentable_desc_stats_entry()
163 _length = reader.read("!H")[0]
164 orig_reader = reader
165 reader = orig_reader.slice(_length - (0 + 2))
166 obj.table_id = reader.read("!H")[0]
167 obj.name = reader.read("!32s")[0].rstrip("\x00")
168 obj.buckets_size = reader.read("!L")[0]
169 obj.max_entries = reader.read("!L")[0]
170 reader.skip(4)
171 return obj
172
173 def __eq__(self, other):
174 if type(self) != type(other): return False
175 if self.table_id != other.table_id: return False
176 if self.name != other.name: return False
177 if self.buckets_size != other.buckets_size: return False
178 if self.max_entries != other.max_entries: return False
179 return True
180
181 def pretty_print(self, q):
182 q.text("bsn_gentable_desc_stats_entry {")
183 with q.group():
184 with q.indent(2):
185 q.breakable()
186 q.text("table_id = ");
187 q.text("%#x" % self.table_id)
188 q.text(","); q.breakable()
189 q.text("name = ");
190 q.pp(self.name)
191 q.text(","); q.breakable()
192 q.text("buckets_size = ");
193 q.text("%#x" % self.buckets_size)
194 q.text(","); q.breakable()
195 q.text("max_entries = ");
196 q.text("%#x" % self.max_entries)
197 q.breakable()
198 q.text('}')
199
200
201class bsn_gentable_entry_desc_stats_entry(loxi.OFObject):
202
203 def __init__(self, checksum=None, key=None, value=None):
204 if checksum != None:
205 self.checksum = checksum
206 else:
207 self.checksum = 0
208 if key != None:
209 self.key = key
210 else:
211 self.key = []
212 if value != None:
213 self.value = value
214 else:
215 self.value = []
216 return
217
218 def pack(self):
219 packed = []
220 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
221 packed.append(struct.pack("!H", 0)) # placeholder for key_length at index 1
222 packed.append(util.pack_checksum_128(self.checksum))
223 packed.append(loxi.generic_util.pack_list(self.key))
224 packed[1] = struct.pack("!H", len(packed[-1]))
225 packed.append(loxi.generic_util.pack_list(self.value))
226 length = sum([len(x) for x in packed])
227 packed[0] = struct.pack("!H", length)
228 return ''.join(packed)
229
230 @staticmethod
231 def unpack(reader):
232 obj = bsn_gentable_entry_desc_stats_entry()
233 _length = reader.read("!H")[0]
234 orig_reader = reader
235 reader = orig_reader.slice(_length - (0 + 2))
236 _key_length = reader.read("!H")[0]
237 obj.checksum = util.unpack_checksum_128(reader)
238 obj.key = loxi.generic_util.unpack_list(reader.slice(_key_length), bsn_tlv.bsn_tlv.unpack)
239 obj.value = loxi.generic_util.unpack_list(reader, bsn_tlv.bsn_tlv.unpack)
240 return obj
241
242 def __eq__(self, other):
243 if type(self) != type(other): return False
244 if self.checksum != other.checksum: return False
245 if self.key != other.key: return False
246 if self.value != other.value: return False
247 return True
248
249 def pretty_print(self, q):
250 q.text("bsn_gentable_entry_desc_stats_entry {")
251 with q.group():
252 with q.indent(2):
253 q.breakable()
254 q.text("checksum = ");
255 q.pp(self.checksum)
256 q.text(","); q.breakable()
257 q.text("key = ");
258 q.pp(self.key)
259 q.text(","); q.breakable()
260 q.text("value = ");
261 q.pp(self.value)
262 q.breakable()
263 q.text('}')
264
265
266class bsn_gentable_entry_stats_entry(loxi.OFObject):
267
268 def __init__(self, key=None, stats=None):
269 if key != None:
270 self.key = key
271 else:
272 self.key = []
273 if stats != None:
274 self.stats = stats
275 else:
276 self.stats = []
277 return
278
279 def pack(self):
280 packed = []
281 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
282 packed.append(struct.pack("!H", 0)) # placeholder for key_length at index 1
283 packed.append(loxi.generic_util.pack_list(self.key))
284 packed[1] = struct.pack("!H", len(packed[-1]))
285 packed.append(loxi.generic_util.pack_list(self.stats))
286 length = sum([len(x) for x in packed])
287 packed[0] = struct.pack("!H", length)
288 return ''.join(packed)
289
290 @staticmethod
291 def unpack(reader):
292 obj = bsn_gentable_entry_stats_entry()
293 _length = reader.read("!H")[0]
294 orig_reader = reader
295 reader = orig_reader.slice(_length - (0 + 2))
296 _key_length = reader.read("!H")[0]
297 obj.key = loxi.generic_util.unpack_list(reader.slice(_key_length), bsn_tlv.bsn_tlv.unpack)
298 obj.stats = loxi.generic_util.unpack_list(reader, bsn_tlv.bsn_tlv.unpack)
299 return obj
300
301 def __eq__(self, other):
302 if type(self) != type(other): return False
303 if self.key != other.key: return False
304 if self.stats != other.stats: return False
305 return True
306
307 def pretty_print(self, q):
308 q.text("bsn_gentable_entry_stats_entry {")
309 with q.group():
310 with q.indent(2):
311 q.breakable()
312 q.text("key = ");
313 q.pp(self.key)
314 q.text(","); q.breakable()
315 q.text("stats = ");
316 q.pp(self.stats)
317 q.breakable()
318 q.text('}')
319
320
321class bsn_gentable_stats_entry(loxi.OFObject):
322
323 def __init__(self, table_id=None, entry_count=None, checksum=None):
324 if table_id != None:
325 self.table_id = table_id
326 else:
327 self.table_id = 0
328 if entry_count != None:
329 self.entry_count = entry_count
330 else:
331 self.entry_count = 0
332 if checksum != None:
333 self.checksum = checksum
334 else:
335 self.checksum = 0
336 return
337
338 def pack(self):
339 packed = []
340 packed.append(struct.pack("!H", self.table_id))
341 packed.append('\x00' * 2)
342 packed.append(struct.pack("!L", self.entry_count))
343 packed.append(util.pack_checksum_128(self.checksum))
344 return ''.join(packed)
345
346 @staticmethod
347 def unpack(reader):
348 obj = bsn_gentable_stats_entry()
349 obj.table_id = reader.read("!H")[0]
350 reader.skip(2)
351 obj.entry_count = reader.read("!L")[0]
352 obj.checksum = util.unpack_checksum_128(reader)
353 return obj
354
355 def __eq__(self, other):
356 if type(self) != type(other): return False
357 if self.table_id != other.table_id: return False
358 if self.entry_count != other.entry_count: return False
359 if self.checksum != other.checksum: return False
360 return True
361
362 def pretty_print(self, q):
363 q.text("bsn_gentable_stats_entry {")
364 with q.group():
365 with q.indent(2):
366 q.breakable()
367 q.text("table_id = ");
368 q.text("%#x" % self.table_id)
369 q.text(","); q.breakable()
370 q.text("entry_count = ");
371 q.text("%#x" % self.entry_count)
372 q.text(","); q.breakable()
373 q.text("checksum = ");
374 q.pp(self.checksum)
375 q.breakable()
376 q.text('}')
377
378
Rich Lane7dcdf022013-12-11 14:45:27 -0800379class bsn_interface(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700380
381 def __init__(self, hw_addr=None, name=None, ipv4_addr=None, ipv4_netmask=None):
382 if hw_addr != None:
383 self.hw_addr = hw_addr
384 else:
385 self.hw_addr = [0,0,0,0,0,0]
386 if name != None:
387 self.name = name
388 else:
389 self.name = ""
390 if ipv4_addr != None:
391 self.ipv4_addr = ipv4_addr
392 else:
393 self.ipv4_addr = 0
394 if ipv4_netmask != None:
395 self.ipv4_netmask = ipv4_netmask
396 else:
397 self.ipv4_netmask = 0
398 return
399
400 def pack(self):
401 packed = []
402 packed.append(struct.pack("!6B", *self.hw_addr))
403 packed.append('\x00' * 2)
404 packed.append(struct.pack("!16s", self.name))
405 packed.append(struct.pack("!L", self.ipv4_addr))
406 packed.append(struct.pack("!L", self.ipv4_netmask))
407 return ''.join(packed)
408
409 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800410 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700411 obj = bsn_interface()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700412 obj.hw_addr = list(reader.read('!6B'))
413 reader.skip(2)
414 obj.name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -0700415 obj.ipv4_addr = reader.read("!L")[0]
416 obj.ipv4_netmask = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700417 return obj
418
419 def __eq__(self, other):
420 if type(self) != type(other): return False
421 if self.hw_addr != other.hw_addr: return False
422 if self.name != other.name: return False
423 if self.ipv4_addr != other.ipv4_addr: return False
424 if self.ipv4_netmask != other.ipv4_netmask: return False
425 return True
426
Rich Lanec2ee4b82013-04-24 17:12:38 -0700427 def pretty_print(self, q):
428 q.text("bsn_interface {")
429 with q.group():
430 with q.indent(2):
431 q.breakable()
432 q.text("hw_addr = ");
433 q.text(util.pretty_mac(self.hw_addr))
434 q.text(","); q.breakable()
435 q.text("name = ");
436 q.pp(self.name)
437 q.text(","); q.breakable()
438 q.text("ipv4_addr = ");
439 q.text(util.pretty_ipv4(self.ipv4_addr))
440 q.text(","); q.breakable()
441 q.text("ipv4_netmask = ");
442 q.text(util.pretty_ipv4(self.ipv4_netmask))
443 q.breakable()
444 q.text('}')
445
Rich Lane7dcdf022013-12-11 14:45:27 -0800446
447class bsn_lacp_stats_entry(loxi.OFObject):
Rich Lane7b0f2012013-11-22 14:15:26 -0800448
449 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):
450 if port_no != None:
451 self.port_no = port_no
452 else:
453 self.port_no = 0
454 if actor_sys_priority != None:
455 self.actor_sys_priority = actor_sys_priority
456 else:
457 self.actor_sys_priority = 0
458 if actor_sys_mac != None:
459 self.actor_sys_mac = actor_sys_mac
460 else:
461 self.actor_sys_mac = [0,0,0,0,0,0]
462 if actor_port_priority != None:
463 self.actor_port_priority = actor_port_priority
464 else:
465 self.actor_port_priority = 0
466 if actor_port_num != None:
467 self.actor_port_num = actor_port_num
468 else:
469 self.actor_port_num = 0
470 if actor_key != None:
471 self.actor_key = actor_key
472 else:
473 self.actor_key = 0
474 if convergence_status != None:
475 self.convergence_status = convergence_status
476 else:
477 self.convergence_status = 0
478 if partner_sys_priority != None:
479 self.partner_sys_priority = partner_sys_priority
480 else:
481 self.partner_sys_priority = 0
482 if partner_sys_mac != None:
483 self.partner_sys_mac = partner_sys_mac
484 else:
485 self.partner_sys_mac = [0,0,0,0,0,0]
486 if partner_port_priority != None:
487 self.partner_port_priority = partner_port_priority
488 else:
489 self.partner_port_priority = 0
490 if partner_port_num != None:
491 self.partner_port_num = partner_port_num
492 else:
493 self.partner_port_num = 0
494 if partner_key != None:
495 self.partner_key = partner_key
496 else:
497 self.partner_key = 0
498 return
499
500 def pack(self):
501 packed = []
502 packed.append(util.pack_port_no(self.port_no))
503 packed.append(struct.pack("!H", self.actor_sys_priority))
504 packed.append(struct.pack("!6B", *self.actor_sys_mac))
505 packed.append(struct.pack("!H", self.actor_port_priority))
506 packed.append(struct.pack("!H", self.actor_port_num))
507 packed.append(struct.pack("!H", self.actor_key))
508 packed.append(struct.pack("!B", self.convergence_status))
509 packed.append('\x00' * 1)
510 packed.append(struct.pack("!H", self.partner_sys_priority))
511 packed.append(struct.pack("!6B", *self.partner_sys_mac))
512 packed.append(struct.pack("!H", self.partner_port_priority))
513 packed.append(struct.pack("!H", self.partner_port_num))
514 packed.append(struct.pack("!H", self.partner_key))
515 packed.append('\x00' * 2)
516 return ''.join(packed)
517
518 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800519 def unpack(reader):
Rich Lane7b0f2012013-11-22 14:15:26 -0800520 obj = bsn_lacp_stats_entry()
Rich Lane7b0f2012013-11-22 14:15:26 -0800521 obj.port_no = util.unpack_port_no(reader)
522 obj.actor_sys_priority = reader.read("!H")[0]
523 obj.actor_sys_mac = list(reader.read('!6B'))
524 obj.actor_port_priority = reader.read("!H")[0]
525 obj.actor_port_num = reader.read("!H")[0]
526 obj.actor_key = reader.read("!H")[0]
527 obj.convergence_status = reader.read("!B")[0]
528 reader.skip(1)
529 obj.partner_sys_priority = reader.read("!H")[0]
530 obj.partner_sys_mac = list(reader.read('!6B'))
531 obj.partner_port_priority = reader.read("!H")[0]
532 obj.partner_port_num = reader.read("!H")[0]
533 obj.partner_key = reader.read("!H")[0]
534 reader.skip(2)
535 return obj
536
537 def __eq__(self, other):
538 if type(self) != type(other): return False
539 if self.port_no != other.port_no: return False
540 if self.actor_sys_priority != other.actor_sys_priority: return False
541 if self.actor_sys_mac != other.actor_sys_mac: return False
542 if self.actor_port_priority != other.actor_port_priority: return False
543 if self.actor_port_num != other.actor_port_num: return False
544 if self.actor_key != other.actor_key: return False
545 if self.convergence_status != other.convergence_status: return False
546 if self.partner_sys_priority != other.partner_sys_priority: return False
547 if self.partner_sys_mac != other.partner_sys_mac: return False
548 if self.partner_port_priority != other.partner_port_priority: return False
549 if self.partner_port_num != other.partner_port_num: return False
550 if self.partner_key != other.partner_key: return False
551 return True
552
Rich Lane7b0f2012013-11-22 14:15:26 -0800553 def pretty_print(self, q):
554 q.text("bsn_lacp_stats_entry {")
555 with q.group():
556 with q.indent(2):
557 q.breakable()
558 q.text("port_no = ");
559 q.text(util.pretty_port(self.port_no))
560 q.text(","); q.breakable()
561 q.text("actor_sys_priority = ");
562 q.text("%#x" % self.actor_sys_priority)
563 q.text(","); q.breakable()
564 q.text("actor_sys_mac = ");
565 q.text(util.pretty_mac(self.actor_sys_mac))
566 q.text(","); q.breakable()
567 q.text("actor_port_priority = ");
568 q.text("%#x" % self.actor_port_priority)
569 q.text(","); q.breakable()
570 q.text("actor_port_num = ");
571 q.text("%#x" % self.actor_port_num)
572 q.text(","); q.breakable()
573 q.text("actor_key = ");
574 q.text("%#x" % self.actor_key)
575 q.text(","); q.breakable()
576 q.text("convergence_status = ");
577 q.text("%#x" % self.convergence_status)
578 q.text(","); q.breakable()
579 q.text("partner_sys_priority = ");
580 q.text("%#x" % self.partner_sys_priority)
581 q.text(","); q.breakable()
582 q.text("partner_sys_mac = ");
583 q.text(util.pretty_mac(self.partner_sys_mac))
584 q.text(","); q.breakable()
585 q.text("partner_port_priority = ");
586 q.text("%#x" % self.partner_port_priority)
587 q.text(","); q.breakable()
588 q.text("partner_port_num = ");
589 q.text("%#x" % self.partner_port_num)
590 q.text(","); q.breakable()
591 q.text("partner_key = ");
592 q.text("%#x" % self.partner_key)
593 q.breakable()
594 q.text('}')
595
Rich Lane7dcdf022013-12-11 14:45:27 -0800596
597class bsn_port_counter_stats_entry(loxi.OFObject):
598
599 def __init__(self, port_no=None, values=None):
600 if port_no != None:
601 self.port_no = port_no
602 else:
603 self.port_no = 0
604 if values != None:
605 self.values = values
606 else:
607 self.values = []
608 return
609
610 def pack(self):
611 packed = []
612 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
613 packed.append('\x00' * 2)
614 packed.append(util.pack_port_no(self.port_no))
615 packed.append(loxi.generic_util.pack_list(self.values))
616 length = sum([len(x) for x in packed])
617 packed[0] = struct.pack("!H", length)
618 return ''.join(packed)
619
620 @staticmethod
621 def unpack(reader):
622 obj = bsn_port_counter_stats_entry()
623 _length = reader.read("!H")[0]
624 orig_reader = reader
625 reader = orig_reader.slice(_length - (0 + 2))
626 reader.skip(2)
627 obj.port_no = util.unpack_port_no(reader)
628 obj.values = loxi.generic_util.unpack_list(reader, common.uint64.unpack)
629 return obj
630
631 def __eq__(self, other):
632 if type(self) != type(other): return False
633 if self.port_no != other.port_no: return False
634 if self.values != other.values: return False
635 return True
636
637 def pretty_print(self, q):
638 q.text("bsn_port_counter_stats_entry {")
639 with q.group():
640 with q.indent(2):
641 q.breakable()
642 q.text("port_no = ");
643 q.text(util.pretty_port(self.port_no))
644 q.text(","); q.breakable()
645 q.text("values = ");
646 q.pp(self.values)
647 q.breakable()
648 q.text('}')
649
650
651class bsn_switch_pipeline_stats_entry(loxi.OFObject):
652
653 def __init__(self, pipeline=None):
654 if pipeline != None:
655 self.pipeline = pipeline
656 else:
657 self.pipeline = ""
658 return
659
660 def pack(self):
661 packed = []
662 packed.append(struct.pack("!256s", self.pipeline))
663 return ''.join(packed)
664
665 @staticmethod
666 def unpack(reader):
667 obj = bsn_switch_pipeline_stats_entry()
668 obj.pipeline = reader.read("!256s")[0].rstrip("\x00")
669 return obj
670
671 def __eq__(self, other):
672 if type(self) != type(other): return False
673 if self.pipeline != other.pipeline: return False
674 return True
675
676 def pretty_print(self, q):
677 q.text("bsn_switch_pipeline_stats_entry {")
678 with q.group():
679 with q.indent(2):
680 q.breakable()
681 q.text("pipeline = ");
682 q.pp(self.pipeline)
683 q.breakable()
684 q.text('}')
685
686
687class bsn_vport(loxi.OFObject):
688 subtypes = {}
689
Rich Lane95f7fc92014-01-27 17:08:16 -0800690
691 def __init__(self, type=None):
692 if type != None:
693 self.type = type
694 else:
695 self.type = 0
696 return
697
698 def pack(self):
699 packed = []
700 packed.append(struct.pack("!H", self.type))
701 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
702 length = sum([len(x) for x in packed])
703 packed[1] = struct.pack("!H", length)
704 return ''.join(packed)
705
Rich Lane7dcdf022013-12-11 14:45:27 -0800706 @staticmethod
707 def unpack(reader):
708 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -0800709 subclass = bsn_vport.subtypes.get(subtype)
710 if subclass:
711 return subclass.unpack(reader)
712
713 obj = bsn_vport()
714 obj.type = reader.read("!H")[0]
715 _length = reader.read("!H")[0]
716 orig_reader = reader
717 reader = orig_reader.slice(_length - (2 + 2))
718 return obj
719
720 def __eq__(self, other):
721 if type(self) != type(other): return False
722 if self.type != other.type: return False
723 return True
724
725 def pretty_print(self, q):
726 q.text("bsn_vport {")
727 with q.group():
728 with q.indent(2):
729 q.breakable()
730 q.breakable()
731 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800732
733
734class bsn_vport_q_in_q(bsn_vport):
Dan Talaycof6202252013-07-02 01:00:29 -0700735 type = 0
736
Kiran Poola150d8b02013-09-20 13:30:39 -0700737 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 -0700738 if port_no != None:
739 self.port_no = port_no
740 else:
741 self.port_no = 0
742 if ingress_tpid != None:
743 self.ingress_tpid = ingress_tpid
744 else:
745 self.ingress_tpid = 0
746 if ingress_vlan_id != None:
747 self.ingress_vlan_id = ingress_vlan_id
748 else:
749 self.ingress_vlan_id = 0
750 if egress_tpid != None:
751 self.egress_tpid = egress_tpid
752 else:
753 self.egress_tpid = 0
754 if egress_vlan_id != None:
755 self.egress_vlan_id = egress_vlan_id
756 else:
757 self.egress_vlan_id = 0
Kiran Poola150d8b02013-09-20 13:30:39 -0700758 if if_name != None:
759 self.if_name = if_name
760 else:
761 self.if_name = ""
Dan Talaycof6202252013-07-02 01:00:29 -0700762 return
763
764 def pack(self):
765 packed = []
766 packed.append(struct.pack("!H", self.type))
Kiran Poola150d8b02013-09-20 13:30:39 -0700767 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700768 packed.append(struct.pack("!L", self.port_no))
769 packed.append(struct.pack("!H", self.ingress_tpid))
770 packed.append(struct.pack("!H", self.ingress_vlan_id))
771 packed.append(struct.pack("!H", self.egress_tpid))
772 packed.append(struct.pack("!H", self.egress_vlan_id))
Kiran Poola150d8b02013-09-20 13:30:39 -0700773 packed.append(struct.pack("!16s", self.if_name))
Dan Talaycof6202252013-07-02 01:00:29 -0700774 length = sum([len(x) for x in packed])
Kiran Poola150d8b02013-09-20 13:30:39 -0700775 packed[1] = struct.pack("!H", length)
Dan Talaycof6202252013-07-02 01:00:29 -0700776 return ''.join(packed)
777
778 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800779 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -0700780 obj = bsn_vport_q_in_q()
Dan Talaycof6202252013-07-02 01:00:29 -0700781 _type = reader.read("!H")[0]
782 assert(_type == 0)
783 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800784 orig_reader = reader
785 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700786 obj.port_no = reader.read("!L")[0]
787 obj.ingress_tpid = reader.read("!H")[0]
788 obj.ingress_vlan_id = reader.read("!H")[0]
789 obj.egress_tpid = reader.read("!H")[0]
790 obj.egress_vlan_id = reader.read("!H")[0]
Kiran Poola150d8b02013-09-20 13:30:39 -0700791 obj.if_name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -0700792 return obj
793
794 def __eq__(self, other):
795 if type(self) != type(other): return False
796 if self.port_no != other.port_no: return False
797 if self.ingress_tpid != other.ingress_tpid: return False
798 if self.ingress_vlan_id != other.ingress_vlan_id: return False
799 if self.egress_tpid != other.egress_tpid: return False
800 if self.egress_vlan_id != other.egress_vlan_id: return False
Kiran Poola150d8b02013-09-20 13:30:39 -0700801 if self.if_name != other.if_name: return False
Dan Talaycof6202252013-07-02 01:00:29 -0700802 return True
803
Dan Talaycof6202252013-07-02 01:00:29 -0700804 def pretty_print(self, q):
805 q.text("bsn_vport_q_in_q {")
806 with q.group():
807 with q.indent(2):
808 q.breakable()
809 q.text("port_no = ");
810 q.text("%#x" % self.port_no)
811 q.text(","); q.breakable()
812 q.text("ingress_tpid = ");
813 q.text("%#x" % self.ingress_tpid)
814 q.text(","); q.breakable()
815 q.text("ingress_vlan_id = ");
816 q.text("%#x" % self.ingress_vlan_id)
817 q.text(","); q.breakable()
818 q.text("egress_tpid = ");
819 q.text("%#x" % self.egress_tpid)
820 q.text(","); q.breakable()
821 q.text("egress_vlan_id = ");
822 q.text("%#x" % self.egress_vlan_id)
Kiran Poola150d8b02013-09-20 13:30:39 -0700823 q.text(","); q.breakable()
824 q.text("if_name = ");
825 q.pp(self.if_name)
Dan Talaycof6202252013-07-02 01:00:29 -0700826 q.breakable()
827 q.text('}')
828
Rich Lane7dcdf022013-12-11 14:45:27 -0800829bsn_vport.subtypes[0] = bsn_vport_q_in_q
830
831class bsn_vlan_counter_stats_entry(loxi.OFObject):
832
833 def __init__(self, vlan_vid=None, values=None):
834 if vlan_vid != None:
835 self.vlan_vid = vlan_vid
836 else:
837 self.vlan_vid = 0
838 if values != None:
839 self.values = values
840 else:
841 self.values = []
842 return
843
844 def pack(self):
845 packed = []
846 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
847 packed.append(struct.pack("!H", self.vlan_vid))
848 packed.append('\x00' * 4)
849 packed.append(loxi.generic_util.pack_list(self.values))
850 length = sum([len(x) for x in packed])
851 packed[0] = struct.pack("!H", length)
852 return ''.join(packed)
853
854 @staticmethod
855 def unpack(reader):
856 obj = bsn_vlan_counter_stats_entry()
857 _length = reader.read("!H")[0]
858 orig_reader = reader
859 reader = orig_reader.slice(_length - (0 + 2))
860 obj.vlan_vid = reader.read("!H")[0]
861 reader.skip(4)
862 obj.values = loxi.generic_util.unpack_list(reader, common.uint64.unpack)
863 return obj
864
865 def __eq__(self, other):
866 if type(self) != type(other): return False
867 if self.vlan_vid != other.vlan_vid: return False
868 if self.values != other.values: return False
869 return True
870
871 def pretty_print(self, q):
872 q.text("bsn_vlan_counter_stats_entry {")
873 with q.group():
874 with q.indent(2):
875 q.breakable()
876 q.text("vlan_vid = ");
877 q.text("%#x" % self.vlan_vid)
878 q.text(","); q.breakable()
879 q.text("values = ");
880 q.pp(self.values)
881 q.breakable()
882 q.text('}')
883
884
885class bucket(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700886
887 def __init__(self, weight=None, watch_port=None, watch_group=None, actions=None):
888 if weight != None:
889 self.weight = weight
890 else:
891 self.weight = 0
892 if watch_port != None:
893 self.watch_port = watch_port
894 else:
895 self.watch_port = 0
896 if watch_group != None:
897 self.watch_group = watch_group
898 else:
899 self.watch_group = 0
900 if actions != None:
901 self.actions = actions
902 else:
903 self.actions = []
904 return
905
906 def pack(self):
907 packed = []
908 packed.append(struct.pack("!H", 0)) # placeholder for len at index 0
909 packed.append(struct.pack("!H", self.weight))
Dan Talaycof6202252013-07-02 01:00:29 -0700910 packed.append(util.pack_port_no(self.watch_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700911 packed.append(struct.pack("!L", self.watch_group))
912 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -0800913 packed.append(loxi.generic_util.pack_list(self.actions))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700914 length = sum([len(x) for x in packed])
915 packed[0] = struct.pack("!H", length)
916 return ''.join(packed)
917
918 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800919 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700920 obj = bucket()
Dan Talaycof6202252013-07-02 01:00:29 -0700921 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800922 orig_reader = reader
923 reader = orig_reader.slice(_len - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700924 obj.weight = reader.read("!H")[0]
925 obj.watch_port = util.unpack_port_no(reader)
926 obj.watch_group = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700927 reader.skip(4)
Rich Lane7dcdf022013-12-11 14:45:27 -0800928 obj.actions = loxi.generic_util.unpack_list(reader, action.action.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700929 return obj
930
931 def __eq__(self, other):
932 if type(self) != type(other): return False
933 if self.weight != other.weight: return False
934 if self.watch_port != other.watch_port: return False
935 if self.watch_group != other.watch_group: return False
936 if self.actions != other.actions: return False
937 return True
938
Rich Lanec2ee4b82013-04-24 17:12:38 -0700939 def pretty_print(self, q):
940 q.text("bucket {")
941 with q.group():
942 with q.indent(2):
943 q.breakable()
944 q.text("weight = ");
945 q.text("%#x" % self.weight)
946 q.text(","); q.breakable()
947 q.text("watch_port = ");
948 q.text(util.pretty_port(self.watch_port))
949 q.text(","); q.breakable()
950 q.text("watch_group = ");
951 q.text("%#x" % self.watch_group)
952 q.text(","); q.breakable()
953 q.text("actions = ");
954 q.pp(self.actions)
955 q.breakable()
956 q.text('}')
957
Rich Lane7dcdf022013-12-11 14:45:27 -0800958
959class bucket_counter(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700960
961 def __init__(self, packet_count=None, byte_count=None):
962 if packet_count != None:
963 self.packet_count = packet_count
964 else:
965 self.packet_count = 0
966 if byte_count != None:
967 self.byte_count = byte_count
968 else:
969 self.byte_count = 0
970 return
971
972 def pack(self):
973 packed = []
974 packed.append(struct.pack("!Q", self.packet_count))
975 packed.append(struct.pack("!Q", self.byte_count))
976 return ''.join(packed)
977
978 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800979 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700980 obj = bucket_counter()
Dan Talaycof6202252013-07-02 01:00:29 -0700981 obj.packet_count = reader.read("!Q")[0]
982 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700983 return obj
984
985 def __eq__(self, other):
986 if type(self) != type(other): return False
987 if self.packet_count != other.packet_count: return False
988 if self.byte_count != other.byte_count: return False
989 return True
990
Rich Lanec2ee4b82013-04-24 17:12:38 -0700991 def pretty_print(self, q):
992 q.text("bucket_counter {")
993 with q.group():
994 with q.indent(2):
995 q.breakable()
996 q.text("packet_count = ");
997 q.text("%#x" % self.packet_count)
998 q.text(","); q.breakable()
999 q.text("byte_count = ");
1000 q.text("%#x" % self.byte_count)
1001 q.breakable()
1002 q.text('}')
1003
Rich Lane7dcdf022013-12-11 14:45:27 -08001004
1005class experimenter_stats_header(loxi.OFObject):
1006 subtypes = {}
1007
Rich Lane95f7fc92014-01-27 17:08:16 -08001008
1009 def __init__(self, experimenter=None, subtype=None):
1010 if experimenter != None:
1011 self.experimenter = experimenter
1012 else:
1013 self.experimenter = 0
1014 if subtype != None:
1015 self.subtype = subtype
1016 else:
1017 self.subtype = 0
1018 return
1019
1020 def pack(self):
1021 packed = []
1022 packed.append(struct.pack("!L", self.experimenter))
1023 packed.append(struct.pack("!L", self.subtype))
1024 return ''.join(packed)
1025
Rich Lane7dcdf022013-12-11 14:45:27 -08001026 @staticmethod
1027 def unpack(reader):
1028 subtype, = reader.peek('!L', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -08001029 subclass = experimenter_stats_header.subtypes.get(subtype)
1030 if subclass:
1031 return subclass.unpack(reader)
1032
1033 obj = experimenter_stats_header()
1034 obj.experimenter = reader.read("!L")[0]
1035 obj.subtype = reader.read("!L")[0]
1036 return obj
1037
1038 def __eq__(self, other):
1039 if type(self) != type(other): return False
1040 if self.experimenter != other.experimenter: return False
1041 if self.subtype != other.subtype: return False
1042 return True
1043
1044 def pretty_print(self, q):
1045 q.text("experimenter_stats_header {")
1046 with q.group():
1047 with q.indent(2):
1048 q.breakable()
1049 q.text("subtype = ");
1050 q.text("%#x" % self.subtype)
1051 q.breakable()
1052 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08001053
1054
1055class flow_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001056
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001057 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 -07001058 if table_id != None:
1059 self.table_id = table_id
1060 else:
1061 self.table_id = 0
1062 if duration_sec != None:
1063 self.duration_sec = duration_sec
1064 else:
1065 self.duration_sec = 0
1066 if duration_nsec != None:
1067 self.duration_nsec = duration_nsec
1068 else:
1069 self.duration_nsec = 0
1070 if priority != None:
1071 self.priority = priority
1072 else:
1073 self.priority = 0
1074 if idle_timeout != None:
1075 self.idle_timeout = idle_timeout
1076 else:
1077 self.idle_timeout = 0
1078 if hard_timeout != None:
1079 self.hard_timeout = hard_timeout
1080 else:
1081 self.hard_timeout = 0
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001082 if flags != None:
1083 self.flags = flags
1084 else:
1085 self.flags = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07001086 if cookie != None:
1087 self.cookie = cookie
1088 else:
1089 self.cookie = 0
1090 if packet_count != None:
1091 self.packet_count = packet_count
1092 else:
1093 self.packet_count = 0
1094 if byte_count != None:
1095 self.byte_count = byte_count
1096 else:
1097 self.byte_count = 0
1098 if match != None:
1099 self.match = match
1100 else:
1101 self.match = common.match()
1102 if instructions != None:
1103 self.instructions = instructions
1104 else:
1105 self.instructions = []
1106 return
1107
1108 def pack(self):
1109 packed = []
1110 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
1111 packed.append(struct.pack("!B", self.table_id))
1112 packed.append('\x00' * 1)
1113 packed.append(struct.pack("!L", self.duration_sec))
1114 packed.append(struct.pack("!L", self.duration_nsec))
1115 packed.append(struct.pack("!H", self.priority))
1116 packed.append(struct.pack("!H", self.idle_timeout))
1117 packed.append(struct.pack("!H", self.hard_timeout))
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001118 packed.append(struct.pack("!H", self.flags))
1119 packed.append('\x00' * 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001120 packed.append(struct.pack("!Q", self.cookie))
1121 packed.append(struct.pack("!Q", self.packet_count))
1122 packed.append(struct.pack("!Q", self.byte_count))
1123 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08001124 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001125 length = sum([len(x) for x in packed])
1126 packed[0] = struct.pack("!H", length)
1127 return ''.join(packed)
1128
1129 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001130 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001131 obj = flow_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001132 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001133 orig_reader = reader
1134 reader = orig_reader.slice(_length - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001135 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001136 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -07001137 obj.duration_sec = reader.read("!L")[0]
1138 obj.duration_nsec = reader.read("!L")[0]
1139 obj.priority = reader.read("!H")[0]
1140 obj.idle_timeout = reader.read("!H")[0]
1141 obj.hard_timeout = reader.read("!H")[0]
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001142 obj.flags = reader.read("!H")[0]
1143 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001144 obj.cookie = reader.read("!Q")[0]
1145 obj.packet_count = reader.read("!Q")[0]
1146 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001147 obj.match = common.match.unpack(reader)
Rich Lane7dcdf022013-12-11 14:45:27 -08001148 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001149 return obj
1150
1151 def __eq__(self, other):
1152 if type(self) != type(other): return False
1153 if self.table_id != other.table_id: return False
1154 if self.duration_sec != other.duration_sec: return False
1155 if self.duration_nsec != other.duration_nsec: return False
1156 if self.priority != other.priority: return False
1157 if self.idle_timeout != other.idle_timeout: return False
1158 if self.hard_timeout != other.hard_timeout: return False
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001159 if self.flags != other.flags: return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001160 if self.cookie != other.cookie: return False
1161 if self.packet_count != other.packet_count: return False
1162 if self.byte_count != other.byte_count: return False
1163 if self.match != other.match: return False
1164 if self.instructions != other.instructions: return False
1165 return True
1166
Rich Lanec2ee4b82013-04-24 17:12:38 -07001167 def pretty_print(self, q):
1168 q.text("flow_stats_entry {")
1169 with q.group():
1170 with q.indent(2):
1171 q.breakable()
1172 q.text("table_id = ");
1173 q.text("%#x" % self.table_id)
1174 q.text(","); q.breakable()
1175 q.text("duration_sec = ");
1176 q.text("%#x" % self.duration_sec)
1177 q.text(","); q.breakable()
1178 q.text("duration_nsec = ");
1179 q.text("%#x" % self.duration_nsec)
1180 q.text(","); q.breakable()
1181 q.text("priority = ");
1182 q.text("%#x" % self.priority)
1183 q.text(","); q.breakable()
1184 q.text("idle_timeout = ");
1185 q.text("%#x" % self.idle_timeout)
1186 q.text(","); q.breakable()
1187 q.text("hard_timeout = ");
1188 q.text("%#x" % self.hard_timeout)
1189 q.text(","); q.breakable()
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001190 q.text("flags = ");
1191 q.text("%#x" % self.flags)
1192 q.text(","); q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001193 q.text("cookie = ");
1194 q.text("%#x" % self.cookie)
1195 q.text(","); q.breakable()
1196 q.text("packet_count = ");
1197 q.text("%#x" % self.packet_count)
1198 q.text(","); q.breakable()
1199 q.text("byte_count = ");
1200 q.text("%#x" % self.byte_count)
1201 q.text(","); q.breakable()
1202 q.text("match = ");
1203 q.pp(self.match)
1204 q.text(","); q.breakable()
1205 q.text("instructions = ");
1206 q.pp(self.instructions)
1207 q.breakable()
1208 q.text('}')
1209
Rich Lane7dcdf022013-12-11 14:45:27 -08001210
1211class group_desc_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001212
Rich Lane6f4978c2013-10-20 21:33:52 -07001213 def __init__(self, group_type=None, group_id=None, buckets=None):
1214 if group_type != None:
1215 self.group_type = group_type
Rich Lanec2ee4b82013-04-24 17:12:38 -07001216 else:
Rich Lane6f4978c2013-10-20 21:33:52 -07001217 self.group_type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07001218 if group_id != None:
1219 self.group_id = group_id
1220 else:
1221 self.group_id = 0
1222 if buckets != None:
1223 self.buckets = buckets
1224 else:
1225 self.buckets = []
1226 return
1227
1228 def pack(self):
1229 packed = []
1230 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
Rich Lane6f4978c2013-10-20 21:33:52 -07001231 packed.append(struct.pack("!B", self.group_type))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001232 packed.append('\x00' * 1)
1233 packed.append(struct.pack("!L", self.group_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08001234 packed.append(loxi.generic_util.pack_list(self.buckets))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001235 length = sum([len(x) for x in packed])
1236 packed[0] = struct.pack("!H", length)
1237 return ''.join(packed)
1238
1239 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001240 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001241 obj = group_desc_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001242 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001243 orig_reader = reader
1244 reader = orig_reader.slice(_length - (0 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07001245 obj.group_type = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001246 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -07001247 obj.group_id = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001248 obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001249 return obj
1250
1251 def __eq__(self, other):
1252 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001253 if self.group_type != other.group_type: return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001254 if self.group_id != other.group_id: return False
1255 if self.buckets != other.buckets: return False
1256 return True
1257
Rich Lanec2ee4b82013-04-24 17:12:38 -07001258 def pretty_print(self, q):
1259 q.text("group_desc_stats_entry {")
1260 with q.group():
1261 with q.indent(2):
1262 q.breakable()
Rich Lane6f4978c2013-10-20 21:33:52 -07001263 q.text("group_type = ");
1264 q.text("%#x" % self.group_type)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001265 q.text(","); q.breakable()
1266 q.text("group_id = ");
1267 q.text("%#x" % self.group_id)
1268 q.text(","); q.breakable()
1269 q.text("buckets = ");
1270 q.pp(self.buckets)
1271 q.breakable()
1272 q.text('}')
1273
Rich Lane7dcdf022013-12-11 14:45:27 -08001274
1275class group_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001276
1277 def __init__(self, group_id=None, ref_count=None, packet_count=None, byte_count=None, duration_sec=None, duration_nsec=None, bucket_stats=None):
1278 if group_id != None:
1279 self.group_id = group_id
1280 else:
1281 self.group_id = 0
1282 if ref_count != None:
1283 self.ref_count = ref_count
1284 else:
1285 self.ref_count = 0
1286 if packet_count != None:
1287 self.packet_count = packet_count
1288 else:
1289 self.packet_count = 0
1290 if byte_count != None:
1291 self.byte_count = byte_count
1292 else:
1293 self.byte_count = 0
1294 if duration_sec != None:
1295 self.duration_sec = duration_sec
1296 else:
1297 self.duration_sec = 0
1298 if duration_nsec != None:
1299 self.duration_nsec = duration_nsec
1300 else:
1301 self.duration_nsec = 0
1302 if bucket_stats != None:
1303 self.bucket_stats = bucket_stats
1304 else:
1305 self.bucket_stats = []
1306 return
1307
1308 def pack(self):
1309 packed = []
1310 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
1311 packed.append('\x00' * 2)
1312 packed.append(struct.pack("!L", self.group_id))
1313 packed.append(struct.pack("!L", self.ref_count))
1314 packed.append('\x00' * 4)
1315 packed.append(struct.pack("!Q", self.packet_count))
1316 packed.append(struct.pack("!Q", self.byte_count))
1317 packed.append(struct.pack("!L", self.duration_sec))
1318 packed.append(struct.pack("!L", self.duration_nsec))
Rich Lane7dcdf022013-12-11 14:45:27 -08001319 packed.append(loxi.generic_util.pack_list(self.bucket_stats))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001320 length = sum([len(x) for x in packed])
1321 packed[0] = struct.pack("!H", length)
1322 return ''.join(packed)
1323
1324 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001325 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001326 obj = group_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001327 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001328 orig_reader = reader
1329 reader = orig_reader.slice(_length - (0 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001330 reader.skip(2)
Dan Talaycof6202252013-07-02 01:00:29 -07001331 obj.group_id = reader.read("!L")[0]
1332 obj.ref_count = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001333 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001334 obj.packet_count = reader.read("!Q")[0]
1335 obj.byte_count = reader.read("!Q")[0]
1336 obj.duration_sec = reader.read("!L")[0]
1337 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001338 obj.bucket_stats = loxi.generic_util.unpack_list(reader, common.bucket_counter.unpack)
1339 return obj
1340
1341 def __eq__(self, other):
1342 if type(self) != type(other): return False
1343 if self.group_id != other.group_id: return False
1344 if self.ref_count != other.ref_count: return False
1345 if self.packet_count != other.packet_count: return False
1346 if self.byte_count != other.byte_count: return False
1347 if self.duration_sec != other.duration_sec: return False
1348 if self.duration_nsec != other.duration_nsec: return False
1349 if self.bucket_stats != other.bucket_stats: return False
1350 return True
1351
Rich Lanec2ee4b82013-04-24 17:12:38 -07001352 def pretty_print(self, q):
1353 q.text("group_stats_entry {")
1354 with q.group():
1355 with q.indent(2):
1356 q.breakable()
1357 q.text("group_id = ");
1358 q.text("%#x" % self.group_id)
1359 q.text(","); q.breakable()
1360 q.text("ref_count = ");
1361 q.text("%#x" % self.ref_count)
1362 q.text(","); q.breakable()
1363 q.text("packet_count = ");
1364 q.text("%#x" % self.packet_count)
1365 q.text(","); q.breakable()
1366 q.text("byte_count = ");
1367 q.text("%#x" % self.byte_count)
1368 q.text(","); q.breakable()
1369 q.text("duration_sec = ");
1370 q.text("%#x" % self.duration_sec)
1371 q.text(","); q.breakable()
1372 q.text("duration_nsec = ");
1373 q.text("%#x" % self.duration_nsec)
1374 q.text(","); q.breakable()
1375 q.text("bucket_stats = ");
1376 q.pp(self.bucket_stats)
1377 q.breakable()
1378 q.text('}')
1379
Rich Lane7dcdf022013-12-11 14:45:27 -08001380
1381class hello_elem(loxi.OFObject):
1382 subtypes = {}
1383
Rich Lane95f7fc92014-01-27 17:08:16 -08001384
1385 def __init__(self, type=None):
1386 if type != None:
1387 self.type = type
1388 else:
1389 self.type = 0
1390 return
1391
1392 def pack(self):
1393 packed = []
1394 packed.append(struct.pack("!H", self.type))
1395 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
1396 length = sum([len(x) for x in packed])
1397 packed[1] = struct.pack("!H", length)
1398 return ''.join(packed)
1399
Rich Lane7dcdf022013-12-11 14:45:27 -08001400 @staticmethod
1401 def unpack(reader):
1402 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -08001403 subclass = hello_elem.subtypes.get(subtype)
1404 if subclass:
1405 return subclass.unpack(reader)
1406
1407 obj = hello_elem()
1408 obj.type = reader.read("!H")[0]
1409 _length = reader.read("!H")[0]
1410 orig_reader = reader
1411 reader = orig_reader.slice(_length - (2 + 2))
1412 return obj
1413
1414 def __eq__(self, other):
1415 if type(self) != type(other): return False
1416 if self.type != other.type: return False
1417 return True
1418
1419 def pretty_print(self, q):
1420 q.text("hello_elem {")
1421 with q.group():
1422 with q.indent(2):
1423 q.breakable()
1424 q.breakable()
1425 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08001426
1427
1428class hello_elem_versionbitmap(hello_elem):
Dan Talaycof6202252013-07-02 01:00:29 -07001429 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07001430
1431 def __init__(self, bitmaps=None):
1432 if bitmaps != None:
1433 self.bitmaps = bitmaps
1434 else:
1435 self.bitmaps = []
1436 return
1437
1438 def pack(self):
1439 packed = []
1440 packed.append(struct.pack("!H", self.type))
1441 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08001442 packed.append(loxi.generic_util.pack_list(self.bitmaps))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001443 length = sum([len(x) for x in packed])
1444 packed[1] = struct.pack("!H", length)
1445 return ''.join(packed)
1446
1447 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001448 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001449 obj = hello_elem_versionbitmap()
Dan Talaycof6202252013-07-02 01:00:29 -07001450 _type = reader.read("!H")[0]
1451 assert(_type == 1)
1452 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001453 orig_reader = reader
1454 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001455 obj.bitmaps = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
1456 return obj
1457
1458 def __eq__(self, other):
1459 if type(self) != type(other): return False
1460 if self.bitmaps != other.bitmaps: return False
1461 return True
1462
Rich Lanec2ee4b82013-04-24 17:12:38 -07001463 def pretty_print(self, q):
1464 q.text("hello_elem_versionbitmap {")
1465 with q.group():
1466 with q.indent(2):
1467 q.breakable()
1468 q.text("bitmaps = ");
1469 q.pp(self.bitmaps)
1470 q.breakable()
1471 q.text('}')
1472
Rich Lane7dcdf022013-12-11 14:45:27 -08001473hello_elem.subtypes[1] = hello_elem_versionbitmap
1474
1475class match_v3(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001476 type = 1
1477
1478 def __init__(self, oxm_list=None):
1479 if oxm_list != None:
1480 self.oxm_list = oxm_list
1481 else:
1482 self.oxm_list = []
1483 return
1484
1485 def pack(self):
1486 packed = []
1487 packed.append(struct.pack("!H", self.type))
1488 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08001489 packed.append(loxi.generic_util.pack_list(self.oxm_list))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001490 length = sum([len(x) for x in packed])
1491 packed[1] = struct.pack("!H", length)
Rich Laned53156a2013-08-05 17:17:33 -07001492 packed.append(loxi.generic_util.pad_to(8, length))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001493 return ''.join(packed)
1494
1495 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001496 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001497 obj = match_v3()
Dan Talaycof6202252013-07-02 01:00:29 -07001498 _type = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001499 assert(_type == 1)
Dan Talaycof6202252013-07-02 01:00:29 -07001500 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001501 orig_reader = reader
1502 reader = orig_reader.slice(_length - (2 + 2))
1503 obj.oxm_list = loxi.generic_util.unpack_list(reader, oxm.oxm.unpack)
1504 orig_reader.skip_align()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001505 return obj
1506
1507 def __eq__(self, other):
1508 if type(self) != type(other): return False
1509 if self.oxm_list != other.oxm_list: return False
1510 return True
1511
Rich Lanec2ee4b82013-04-24 17:12:38 -07001512 def pretty_print(self, q):
1513 q.text("match_v3 {")
1514 with q.group():
1515 with q.indent(2):
1516 q.breakable()
1517 q.text("oxm_list = ");
1518 q.pp(self.oxm_list)
1519 q.breakable()
1520 q.text('}')
1521
Rich Lane7dcdf022013-12-11 14:45:27 -08001522
1523class meter_band_stats(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001524
1525 def __init__(self, packet_band_count=None, byte_band_count=None):
1526 if packet_band_count != None:
1527 self.packet_band_count = packet_band_count
1528 else:
1529 self.packet_band_count = 0
1530 if byte_band_count != None:
1531 self.byte_band_count = byte_band_count
1532 else:
1533 self.byte_band_count = 0
1534 return
1535
1536 def pack(self):
1537 packed = []
1538 packed.append(struct.pack("!Q", self.packet_band_count))
1539 packed.append(struct.pack("!Q", self.byte_band_count))
1540 return ''.join(packed)
1541
1542 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001543 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001544 obj = meter_band_stats()
Dan Talaycof6202252013-07-02 01:00:29 -07001545 obj.packet_band_count = reader.read("!Q")[0]
1546 obj.byte_band_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001547 return obj
1548
1549 def __eq__(self, other):
1550 if type(self) != type(other): return False
1551 if self.packet_band_count != other.packet_band_count: return False
1552 if self.byte_band_count != other.byte_band_count: return False
1553 return True
1554
Rich Lanec2ee4b82013-04-24 17:12:38 -07001555 def pretty_print(self, q):
1556 q.text("meter_band_stats {")
1557 with q.group():
1558 with q.indent(2):
1559 q.breakable()
1560 q.text("packet_band_count = ");
1561 q.text("%#x" % self.packet_band_count)
1562 q.text(","); q.breakable()
1563 q.text("byte_band_count = ");
1564 q.text("%#x" % self.byte_band_count)
1565 q.breakable()
1566 q.text('}')
1567
Rich Lane7dcdf022013-12-11 14:45:27 -08001568
1569class meter_config(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001570
1571 def __init__(self, flags=None, meter_id=None, entries=None):
1572 if flags != None:
1573 self.flags = flags
1574 else:
1575 self.flags = 0
1576 if meter_id != None:
1577 self.meter_id = meter_id
1578 else:
1579 self.meter_id = 0
1580 if entries != None:
1581 self.entries = entries
1582 else:
1583 self.entries = []
1584 return
1585
1586 def pack(self):
1587 packed = []
1588 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
1589 packed.append(struct.pack("!H", self.flags))
1590 packed.append(struct.pack("!L", self.meter_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08001591 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001592 length = sum([len(x) for x in packed])
1593 packed[0] = struct.pack("!H", length)
1594 return ''.join(packed)
1595
1596 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001597 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001598 obj = meter_config()
Dan Talaycof6202252013-07-02 01:00:29 -07001599 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001600 orig_reader = reader
1601 reader = orig_reader.slice(_length - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001602 obj.flags = reader.read("!H")[0]
1603 obj.meter_id = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001604 obj.entries = loxi.generic_util.unpack_list(reader, meter_band.meter_band.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001605 return obj
1606
1607 def __eq__(self, other):
1608 if type(self) != type(other): return False
1609 if self.flags != other.flags: return False
1610 if self.meter_id != other.meter_id: return False
1611 if self.entries != other.entries: return False
1612 return True
1613
Rich Lanec2ee4b82013-04-24 17:12:38 -07001614 def pretty_print(self, q):
1615 q.text("meter_config {")
1616 with q.group():
1617 with q.indent(2):
1618 q.breakable()
1619 q.text("flags = ");
1620 q.text("%#x" % self.flags)
1621 q.text(","); q.breakable()
1622 q.text("meter_id = ");
1623 q.text("%#x" % self.meter_id)
1624 q.text(","); q.breakable()
1625 q.text("entries = ");
1626 q.pp(self.entries)
1627 q.breakable()
1628 q.text('}')
1629
Rich Lane7dcdf022013-12-11 14:45:27 -08001630
1631class meter_features(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001632
1633 def __init__(self, max_meter=None, band_types=None, capabilities=None, max_bands=None, max_color=None):
1634 if max_meter != None:
1635 self.max_meter = max_meter
1636 else:
1637 self.max_meter = 0
1638 if band_types != None:
1639 self.band_types = band_types
1640 else:
1641 self.band_types = 0
1642 if capabilities != None:
1643 self.capabilities = capabilities
1644 else:
1645 self.capabilities = 0
1646 if max_bands != None:
1647 self.max_bands = max_bands
1648 else:
1649 self.max_bands = 0
1650 if max_color != None:
1651 self.max_color = max_color
1652 else:
1653 self.max_color = 0
1654 return
1655
1656 def pack(self):
1657 packed = []
1658 packed.append(struct.pack("!L", self.max_meter))
1659 packed.append(struct.pack("!L", self.band_types))
1660 packed.append(struct.pack("!L", self.capabilities))
1661 packed.append(struct.pack("!B", self.max_bands))
1662 packed.append(struct.pack("!B", self.max_color))
1663 packed.append('\x00' * 2)
1664 return ''.join(packed)
1665
1666 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001667 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001668 obj = meter_features()
Dan Talaycof6202252013-07-02 01:00:29 -07001669 obj.max_meter = reader.read("!L")[0]
1670 obj.band_types = reader.read("!L")[0]
1671 obj.capabilities = reader.read("!L")[0]
1672 obj.max_bands = reader.read("!B")[0]
1673 obj.max_color = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001674 reader.skip(2)
1675 return obj
1676
1677 def __eq__(self, other):
1678 if type(self) != type(other): return False
1679 if self.max_meter != other.max_meter: return False
1680 if self.band_types != other.band_types: return False
1681 if self.capabilities != other.capabilities: return False
1682 if self.max_bands != other.max_bands: return False
1683 if self.max_color != other.max_color: return False
1684 return True
1685
Rich Lanec2ee4b82013-04-24 17:12:38 -07001686 def pretty_print(self, q):
1687 q.text("meter_features {")
1688 with q.group():
1689 with q.indent(2):
1690 q.breakable()
1691 q.text("max_meter = ");
1692 q.text("%#x" % self.max_meter)
1693 q.text(","); q.breakable()
1694 q.text("band_types = ");
1695 q.text("%#x" % self.band_types)
1696 q.text(","); q.breakable()
1697 q.text("capabilities = ");
1698 q.text("%#x" % self.capabilities)
1699 q.text(","); q.breakable()
1700 q.text("max_bands = ");
1701 q.text("%#x" % self.max_bands)
1702 q.text(","); q.breakable()
1703 q.text("max_color = ");
1704 q.text("%#x" % self.max_color)
1705 q.breakable()
1706 q.text('}')
1707
Rich Lane7dcdf022013-12-11 14:45:27 -08001708
1709class meter_stats(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001710
1711 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):
1712 if meter_id != None:
1713 self.meter_id = meter_id
1714 else:
1715 self.meter_id = 0
1716 if flow_count != None:
1717 self.flow_count = flow_count
1718 else:
1719 self.flow_count = 0
1720 if packet_in_count != None:
1721 self.packet_in_count = packet_in_count
1722 else:
1723 self.packet_in_count = 0
1724 if byte_in_count != None:
1725 self.byte_in_count = byte_in_count
1726 else:
1727 self.byte_in_count = 0
1728 if duration_sec != None:
1729 self.duration_sec = duration_sec
1730 else:
1731 self.duration_sec = 0
1732 if duration_nsec != None:
1733 self.duration_nsec = duration_nsec
1734 else:
1735 self.duration_nsec = 0
1736 if band_stats != None:
1737 self.band_stats = band_stats
1738 else:
1739 self.band_stats = []
1740 return
1741
1742 def pack(self):
1743 packed = []
1744 packed.append(struct.pack("!L", self.meter_id))
1745 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1746 packed.append('\x00' * 6)
1747 packed.append(struct.pack("!L", self.flow_count))
1748 packed.append(struct.pack("!Q", self.packet_in_count))
1749 packed.append(struct.pack("!Q", self.byte_in_count))
1750 packed.append(struct.pack("!L", self.duration_sec))
1751 packed.append(struct.pack("!L", self.duration_nsec))
Rich Lane7dcdf022013-12-11 14:45:27 -08001752 packed.append(loxi.generic_util.pack_list(self.band_stats))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001753 length = sum([len(x) for x in packed])
1754 packed[1] = struct.pack("!H", length)
1755 return ''.join(packed)
1756
1757 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001758 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001759 obj = meter_stats()
Dan Talaycof6202252013-07-02 01:00:29 -07001760 obj.meter_id = reader.read("!L")[0]
1761 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001762 orig_reader = reader
1763 reader = orig_reader.slice(_len - (4 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001764 reader.skip(6)
Dan Talaycof6202252013-07-02 01:00:29 -07001765 obj.flow_count = reader.read("!L")[0]
1766 obj.packet_in_count = reader.read("!Q")[0]
1767 obj.byte_in_count = reader.read("!Q")[0]
1768 obj.duration_sec = reader.read("!L")[0]
1769 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001770 obj.band_stats = loxi.generic_util.unpack_list(reader, common.meter_band_stats.unpack)
1771 return obj
1772
1773 def __eq__(self, other):
1774 if type(self) != type(other): return False
1775 if self.meter_id != other.meter_id: return False
1776 if self.flow_count != other.flow_count: return False
1777 if self.packet_in_count != other.packet_in_count: return False
1778 if self.byte_in_count != other.byte_in_count: return False
1779 if self.duration_sec != other.duration_sec: return False
1780 if self.duration_nsec != other.duration_nsec: return False
1781 if self.band_stats != other.band_stats: return False
1782 return True
1783
Rich Lanec2ee4b82013-04-24 17:12:38 -07001784 def pretty_print(self, q):
1785 q.text("meter_stats {")
1786 with q.group():
1787 with q.indent(2):
1788 q.breakable()
1789 q.text("meter_id = ");
1790 q.text("%#x" % self.meter_id)
1791 q.text(","); q.breakable()
1792 q.text("flow_count = ");
1793 q.text("%#x" % self.flow_count)
1794 q.text(","); q.breakable()
1795 q.text("packet_in_count = ");
1796 q.text("%#x" % self.packet_in_count)
1797 q.text(","); q.breakable()
1798 q.text("byte_in_count = ");
1799 q.text("%#x" % self.byte_in_count)
1800 q.text(","); q.breakable()
1801 q.text("duration_sec = ");
1802 q.text("%#x" % self.duration_sec)
1803 q.text(","); q.breakable()
1804 q.text("duration_nsec = ");
1805 q.text("%#x" % self.duration_nsec)
1806 q.text(","); q.breakable()
1807 q.text("band_stats = ");
1808 q.pp(self.band_stats)
1809 q.breakable()
1810 q.text('}')
1811
Rich Lane7dcdf022013-12-11 14:45:27 -08001812
1813class packet_queue(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001814
1815 def __init__(self, queue_id=None, port=None, properties=None):
1816 if queue_id != None:
1817 self.queue_id = queue_id
1818 else:
1819 self.queue_id = 0
1820 if port != None:
1821 self.port = port
1822 else:
1823 self.port = 0
1824 if properties != None:
1825 self.properties = properties
1826 else:
1827 self.properties = []
1828 return
1829
1830 def pack(self):
1831 packed = []
1832 packed.append(struct.pack("!L", self.queue_id))
Dan Talaycof6202252013-07-02 01:00:29 -07001833 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001834 packed.append(struct.pack("!H", 0)) # placeholder for len at index 2
1835 packed.append('\x00' * 6)
Rich Lane7dcdf022013-12-11 14:45:27 -08001836 packed.append(loxi.generic_util.pack_list(self.properties))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001837 length = sum([len(x) for x in packed])
1838 packed[2] = struct.pack("!H", length)
1839 return ''.join(packed)
1840
1841 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001842 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001843 obj = packet_queue()
Dan Talaycof6202252013-07-02 01:00:29 -07001844 obj.queue_id = reader.read("!L")[0]
1845 obj.port = util.unpack_port_no(reader)
1846 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001847 orig_reader = reader
1848 reader = orig_reader.slice(_len - (8 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001849 reader.skip(6)
Rich Lane7dcdf022013-12-11 14:45:27 -08001850 obj.properties = loxi.generic_util.unpack_list(reader, common.queue_prop.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001851 return obj
1852
1853 def __eq__(self, other):
1854 if type(self) != type(other): return False
1855 if self.queue_id != other.queue_id: return False
1856 if self.port != other.port: return False
1857 if self.properties != other.properties: return False
1858 return True
1859
Rich Lanec2ee4b82013-04-24 17:12:38 -07001860 def pretty_print(self, q):
1861 q.text("packet_queue {")
1862 with q.group():
1863 with q.indent(2):
1864 q.breakable()
1865 q.text("queue_id = ");
1866 q.text("%#x" % self.queue_id)
1867 q.text(","); q.breakable()
1868 q.text("port = ");
1869 q.text(util.pretty_port(self.port))
1870 q.text(","); q.breakable()
1871 q.text("properties = ");
1872 q.pp(self.properties)
1873 q.breakable()
1874 q.text('}')
1875
Rich Lane7dcdf022013-12-11 14:45:27 -08001876
1877class port_desc(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001878
1879 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):
1880 if port_no != None:
1881 self.port_no = port_no
1882 else:
1883 self.port_no = 0
1884 if hw_addr != None:
1885 self.hw_addr = hw_addr
1886 else:
1887 self.hw_addr = [0,0,0,0,0,0]
1888 if name != None:
1889 self.name = name
1890 else:
1891 self.name = ""
1892 if config != None:
1893 self.config = config
1894 else:
1895 self.config = 0
1896 if state != None:
1897 self.state = state
1898 else:
1899 self.state = 0
1900 if curr != None:
1901 self.curr = curr
1902 else:
1903 self.curr = 0
1904 if advertised != None:
1905 self.advertised = advertised
1906 else:
1907 self.advertised = 0
1908 if supported != None:
1909 self.supported = supported
1910 else:
1911 self.supported = 0
1912 if peer != None:
1913 self.peer = peer
1914 else:
1915 self.peer = 0
1916 if curr_speed != None:
1917 self.curr_speed = curr_speed
1918 else:
1919 self.curr_speed = 0
1920 if max_speed != None:
1921 self.max_speed = max_speed
1922 else:
1923 self.max_speed = 0
1924 return
1925
1926 def pack(self):
1927 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07001928 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001929 packed.append('\x00' * 4)
1930 packed.append(struct.pack("!6B", *self.hw_addr))
1931 packed.append('\x00' * 2)
1932 packed.append(struct.pack("!16s", self.name))
1933 packed.append(struct.pack("!L", self.config))
1934 packed.append(struct.pack("!L", self.state))
1935 packed.append(struct.pack("!L", self.curr))
1936 packed.append(struct.pack("!L", self.advertised))
1937 packed.append(struct.pack("!L", self.supported))
1938 packed.append(struct.pack("!L", self.peer))
1939 packed.append(struct.pack("!L", self.curr_speed))
1940 packed.append(struct.pack("!L", self.max_speed))
1941 return ''.join(packed)
1942
1943 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001944 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001945 obj = port_desc()
Dan Talaycof6202252013-07-02 01:00:29 -07001946 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001947 reader.skip(4)
1948 obj.hw_addr = list(reader.read('!6B'))
1949 reader.skip(2)
1950 obj.name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -07001951 obj.config = reader.read("!L")[0]
1952 obj.state = reader.read("!L")[0]
1953 obj.curr = reader.read("!L")[0]
1954 obj.advertised = reader.read("!L")[0]
1955 obj.supported = reader.read("!L")[0]
1956 obj.peer = reader.read("!L")[0]
1957 obj.curr_speed = reader.read("!L")[0]
1958 obj.max_speed = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001959 return obj
1960
1961 def __eq__(self, other):
1962 if type(self) != type(other): return False
1963 if self.port_no != other.port_no: return False
1964 if self.hw_addr != other.hw_addr: return False
1965 if self.name != other.name: return False
1966 if self.config != other.config: return False
1967 if self.state != other.state: return False
1968 if self.curr != other.curr: return False
1969 if self.advertised != other.advertised: return False
1970 if self.supported != other.supported: return False
1971 if self.peer != other.peer: return False
1972 if self.curr_speed != other.curr_speed: return False
1973 if self.max_speed != other.max_speed: return False
1974 return True
1975
Rich Lanec2ee4b82013-04-24 17:12:38 -07001976 def pretty_print(self, q):
1977 q.text("port_desc {")
1978 with q.group():
1979 with q.indent(2):
1980 q.breakable()
1981 q.text("port_no = ");
1982 q.text(util.pretty_port(self.port_no))
1983 q.text(","); q.breakable()
1984 q.text("hw_addr = ");
1985 q.text(util.pretty_mac(self.hw_addr))
1986 q.text(","); q.breakable()
1987 q.text("name = ");
1988 q.pp(self.name)
1989 q.text(","); q.breakable()
1990 q.text("config = ");
1991 q.text("%#x" % self.config)
1992 q.text(","); q.breakable()
1993 q.text("state = ");
1994 q.text("%#x" % self.state)
1995 q.text(","); q.breakable()
1996 q.text("curr = ");
1997 q.text("%#x" % self.curr)
1998 q.text(","); q.breakable()
1999 q.text("advertised = ");
2000 q.text("%#x" % self.advertised)
2001 q.text(","); q.breakable()
2002 q.text("supported = ");
2003 q.text("%#x" % self.supported)
2004 q.text(","); q.breakable()
2005 q.text("peer = ");
2006 q.text("%#x" % self.peer)
2007 q.text(","); q.breakable()
2008 q.text("curr_speed = ");
2009 q.text("%#x" % self.curr_speed)
2010 q.text(","); q.breakable()
2011 q.text("max_speed = ");
2012 q.text("%#x" % self.max_speed)
2013 q.breakable()
2014 q.text('}')
2015
Rich Lane7dcdf022013-12-11 14:45:27 -08002016
2017class port_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002018
2019 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):
2020 if port_no != None:
2021 self.port_no = port_no
2022 else:
2023 self.port_no = 0
2024 if rx_packets != None:
2025 self.rx_packets = rx_packets
2026 else:
2027 self.rx_packets = 0
2028 if tx_packets != None:
2029 self.tx_packets = tx_packets
2030 else:
2031 self.tx_packets = 0
2032 if rx_bytes != None:
2033 self.rx_bytes = rx_bytes
2034 else:
2035 self.rx_bytes = 0
2036 if tx_bytes != None:
2037 self.tx_bytes = tx_bytes
2038 else:
2039 self.tx_bytes = 0
2040 if rx_dropped != None:
2041 self.rx_dropped = rx_dropped
2042 else:
2043 self.rx_dropped = 0
2044 if tx_dropped != None:
2045 self.tx_dropped = tx_dropped
2046 else:
2047 self.tx_dropped = 0
2048 if rx_errors != None:
2049 self.rx_errors = rx_errors
2050 else:
2051 self.rx_errors = 0
2052 if tx_errors != None:
2053 self.tx_errors = tx_errors
2054 else:
2055 self.tx_errors = 0
2056 if rx_frame_err != None:
2057 self.rx_frame_err = rx_frame_err
2058 else:
2059 self.rx_frame_err = 0
2060 if rx_over_err != None:
2061 self.rx_over_err = rx_over_err
2062 else:
2063 self.rx_over_err = 0
2064 if rx_crc_err != None:
2065 self.rx_crc_err = rx_crc_err
2066 else:
2067 self.rx_crc_err = 0
2068 if collisions != None:
2069 self.collisions = collisions
2070 else:
2071 self.collisions = 0
2072 if duration_sec != None:
2073 self.duration_sec = duration_sec
2074 else:
2075 self.duration_sec = 0
2076 if duration_nsec != None:
2077 self.duration_nsec = duration_nsec
2078 else:
2079 self.duration_nsec = 0
2080 return
2081
2082 def pack(self):
2083 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07002084 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002085 packed.append('\x00' * 4)
2086 packed.append(struct.pack("!Q", self.rx_packets))
2087 packed.append(struct.pack("!Q", self.tx_packets))
2088 packed.append(struct.pack("!Q", self.rx_bytes))
2089 packed.append(struct.pack("!Q", self.tx_bytes))
2090 packed.append(struct.pack("!Q", self.rx_dropped))
2091 packed.append(struct.pack("!Q", self.tx_dropped))
2092 packed.append(struct.pack("!Q", self.rx_errors))
2093 packed.append(struct.pack("!Q", self.tx_errors))
2094 packed.append(struct.pack("!Q", self.rx_frame_err))
2095 packed.append(struct.pack("!Q", self.rx_over_err))
2096 packed.append(struct.pack("!Q", self.rx_crc_err))
2097 packed.append(struct.pack("!Q", self.collisions))
2098 packed.append(struct.pack("!L", self.duration_sec))
2099 packed.append(struct.pack("!L", self.duration_nsec))
2100 return ''.join(packed)
2101
2102 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002103 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002104 obj = port_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07002105 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002106 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07002107 obj.rx_packets = reader.read("!Q")[0]
2108 obj.tx_packets = reader.read("!Q")[0]
2109 obj.rx_bytes = reader.read("!Q")[0]
2110 obj.tx_bytes = reader.read("!Q")[0]
2111 obj.rx_dropped = reader.read("!Q")[0]
2112 obj.tx_dropped = reader.read("!Q")[0]
2113 obj.rx_errors = reader.read("!Q")[0]
2114 obj.tx_errors = reader.read("!Q")[0]
2115 obj.rx_frame_err = reader.read("!Q")[0]
2116 obj.rx_over_err = reader.read("!Q")[0]
2117 obj.rx_crc_err = reader.read("!Q")[0]
2118 obj.collisions = reader.read("!Q")[0]
2119 obj.duration_sec = reader.read("!L")[0]
2120 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002121 return obj
2122
2123 def __eq__(self, other):
2124 if type(self) != type(other): return False
2125 if self.port_no != other.port_no: return False
2126 if self.rx_packets != other.rx_packets: return False
2127 if self.tx_packets != other.tx_packets: return False
2128 if self.rx_bytes != other.rx_bytes: return False
2129 if self.tx_bytes != other.tx_bytes: return False
2130 if self.rx_dropped != other.rx_dropped: return False
2131 if self.tx_dropped != other.tx_dropped: return False
2132 if self.rx_errors != other.rx_errors: return False
2133 if self.tx_errors != other.tx_errors: return False
2134 if self.rx_frame_err != other.rx_frame_err: return False
2135 if self.rx_over_err != other.rx_over_err: return False
2136 if self.rx_crc_err != other.rx_crc_err: return False
2137 if self.collisions != other.collisions: return False
2138 if self.duration_sec != other.duration_sec: return False
2139 if self.duration_nsec != other.duration_nsec: return False
2140 return True
2141
Rich Lanec2ee4b82013-04-24 17:12:38 -07002142 def pretty_print(self, q):
2143 q.text("port_stats_entry {")
2144 with q.group():
2145 with q.indent(2):
2146 q.breakable()
2147 q.text("port_no = ");
2148 q.text(util.pretty_port(self.port_no))
2149 q.text(","); q.breakable()
2150 q.text("rx_packets = ");
2151 q.text("%#x" % self.rx_packets)
2152 q.text(","); q.breakable()
2153 q.text("tx_packets = ");
2154 q.text("%#x" % self.tx_packets)
2155 q.text(","); q.breakable()
2156 q.text("rx_bytes = ");
2157 q.text("%#x" % self.rx_bytes)
2158 q.text(","); q.breakable()
2159 q.text("tx_bytes = ");
2160 q.text("%#x" % self.tx_bytes)
2161 q.text(","); q.breakable()
2162 q.text("rx_dropped = ");
2163 q.text("%#x" % self.rx_dropped)
2164 q.text(","); q.breakable()
2165 q.text("tx_dropped = ");
2166 q.text("%#x" % self.tx_dropped)
2167 q.text(","); q.breakable()
2168 q.text("rx_errors = ");
2169 q.text("%#x" % self.rx_errors)
2170 q.text(","); q.breakable()
2171 q.text("tx_errors = ");
2172 q.text("%#x" % self.tx_errors)
2173 q.text(","); q.breakable()
2174 q.text("rx_frame_err = ");
2175 q.text("%#x" % self.rx_frame_err)
2176 q.text(","); q.breakable()
2177 q.text("rx_over_err = ");
2178 q.text("%#x" % self.rx_over_err)
2179 q.text(","); q.breakable()
2180 q.text("rx_crc_err = ");
2181 q.text("%#x" % self.rx_crc_err)
2182 q.text(","); q.breakable()
2183 q.text("collisions = ");
2184 q.text("%#x" % self.collisions)
2185 q.text(","); q.breakable()
2186 q.text("duration_sec = ");
2187 q.text("%#x" % self.duration_sec)
2188 q.text(","); q.breakable()
2189 q.text("duration_nsec = ");
2190 q.text("%#x" % self.duration_nsec)
2191 q.breakable()
2192 q.text('}')
2193
Rich Lane7dcdf022013-12-11 14:45:27 -08002194
2195class queue_prop(loxi.OFObject):
2196 subtypes = {}
2197
Rich Lane95f7fc92014-01-27 17:08:16 -08002198
2199 def __init__(self, type=None):
2200 if type != None:
2201 self.type = type
2202 else:
2203 self.type = 0
2204 return
2205
2206 def pack(self):
2207 packed = []
2208 packed.append(struct.pack("!H", self.type))
2209 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2210 packed.append('\x00' * 4)
2211 length = sum([len(x) for x in packed])
2212 packed[1] = struct.pack("!H", length)
2213 return ''.join(packed)
2214
Rich Lane7dcdf022013-12-11 14:45:27 -08002215 @staticmethod
2216 def unpack(reader):
2217 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -08002218 subclass = queue_prop.subtypes.get(subtype)
2219 if subclass:
2220 return subclass.unpack(reader)
2221
2222 obj = queue_prop()
2223 obj.type = reader.read("!H")[0]
2224 _len = reader.read("!H")[0]
2225 orig_reader = reader
2226 reader = orig_reader.slice(_len - (2 + 2))
2227 reader.skip(4)
2228 return obj
2229
2230 def __eq__(self, other):
2231 if type(self) != type(other): return False
2232 if self.type != other.type: return False
2233 return True
2234
2235 def pretty_print(self, q):
2236 q.text("queue_prop {")
2237 with q.group():
2238 with q.indent(2):
2239 q.breakable()
2240 q.breakable()
2241 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002242
2243
2244class queue_prop_experimenter(queue_prop):
2245 subtypes = {}
2246
Rich Lane95f7fc92014-01-27 17:08:16 -08002247 type = 65535
2248
2249 def __init__(self, experimenter=None, data=None):
2250 if experimenter != None:
2251 self.experimenter = experimenter
2252 else:
2253 self.experimenter = 0
2254 if data != None:
2255 self.data = data
2256 else:
2257 self.data = ''
2258 return
2259
2260 def pack(self):
2261 packed = []
2262 packed.append(struct.pack("!H", self.type))
2263 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2264 packed.append('\x00' * 4)
2265 packed.append(struct.pack("!L", self.experimenter))
2266 packed.append('\x00' * 4)
2267 packed.append(self.data)
2268 length = sum([len(x) for x in packed])
2269 packed[1] = struct.pack("!H", length)
2270 return ''.join(packed)
2271
Rich Lane7dcdf022013-12-11 14:45:27 -08002272 @staticmethod
2273 def unpack(reader):
2274 subtype, = reader.peek('!L', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -08002275 subclass = queue_prop_experimenter.subtypes.get(subtype)
2276 if subclass:
2277 return subclass.unpack(reader)
2278
2279 obj = queue_prop_experimenter()
2280 _type = reader.read("!H")[0]
2281 assert(_type == 65535)
2282 _len = reader.read("!H")[0]
2283 orig_reader = reader
2284 reader = orig_reader.slice(_len - (2 + 2))
2285 reader.skip(4)
2286 obj.experimenter = reader.read("!L")[0]
2287 reader.skip(4)
2288 obj.data = str(reader.read_all())
2289 return obj
2290
2291 def __eq__(self, other):
2292 if type(self) != type(other): return False
2293 if self.experimenter != other.experimenter: return False
2294 if self.data != other.data: return False
2295 return True
2296
2297 def pretty_print(self, q):
2298 q.text("queue_prop_experimenter {")
2299 with q.group():
2300 with q.indent(2):
2301 q.breakable()
2302 q.text("data = ");
2303 q.pp(self.data)
2304 q.breakable()
2305 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002306
2307queue_prop.subtypes[65535] = queue_prop_experimenter
2308
2309class queue_prop_max_rate(queue_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002310 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07002311
2312 def __init__(self, rate=None):
2313 if rate != None:
2314 self.rate = rate
2315 else:
2316 self.rate = 0
2317 return
2318
2319 def pack(self):
2320 packed = []
2321 packed.append(struct.pack("!H", self.type))
2322 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2323 packed.append('\x00' * 4)
2324 packed.append(struct.pack("!H", self.rate))
2325 packed.append('\x00' * 6)
2326 length = sum([len(x) for x in packed])
2327 packed[1] = struct.pack("!H", length)
2328 return ''.join(packed)
2329
2330 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002331 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002332 obj = queue_prop_max_rate()
Dan Talaycof6202252013-07-02 01:00:29 -07002333 _type = reader.read("!H")[0]
2334 assert(_type == 2)
2335 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002336 orig_reader = reader
2337 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002338 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07002339 obj.rate = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002340 reader.skip(6)
2341 return obj
2342
2343 def __eq__(self, other):
2344 if type(self) != type(other): return False
2345 if self.rate != other.rate: return False
2346 return True
2347
Rich Lanec2ee4b82013-04-24 17:12:38 -07002348 def pretty_print(self, q):
2349 q.text("queue_prop_max_rate {")
2350 with q.group():
2351 with q.indent(2):
2352 q.breakable()
2353 q.text("rate = ");
2354 q.text("%#x" % self.rate)
2355 q.breakable()
2356 q.text('}')
2357
Rich Lane7dcdf022013-12-11 14:45:27 -08002358queue_prop.subtypes[2] = queue_prop_max_rate
2359
2360class queue_prop_min_rate(queue_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002361 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07002362
2363 def __init__(self, rate=None):
2364 if rate != None:
2365 self.rate = rate
2366 else:
2367 self.rate = 0
2368 return
2369
2370 def pack(self):
2371 packed = []
2372 packed.append(struct.pack("!H", self.type))
2373 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2374 packed.append('\x00' * 4)
2375 packed.append(struct.pack("!H", self.rate))
2376 packed.append('\x00' * 6)
2377 length = sum([len(x) for x in packed])
2378 packed[1] = struct.pack("!H", length)
2379 return ''.join(packed)
2380
2381 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002382 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002383 obj = queue_prop_min_rate()
Dan Talaycof6202252013-07-02 01:00:29 -07002384 _type = reader.read("!H")[0]
2385 assert(_type == 1)
2386 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002387 orig_reader = reader
2388 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002389 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07002390 obj.rate = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002391 reader.skip(6)
2392 return obj
2393
2394 def __eq__(self, other):
2395 if type(self) != type(other): return False
2396 if self.rate != other.rate: return False
2397 return True
2398
Rich Lanec2ee4b82013-04-24 17:12:38 -07002399 def pretty_print(self, q):
2400 q.text("queue_prop_min_rate {")
2401 with q.group():
2402 with q.indent(2):
2403 q.breakable()
2404 q.text("rate = ");
2405 q.text("%#x" % self.rate)
2406 q.breakable()
2407 q.text('}')
2408
Rich Lane7dcdf022013-12-11 14:45:27 -08002409queue_prop.subtypes[1] = queue_prop_min_rate
2410
2411class queue_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002412
2413 def __init__(self, port_no=None, queue_id=None, tx_bytes=None, tx_packets=None, tx_errors=None, duration_sec=None, duration_nsec=None):
2414 if port_no != None:
2415 self.port_no = port_no
2416 else:
2417 self.port_no = 0
2418 if queue_id != None:
2419 self.queue_id = queue_id
2420 else:
2421 self.queue_id = 0
2422 if tx_bytes != None:
2423 self.tx_bytes = tx_bytes
2424 else:
2425 self.tx_bytes = 0
2426 if tx_packets != None:
2427 self.tx_packets = tx_packets
2428 else:
2429 self.tx_packets = 0
2430 if tx_errors != None:
2431 self.tx_errors = tx_errors
2432 else:
2433 self.tx_errors = 0
2434 if duration_sec != None:
2435 self.duration_sec = duration_sec
2436 else:
2437 self.duration_sec = 0
2438 if duration_nsec != None:
2439 self.duration_nsec = duration_nsec
2440 else:
2441 self.duration_nsec = 0
2442 return
2443
2444 def pack(self):
2445 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07002446 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002447 packed.append(struct.pack("!L", self.queue_id))
2448 packed.append(struct.pack("!Q", self.tx_bytes))
2449 packed.append(struct.pack("!Q", self.tx_packets))
2450 packed.append(struct.pack("!Q", self.tx_errors))
2451 packed.append(struct.pack("!L", self.duration_sec))
2452 packed.append(struct.pack("!L", self.duration_nsec))
2453 return ''.join(packed)
2454
2455 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002456 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002457 obj = queue_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07002458 obj.port_no = util.unpack_port_no(reader)
2459 obj.queue_id = reader.read("!L")[0]
2460 obj.tx_bytes = reader.read("!Q")[0]
2461 obj.tx_packets = reader.read("!Q")[0]
2462 obj.tx_errors = reader.read("!Q")[0]
2463 obj.duration_sec = reader.read("!L")[0]
2464 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002465 return obj
2466
2467 def __eq__(self, other):
2468 if type(self) != type(other): return False
2469 if self.port_no != other.port_no: return False
2470 if self.queue_id != other.queue_id: return False
2471 if self.tx_bytes != other.tx_bytes: return False
2472 if self.tx_packets != other.tx_packets: return False
2473 if self.tx_errors != other.tx_errors: return False
2474 if self.duration_sec != other.duration_sec: return False
2475 if self.duration_nsec != other.duration_nsec: return False
2476 return True
2477
Rich Lanec2ee4b82013-04-24 17:12:38 -07002478 def pretty_print(self, q):
2479 q.text("queue_stats_entry {")
2480 with q.group():
2481 with q.indent(2):
2482 q.breakable()
2483 q.text("port_no = ");
2484 q.text(util.pretty_port(self.port_no))
2485 q.text(","); q.breakable()
2486 q.text("queue_id = ");
2487 q.text("%#x" % self.queue_id)
2488 q.text(","); q.breakable()
2489 q.text("tx_bytes = ");
2490 q.text("%#x" % self.tx_bytes)
2491 q.text(","); q.breakable()
2492 q.text("tx_packets = ");
2493 q.text("%#x" % self.tx_packets)
2494 q.text(","); q.breakable()
2495 q.text("tx_errors = ");
2496 q.text("%#x" % self.tx_errors)
2497 q.text(","); q.breakable()
2498 q.text("duration_sec = ");
2499 q.text("%#x" % self.duration_sec)
2500 q.text(","); q.breakable()
2501 q.text("duration_nsec = ");
2502 q.text("%#x" % self.duration_nsec)
2503 q.breakable()
2504 q.text('}')
2505
Rich Lane7dcdf022013-12-11 14:45:27 -08002506
2507class table_feature_prop(loxi.OFObject):
2508 subtypes = {}
2509
Rich Lane95f7fc92014-01-27 17:08:16 -08002510
2511 def __init__(self, type=None):
2512 if type != None:
2513 self.type = type
2514 else:
2515 self.type = 0
2516 return
2517
2518 def pack(self):
2519 packed = []
2520 packed.append(struct.pack("!H", self.type))
2521 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
2522 length = sum([len(x) for x in packed])
2523 packed[1] = struct.pack("!H", length)
2524 return ''.join(packed)
2525
Rich Lane7dcdf022013-12-11 14:45:27 -08002526 @staticmethod
2527 def unpack(reader):
2528 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -08002529 subclass = table_feature_prop.subtypes.get(subtype)
2530 if subclass:
2531 return subclass.unpack(reader)
2532
2533 obj = table_feature_prop()
2534 obj.type = reader.read("!H")[0]
2535 _length = reader.read("!H")[0]
2536 orig_reader = reader
2537 reader = orig_reader.slice(_length - (2 + 2))
2538 return obj
2539
2540 def __eq__(self, other):
2541 if type(self) != type(other): return False
2542 if self.type != other.type: return False
2543 return True
2544
2545 def pretty_print(self, q):
2546 q.text("table_feature_prop {")
2547 with q.group():
2548 with q.indent(2):
2549 q.breakable()
2550 q.breakable()
2551 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002552
2553
2554class table_feature_prop_apply_actions(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002555 type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07002556
Dan Talaycof6202252013-07-02 01:00:29 -07002557 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002558 if action_ids != None:
2559 self.action_ids = action_ids
2560 else:
2561 self.action_ids = []
2562 return
2563
2564 def pack(self):
2565 packed = []
2566 packed.append(struct.pack("!H", self.type))
2567 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002568 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002569 length = sum([len(x) for x in packed])
2570 packed[1] = struct.pack("!H", length)
2571 return ''.join(packed)
2572
2573 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002574 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002575 obj = table_feature_prop_apply_actions()
Dan Talaycof6202252013-07-02 01:00:29 -07002576 _type = reader.read("!H")[0]
2577 assert(_type == 6)
2578 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002579 orig_reader = reader
2580 reader = orig_reader.slice(_length - (2 + 2))
2581 obj.action_ids = loxi.generic_util.unpack_list(reader, action_id.action_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002582 return obj
2583
2584 def __eq__(self, other):
2585 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002586 if self.action_ids != other.action_ids: return False
2587 return True
2588
Rich Lanec2ee4b82013-04-24 17:12:38 -07002589 def pretty_print(self, q):
2590 q.text("table_feature_prop_apply_actions {")
2591 with q.group():
2592 with q.indent(2):
2593 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002594 q.text("action_ids = ");
2595 q.pp(self.action_ids)
2596 q.breakable()
2597 q.text('}')
2598
Rich Lane7dcdf022013-12-11 14:45:27 -08002599table_feature_prop.subtypes[6] = table_feature_prop_apply_actions
2600
2601class table_feature_prop_apply_actions_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002602 type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07002603
Dan Talaycof6202252013-07-02 01:00:29 -07002604 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002605 if action_ids != None:
2606 self.action_ids = action_ids
2607 else:
2608 self.action_ids = []
2609 return
2610
2611 def pack(self):
2612 packed = []
2613 packed.append(struct.pack("!H", self.type))
2614 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002615 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002616 length = sum([len(x) for x in packed])
2617 packed[1] = struct.pack("!H", length)
2618 return ''.join(packed)
2619
2620 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002621 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002622 obj = table_feature_prop_apply_actions_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07002623 _type = reader.read("!H")[0]
2624 assert(_type == 7)
2625 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002626 orig_reader = reader
2627 reader = orig_reader.slice(_length - (2 + 2))
2628 obj.action_ids = loxi.generic_util.unpack_list(reader, action_id.action_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002629 return obj
2630
2631 def __eq__(self, other):
2632 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002633 if self.action_ids != other.action_ids: return False
2634 return True
2635
Rich Lanec2ee4b82013-04-24 17:12:38 -07002636 def pretty_print(self, q):
2637 q.text("table_feature_prop_apply_actions_miss {")
2638 with q.group():
2639 with q.indent(2):
2640 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002641 q.text("action_ids = ");
2642 q.pp(self.action_ids)
2643 q.breakable()
2644 q.text('}')
2645
Rich Lane7dcdf022013-12-11 14:45:27 -08002646table_feature_prop.subtypes[7] = table_feature_prop_apply_actions_miss
2647
2648class table_feature_prop_apply_setfield(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002649 type = 14
Rich Lanec2ee4b82013-04-24 17:12:38 -07002650
Dan Talaycof6202252013-07-02 01:00:29 -07002651 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002652 if oxm_ids != None:
2653 self.oxm_ids = oxm_ids
2654 else:
2655 self.oxm_ids = []
2656 return
2657
2658 def pack(self):
2659 packed = []
2660 packed.append(struct.pack("!H", self.type))
2661 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002662 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002663 length = sum([len(x) for x in packed])
2664 packed[1] = struct.pack("!H", length)
2665 return ''.join(packed)
2666
2667 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002668 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002669 obj = table_feature_prop_apply_setfield()
Dan Talaycof6202252013-07-02 01:00:29 -07002670 _type = reader.read("!H")[0]
2671 assert(_type == 14)
2672 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002673 orig_reader = reader
2674 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002675 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
2676 return obj
2677
2678 def __eq__(self, other):
2679 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002680 if self.oxm_ids != other.oxm_ids: return False
2681 return True
2682
Rich Lanec2ee4b82013-04-24 17:12:38 -07002683 def pretty_print(self, q):
2684 q.text("table_feature_prop_apply_setfield {")
2685 with q.group():
2686 with q.indent(2):
2687 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002688 q.text("oxm_ids = ");
2689 q.pp(self.oxm_ids)
2690 q.breakable()
2691 q.text('}')
2692
Rich Lane7dcdf022013-12-11 14:45:27 -08002693table_feature_prop.subtypes[14] = table_feature_prop_apply_setfield
2694
2695class table_feature_prop_apply_setfield_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002696 type = 15
Rich Lanec2ee4b82013-04-24 17:12:38 -07002697
Dan Talaycof6202252013-07-02 01:00:29 -07002698 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002699 if oxm_ids != None:
2700 self.oxm_ids = oxm_ids
2701 else:
2702 self.oxm_ids = []
2703 return
2704
2705 def pack(self):
2706 packed = []
2707 packed.append(struct.pack("!H", self.type))
2708 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002709 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002710 length = sum([len(x) for x in packed])
2711 packed[1] = struct.pack("!H", length)
2712 return ''.join(packed)
2713
2714 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002715 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002716 obj = table_feature_prop_apply_setfield_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07002717 _type = reader.read("!H")[0]
2718 assert(_type == 15)
2719 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002720 orig_reader = reader
2721 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002722 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
2723 return obj
2724
2725 def __eq__(self, other):
2726 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002727 if self.oxm_ids != other.oxm_ids: return False
2728 return True
2729
Rich Lanec2ee4b82013-04-24 17:12:38 -07002730 def pretty_print(self, q):
2731 q.text("table_feature_prop_apply_setfield_miss {")
2732 with q.group():
2733 with q.indent(2):
2734 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002735 q.text("oxm_ids = ");
2736 q.pp(self.oxm_ids)
2737 q.breakable()
2738 q.text('}')
2739
Rich Lane7dcdf022013-12-11 14:45:27 -08002740table_feature_prop.subtypes[15] = table_feature_prop_apply_setfield_miss
2741
2742class table_feature_prop_experimenter(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002743 type = 65535
Rich Lanec2ee4b82013-04-24 17:12:38 -07002744
Dan Talaycof6202252013-07-02 01:00:29 -07002745 def __init__(self, experimenter=None, subtype=None, experimenter_data=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002746 if experimenter != None:
2747 self.experimenter = experimenter
2748 else:
2749 self.experimenter = 0
2750 if subtype != None:
2751 self.subtype = subtype
2752 else:
2753 self.subtype = 0
2754 if experimenter_data != None:
2755 self.experimenter_data = experimenter_data
2756 else:
Dan Talaycof6202252013-07-02 01:00:29 -07002757 self.experimenter_data = ''
Rich Lanec2ee4b82013-04-24 17:12:38 -07002758 return
2759
2760 def pack(self):
2761 packed = []
2762 packed.append(struct.pack("!H", self.type))
2763 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
2764 packed.append(struct.pack("!L", self.experimenter))
2765 packed.append(struct.pack("!L", self.subtype))
2766 packed.append(self.experimenter_data)
2767 length = sum([len(x) for x in packed])
2768 packed[1] = struct.pack("!H", length)
2769 return ''.join(packed)
2770
2771 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002772 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002773 obj = table_feature_prop_experimenter()
Dan Talaycof6202252013-07-02 01:00:29 -07002774 _type = reader.read("!H")[0]
2775 assert(_type == 65535)
2776 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002777 orig_reader = reader
2778 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002779 obj.experimenter = reader.read("!L")[0]
2780 obj.subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002781 obj.experimenter_data = str(reader.read_all())
2782 return obj
2783
2784 def __eq__(self, other):
2785 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002786 if self.experimenter != other.experimenter: return False
2787 if self.subtype != other.subtype: return False
2788 if self.experimenter_data != other.experimenter_data: return False
2789 return True
2790
Rich Lanec2ee4b82013-04-24 17:12:38 -07002791 def pretty_print(self, q):
2792 q.text("table_feature_prop_experimenter {")
2793 with q.group():
2794 with q.indent(2):
2795 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002796 q.text("experimenter = ");
2797 q.text("%#x" % self.experimenter)
2798 q.text(","); q.breakable()
2799 q.text("subtype = ");
2800 q.text("%#x" % self.subtype)
2801 q.text(","); q.breakable()
2802 q.text("experimenter_data = ");
2803 q.pp(self.experimenter_data)
2804 q.breakable()
2805 q.text('}')
2806
Rich Lane7dcdf022013-12-11 14:45:27 -08002807table_feature_prop.subtypes[65535] = table_feature_prop_experimenter
2808
2809class table_feature_prop_instructions(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002810 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07002811
Dan Talaycof6202252013-07-02 01:00:29 -07002812 def __init__(self, instruction_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002813 if instruction_ids != None:
2814 self.instruction_ids = instruction_ids
2815 else:
2816 self.instruction_ids = []
2817 return
2818
2819 def pack(self):
2820 packed = []
2821 packed.append(struct.pack("!H", self.type))
2822 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002823 packed.append(loxi.generic_util.pack_list(self.instruction_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002824 length = sum([len(x) for x in packed])
2825 packed[1] = struct.pack("!H", length)
2826 return ''.join(packed)
2827
2828 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002829 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002830 obj = table_feature_prop_instructions()
Dan Talaycof6202252013-07-02 01:00:29 -07002831 _type = reader.read("!H")[0]
2832 assert(_type == 0)
2833 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002834 orig_reader = reader
2835 reader = orig_reader.slice(_length - (2 + 2))
2836 obj.instruction_ids = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002837 return obj
2838
2839 def __eq__(self, other):
2840 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002841 if self.instruction_ids != other.instruction_ids: return False
2842 return True
2843
Rich Lanec2ee4b82013-04-24 17:12:38 -07002844 def pretty_print(self, q):
2845 q.text("table_feature_prop_instructions {")
2846 with q.group():
2847 with q.indent(2):
2848 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002849 q.text("instruction_ids = ");
2850 q.pp(self.instruction_ids)
2851 q.breakable()
2852 q.text('}')
2853
Rich Lane7dcdf022013-12-11 14:45:27 -08002854table_feature_prop.subtypes[0] = table_feature_prop_instructions
2855
2856class table_feature_prop_instructions_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002857 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07002858
Dan Talaycof6202252013-07-02 01:00:29 -07002859 def __init__(self, instruction_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002860 if instruction_ids != None:
2861 self.instruction_ids = instruction_ids
2862 else:
2863 self.instruction_ids = []
2864 return
2865
2866 def pack(self):
2867 packed = []
2868 packed.append(struct.pack("!H", self.type))
2869 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002870 packed.append(loxi.generic_util.pack_list(self.instruction_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002871 length = sum([len(x) for x in packed])
2872 packed[1] = struct.pack("!H", length)
2873 return ''.join(packed)
2874
2875 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002876 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002877 obj = table_feature_prop_instructions_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07002878 _type = reader.read("!H")[0]
2879 assert(_type == 1)
2880 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002881 orig_reader = reader
2882 reader = orig_reader.slice(_length - (2 + 2))
2883 obj.instruction_ids = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002884 return obj
2885
2886 def __eq__(self, other):
2887 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002888 if self.instruction_ids != other.instruction_ids: return False
2889 return True
2890
Rich Lanec2ee4b82013-04-24 17:12:38 -07002891 def pretty_print(self, q):
2892 q.text("table_feature_prop_instructions_miss {")
2893 with q.group():
2894 with q.indent(2):
2895 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002896 q.text("instruction_ids = ");
2897 q.pp(self.instruction_ids)
2898 q.breakable()
2899 q.text('}')
2900
Rich Lane7dcdf022013-12-11 14:45:27 -08002901table_feature_prop.subtypes[1] = table_feature_prop_instructions_miss
2902
2903class table_feature_prop_match(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002904 type = 8
Rich Lanec2ee4b82013-04-24 17:12:38 -07002905
Dan Talaycof6202252013-07-02 01:00:29 -07002906 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002907 if oxm_ids != None:
2908 self.oxm_ids = oxm_ids
2909 else:
2910 self.oxm_ids = []
2911 return
2912
2913 def pack(self):
2914 packed = []
2915 packed.append(struct.pack("!H", self.type))
2916 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002917 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002918 length = sum([len(x) for x in packed])
2919 packed[1] = struct.pack("!H", length)
2920 return ''.join(packed)
2921
2922 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002923 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002924 obj = table_feature_prop_match()
Dan Talaycof6202252013-07-02 01:00:29 -07002925 _type = reader.read("!H")[0]
2926 assert(_type == 8)
2927 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002928 orig_reader = reader
2929 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002930 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
2931 return obj
2932
2933 def __eq__(self, other):
2934 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002935 if self.oxm_ids != other.oxm_ids: return False
2936 return True
2937
Rich Lanec2ee4b82013-04-24 17:12:38 -07002938 def pretty_print(self, q):
2939 q.text("table_feature_prop_match {")
2940 with q.group():
2941 with q.indent(2):
2942 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002943 q.text("oxm_ids = ");
2944 q.pp(self.oxm_ids)
2945 q.breakable()
2946 q.text('}')
2947
Rich Lane7dcdf022013-12-11 14:45:27 -08002948table_feature_prop.subtypes[8] = table_feature_prop_match
2949
2950class table_feature_prop_next_tables(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002951 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07002952
Dan Talaycof6202252013-07-02 01:00:29 -07002953 def __init__(self, next_table_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002954 if next_table_ids != None:
2955 self.next_table_ids = next_table_ids
2956 else:
2957 self.next_table_ids = []
2958 return
2959
2960 def pack(self):
2961 packed = []
2962 packed.append(struct.pack("!H", self.type))
2963 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002964 packed.append(loxi.generic_util.pack_list(self.next_table_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002965 length = sum([len(x) for x in packed])
2966 packed[1] = struct.pack("!H", length)
2967 return ''.join(packed)
2968
2969 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002970 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002971 obj = table_feature_prop_next_tables()
Dan Talaycof6202252013-07-02 01:00:29 -07002972 _type = reader.read("!H")[0]
2973 assert(_type == 2)
2974 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002975 orig_reader = reader
2976 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002977 obj.next_table_ids = loxi.generic_util.unpack_list(reader, common.uint8.unpack)
2978 return obj
2979
2980 def __eq__(self, other):
2981 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002982 if self.next_table_ids != other.next_table_ids: return False
2983 return True
2984
Rich Lanec2ee4b82013-04-24 17:12:38 -07002985 def pretty_print(self, q):
2986 q.text("table_feature_prop_next_tables {")
2987 with q.group():
2988 with q.indent(2):
2989 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002990 q.text("next_table_ids = ");
2991 q.pp(self.next_table_ids)
2992 q.breakable()
2993 q.text('}')
2994
Rich Lane7dcdf022013-12-11 14:45:27 -08002995table_feature_prop.subtypes[2] = table_feature_prop_next_tables
2996
2997class table_feature_prop_next_tables_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002998 type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07002999
Dan Talaycof6202252013-07-02 01:00:29 -07003000 def __init__(self, next_table_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003001 if next_table_ids != None:
3002 self.next_table_ids = next_table_ids
3003 else:
3004 self.next_table_ids = []
3005 return
3006
3007 def pack(self):
3008 packed = []
3009 packed.append(struct.pack("!H", self.type))
3010 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003011 packed.append(loxi.generic_util.pack_list(self.next_table_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003012 length = sum([len(x) for x in packed])
3013 packed[1] = struct.pack("!H", length)
3014 return ''.join(packed)
3015
3016 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003017 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003018 obj = table_feature_prop_next_tables_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07003019 _type = reader.read("!H")[0]
3020 assert(_type == 3)
3021 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003022 orig_reader = reader
3023 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003024 obj.next_table_ids = loxi.generic_util.unpack_list(reader, common.uint8.unpack)
3025 return obj
3026
3027 def __eq__(self, other):
3028 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003029 if self.next_table_ids != other.next_table_ids: return False
3030 return True
3031
Rich Lanec2ee4b82013-04-24 17:12:38 -07003032 def pretty_print(self, q):
3033 q.text("table_feature_prop_next_tables_miss {")
3034 with q.group():
3035 with q.indent(2):
3036 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003037 q.text("next_table_ids = ");
3038 q.pp(self.next_table_ids)
3039 q.breakable()
3040 q.text('}')
3041
Rich Lane7dcdf022013-12-11 14:45:27 -08003042table_feature_prop.subtypes[3] = table_feature_prop_next_tables_miss
3043
3044class table_feature_prop_wildcards(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003045 type = 10
Rich Lanec2ee4b82013-04-24 17:12:38 -07003046
Dan Talaycof6202252013-07-02 01:00:29 -07003047 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003048 if oxm_ids != None:
3049 self.oxm_ids = oxm_ids
3050 else:
3051 self.oxm_ids = []
3052 return
3053
3054 def pack(self):
3055 packed = []
3056 packed.append(struct.pack("!H", self.type))
3057 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003058 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003059 length = sum([len(x) for x in packed])
3060 packed[1] = struct.pack("!H", length)
3061 return ''.join(packed)
3062
3063 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003064 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003065 obj = table_feature_prop_wildcards()
Dan Talaycof6202252013-07-02 01:00:29 -07003066 _type = reader.read("!H")[0]
3067 assert(_type == 10)
3068 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003069 orig_reader = reader
3070 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003071 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
3072 return obj
3073
3074 def __eq__(self, other):
3075 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003076 if self.oxm_ids != other.oxm_ids: return False
3077 return True
3078
Rich Lanec2ee4b82013-04-24 17:12:38 -07003079 def pretty_print(self, q):
3080 q.text("table_feature_prop_wildcards {")
3081 with q.group():
3082 with q.indent(2):
3083 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003084 q.text("oxm_ids = ");
3085 q.pp(self.oxm_ids)
3086 q.breakable()
3087 q.text('}')
3088
Rich Lane7dcdf022013-12-11 14:45:27 -08003089table_feature_prop.subtypes[10] = table_feature_prop_wildcards
3090
3091class table_feature_prop_write_actions(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003092 type = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07003093
Dan Talaycof6202252013-07-02 01:00:29 -07003094 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003095 if action_ids != None:
3096 self.action_ids = action_ids
3097 else:
3098 self.action_ids = []
3099 return
3100
3101 def pack(self):
3102 packed = []
3103 packed.append(struct.pack("!H", self.type))
3104 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003105 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003106 length = sum([len(x) for x in packed])
3107 packed[1] = struct.pack("!H", length)
3108 return ''.join(packed)
3109
3110 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003111 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003112 obj = table_feature_prop_write_actions()
Dan Talaycof6202252013-07-02 01:00:29 -07003113 _type = reader.read("!H")[0]
3114 assert(_type == 4)
3115 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003116 orig_reader = reader
3117 reader = orig_reader.slice(_length - (2 + 2))
3118 obj.action_ids = loxi.generic_util.unpack_list(reader, action_id.action_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003119 return obj
3120
3121 def __eq__(self, other):
3122 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003123 if self.action_ids != other.action_ids: return False
3124 return True
3125
Rich Lanec2ee4b82013-04-24 17:12:38 -07003126 def pretty_print(self, q):
3127 q.text("table_feature_prop_write_actions {")
3128 with q.group():
3129 with q.indent(2):
3130 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003131 q.text("action_ids = ");
3132 q.pp(self.action_ids)
3133 q.breakable()
3134 q.text('}')
3135
Rich Lane7dcdf022013-12-11 14:45:27 -08003136table_feature_prop.subtypes[4] = table_feature_prop_write_actions
3137
3138class table_feature_prop_write_actions_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003139 type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07003140
Dan Talaycof6202252013-07-02 01:00:29 -07003141 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003142 if action_ids != None:
3143 self.action_ids = action_ids
3144 else:
3145 self.action_ids = []
3146 return
3147
3148 def pack(self):
3149 packed = []
3150 packed.append(struct.pack("!H", self.type))
3151 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003152 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003153 length = sum([len(x) for x in packed])
3154 packed[1] = struct.pack("!H", length)
3155 return ''.join(packed)
3156
3157 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003158 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003159 obj = table_feature_prop_write_actions_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07003160 _type = reader.read("!H")[0]
3161 assert(_type == 5)
3162 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003163 orig_reader = reader
3164 reader = orig_reader.slice(_length - (2 + 2))
3165 obj.action_ids = loxi.generic_util.unpack_list(reader, action_id.action_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003166 return obj
3167
3168 def __eq__(self, other):
3169 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003170 if self.action_ids != other.action_ids: return False
3171 return True
3172
Rich Lanec2ee4b82013-04-24 17:12:38 -07003173 def pretty_print(self, q):
3174 q.text("table_feature_prop_write_actions_miss {")
3175 with q.group():
3176 with q.indent(2):
3177 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003178 q.text("action_ids = ");
3179 q.pp(self.action_ids)
3180 q.breakable()
3181 q.text('}')
3182
Rich Lane7dcdf022013-12-11 14:45:27 -08003183table_feature_prop.subtypes[5] = table_feature_prop_write_actions_miss
3184
3185class table_feature_prop_write_setfield(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003186 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -07003187
Dan Talaycof6202252013-07-02 01:00:29 -07003188 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003189 if oxm_ids != None:
3190 self.oxm_ids = oxm_ids
3191 else:
3192 self.oxm_ids = []
3193 return
3194
3195 def pack(self):
3196 packed = []
3197 packed.append(struct.pack("!H", self.type))
3198 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003199 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003200 length = sum([len(x) for x in packed])
3201 packed[1] = struct.pack("!H", length)
3202 return ''.join(packed)
3203
3204 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003205 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003206 obj = table_feature_prop_write_setfield()
Dan Talaycof6202252013-07-02 01:00:29 -07003207 _type = reader.read("!H")[0]
3208 assert(_type == 12)
3209 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003210 orig_reader = reader
3211 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003212 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
3213 return obj
3214
3215 def __eq__(self, other):
3216 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003217 if self.oxm_ids != other.oxm_ids: return False
3218 return True
3219
Rich Lanec2ee4b82013-04-24 17:12:38 -07003220 def pretty_print(self, q):
3221 q.text("table_feature_prop_write_setfield {")
3222 with q.group():
3223 with q.indent(2):
3224 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003225 q.text("oxm_ids = ");
3226 q.pp(self.oxm_ids)
3227 q.breakable()
3228 q.text('}')
3229
Rich Lane7dcdf022013-12-11 14:45:27 -08003230table_feature_prop.subtypes[12] = table_feature_prop_write_setfield
3231
3232class table_feature_prop_write_setfield_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003233 type = 13
Rich Lanec2ee4b82013-04-24 17:12:38 -07003234
Dan Talaycof6202252013-07-02 01:00:29 -07003235 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003236 if oxm_ids != None:
3237 self.oxm_ids = oxm_ids
3238 else:
3239 self.oxm_ids = []
3240 return
3241
3242 def pack(self):
3243 packed = []
3244 packed.append(struct.pack("!H", self.type))
3245 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003246 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003247 length = sum([len(x) for x in packed])
3248 packed[1] = struct.pack("!H", length)
3249 return ''.join(packed)
3250
3251 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003252 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003253 obj = table_feature_prop_write_setfield_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07003254 _type = reader.read("!H")[0]
3255 assert(_type == 13)
3256 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003257 orig_reader = reader
3258 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003259 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
3260 return obj
3261
3262 def __eq__(self, other):
3263 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003264 if self.oxm_ids != other.oxm_ids: return False
3265 return True
3266
Rich Lanec2ee4b82013-04-24 17:12:38 -07003267 def pretty_print(self, q):
3268 q.text("table_feature_prop_write_setfield_miss {")
3269 with q.group():
3270 with q.indent(2):
3271 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003272 q.text("oxm_ids = ");
3273 q.pp(self.oxm_ids)
3274 q.breakable()
3275 q.text('}')
3276
Rich Lane7dcdf022013-12-11 14:45:27 -08003277table_feature_prop.subtypes[13] = table_feature_prop_write_setfield_miss
3278
3279class table_features(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003280
3281 def __init__(self, table_id=None, name=None, metadata_match=None, metadata_write=None, config=None, max_entries=None, properties=None):
3282 if table_id != None:
3283 self.table_id = table_id
3284 else:
3285 self.table_id = 0
3286 if name != None:
3287 self.name = name
3288 else:
3289 self.name = ""
3290 if metadata_match != None:
3291 self.metadata_match = metadata_match
3292 else:
3293 self.metadata_match = 0
3294 if metadata_write != None:
3295 self.metadata_write = metadata_write
3296 else:
3297 self.metadata_write = 0
3298 if config != None:
3299 self.config = config
3300 else:
3301 self.config = 0
3302 if max_entries != None:
3303 self.max_entries = max_entries
3304 else:
3305 self.max_entries = 0
3306 if properties != None:
3307 self.properties = properties
3308 else:
3309 self.properties = []
3310 return
3311
3312 def pack(self):
3313 packed = []
3314 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
3315 packed.append(struct.pack("!B", self.table_id))
3316 packed.append('\x00' * 5)
3317 packed.append(struct.pack("!32s", self.name))
3318 packed.append(struct.pack("!Q", self.metadata_match))
3319 packed.append(struct.pack("!Q", self.metadata_write))
3320 packed.append(struct.pack("!L", self.config))
3321 packed.append(struct.pack("!L", self.max_entries))
Rich Lane7dcdf022013-12-11 14:45:27 -08003322 packed.append(loxi.generic_util.pack_list(self.properties))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003323 length = sum([len(x) for x in packed])
3324 packed[0] = struct.pack("!H", length)
3325 return ''.join(packed)
3326
3327 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003328 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003329 obj = table_features()
Dan Talaycof6202252013-07-02 01:00:29 -07003330 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003331 orig_reader = reader
3332 reader = orig_reader.slice(_length - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003333 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003334 reader.skip(5)
3335 obj.name = reader.read("!32s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -07003336 obj.metadata_match = reader.read("!Q")[0]
3337 obj.metadata_write = reader.read("!Q")[0]
3338 obj.config = reader.read("!L")[0]
3339 obj.max_entries = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003340 obj.properties = loxi.generic_util.unpack_list(reader, common.table_feature_prop.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003341 return obj
3342
3343 def __eq__(self, other):
3344 if type(self) != type(other): return False
3345 if self.table_id != other.table_id: return False
3346 if self.name != other.name: return False
3347 if self.metadata_match != other.metadata_match: return False
3348 if self.metadata_write != other.metadata_write: return False
3349 if self.config != other.config: return False
3350 if self.max_entries != other.max_entries: return False
3351 if self.properties != other.properties: return False
3352 return True
3353
Rich Lanec2ee4b82013-04-24 17:12:38 -07003354 def pretty_print(self, q):
3355 q.text("table_features {")
3356 with q.group():
3357 with q.indent(2):
3358 q.breakable()
3359 q.text("table_id = ");
3360 q.text("%#x" % self.table_id)
3361 q.text(","); q.breakable()
3362 q.text("name = ");
3363 q.pp(self.name)
3364 q.text(","); q.breakable()
3365 q.text("metadata_match = ");
3366 q.text("%#x" % self.metadata_match)
3367 q.text(","); q.breakable()
3368 q.text("metadata_write = ");
3369 q.text("%#x" % self.metadata_write)
3370 q.text(","); q.breakable()
3371 q.text("config = ");
3372 q.text("%#x" % self.config)
3373 q.text(","); q.breakable()
3374 q.text("max_entries = ");
3375 q.text("%#x" % self.max_entries)
3376 q.text(","); q.breakable()
3377 q.text("properties = ");
3378 q.pp(self.properties)
3379 q.breakable()
3380 q.text('}')
3381
Rich Lane7dcdf022013-12-11 14:45:27 -08003382
3383class table_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003384
3385 def __init__(self, table_id=None, active_count=None, lookup_count=None, matched_count=None):
3386 if table_id != None:
3387 self.table_id = table_id
3388 else:
3389 self.table_id = 0
3390 if active_count != None:
3391 self.active_count = active_count
3392 else:
3393 self.active_count = 0
3394 if lookup_count != None:
3395 self.lookup_count = lookup_count
3396 else:
3397 self.lookup_count = 0
3398 if matched_count != None:
3399 self.matched_count = matched_count
3400 else:
3401 self.matched_count = 0
3402 return
3403
3404 def pack(self):
3405 packed = []
3406 packed.append(struct.pack("!B", self.table_id))
3407 packed.append('\x00' * 3)
3408 packed.append(struct.pack("!L", self.active_count))
3409 packed.append(struct.pack("!Q", self.lookup_count))
3410 packed.append(struct.pack("!Q", self.matched_count))
3411 return ''.join(packed)
3412
3413 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003414 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003415 obj = table_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07003416 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003417 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07003418 obj.active_count = reader.read("!L")[0]
3419 obj.lookup_count = reader.read("!Q")[0]
3420 obj.matched_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003421 return obj
3422
3423 def __eq__(self, other):
3424 if type(self) != type(other): return False
3425 if self.table_id != other.table_id: return False
3426 if self.active_count != other.active_count: return False
3427 if self.lookup_count != other.lookup_count: return False
3428 if self.matched_count != other.matched_count: return False
3429 return True
3430
Rich Lanec2ee4b82013-04-24 17:12:38 -07003431 def pretty_print(self, q):
3432 q.text("table_stats_entry {")
3433 with q.group():
3434 with q.indent(2):
3435 q.breakable()
3436 q.text("table_id = ");
3437 q.text("%#x" % self.table_id)
3438 q.text(","); q.breakable()
3439 q.text("active_count = ");
3440 q.text("%#x" % self.active_count)
3441 q.text(","); q.breakable()
3442 q.text("lookup_count = ");
3443 q.text("%#x" % self.lookup_count)
3444 q.text(","); q.breakable()
3445 q.text("matched_count = ");
3446 q.text("%#x" % self.matched_count)
3447 q.breakable()
3448 q.text('}')
3449
Rich Lane7dcdf022013-12-11 14:45:27 -08003450
3451class uint32(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003452
3453 def __init__(self, value=None):
3454 if value != None:
3455 self.value = value
3456 else:
3457 self.value = 0
3458 return
3459
3460 def pack(self):
3461 packed = []
3462 packed.append(struct.pack("!L", self.value))
3463 return ''.join(packed)
3464
3465 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003466 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003467 obj = uint32()
Dan Talaycof6202252013-07-02 01:00:29 -07003468 obj.value = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003469 return obj
3470
3471 def __eq__(self, other):
3472 if type(self) != type(other): return False
3473 if self.value != other.value: return False
3474 return True
3475
Rich Lanec2ee4b82013-04-24 17:12:38 -07003476 def pretty_print(self, q):
3477 q.text("uint32 {")
3478 with q.group():
3479 with q.indent(2):
3480 q.breakable()
3481 q.text("value = ");
3482 q.text("%#x" % self.value)
3483 q.breakable()
3484 q.text('}')
3485
Rich Lane7dcdf022013-12-11 14:45:27 -08003486
3487class uint64(loxi.OFObject):
3488
3489 def __init__(self, value=None):
3490 if value != None:
3491 self.value = value
3492 else:
3493 self.value = 0
3494 return
3495
3496 def pack(self):
3497 packed = []
3498 packed.append(struct.pack("!Q", self.value))
3499 return ''.join(packed)
3500
3501 @staticmethod
3502 def unpack(reader):
3503 obj = uint64()
3504 obj.value = reader.read("!Q")[0]
3505 return obj
3506
3507 def __eq__(self, other):
3508 if type(self) != type(other): return False
3509 if self.value != other.value: return False
3510 return True
3511
3512 def pretty_print(self, q):
3513 q.text("uint64 {")
3514 with q.group():
3515 with q.indent(2):
3516 q.breakable()
3517 q.text("value = ");
3518 q.text("%#x" % self.value)
3519 q.breakable()
3520 q.text('}')
3521
3522
3523class uint8(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003524
3525 def __init__(self, value=None):
3526 if value != None:
3527 self.value = value
3528 else:
3529 self.value = 0
3530 return
3531
3532 def pack(self):
3533 packed = []
3534 packed.append(struct.pack("!B", self.value))
3535 return ''.join(packed)
3536
3537 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003538 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003539 obj = uint8()
Dan Talaycof6202252013-07-02 01:00:29 -07003540 obj.value = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003541 return obj
3542
3543 def __eq__(self, other):
3544 if type(self) != type(other): return False
3545 if self.value != other.value: return False
3546 return True
3547
Rich Lanec2ee4b82013-04-24 17:12:38 -07003548 def pretty_print(self, q):
3549 q.text("uint8 {")
3550 with q.group():
3551 with q.indent(2):
3552 q.breakable()
3553 q.text("value = ");
3554 q.text("%#x" % self.value)
3555 q.breakable()
3556 q.text('}')
3557
3558
Rich Lane7dcdf022013-12-11 14:45:27 -08003559
Rich Lanec2ee4b82013-04-24 17:12:38 -07003560match = match_v3