blob: 93a4faf3e80e846c730127a130e2ac28c448e17f [file] [log] [blame]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001# Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2# Copyright (c) 2011, 2012 Open Networking Foundation
3# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
Dan Talaycof6202252013-07-02 01:00:29 -07004# See the file LICENSE.pyloxi which should have been included in the source distribution
Rich Lane7dcdf022013-12-11 14:45:27 -08005
6# Automatically generated by LOXI from template module.py
Rich Lanec2ee4b82013-04-24 17:12:38 -07007# Do not modify
8
Rich Lanec2ee4b82013-04-24 17:12:38 -07009import struct
Rich Lane7dcdf022013-12-11 14:45:27 -080010import loxi
Rich Lanec2ee4b82013-04-24 17:12:38 -070011import const
Rich Lane7dcdf022013-12-11 14:45:27 -080012import common
13import action
14import instruction
15import oxm
16import action_id
17import instruction_id
18import meter_band
Rich Lane5454b682014-01-14 17:07:36 -080019import bsn_tlv
Rich Lanec2ee4b82013-04-24 17:12:38 -070020import util
21import loxi.generic_util
22
Rich Lane5454b682014-01-14 17:07:36 -080023class bsn_controller_connection(loxi.OFObject):
24
25 def __init__(self, state=None, auxiliary_id=None, role=None, uri=None):
26 if state != None:
27 self.state = state
28 else:
29 self.state = 0
30 if auxiliary_id != None:
31 self.auxiliary_id = auxiliary_id
32 else:
33 self.auxiliary_id = 0
34 if role != None:
35 self.role = role
36 else:
37 self.role = 0
38 if uri != None:
39 self.uri = uri
40 else:
41 self.uri = ""
42 return
43
44 def pack(self):
45 packed = []
46 packed.append(struct.pack("!B", self.state))
47 packed.append(struct.pack("!B", self.auxiliary_id))
48 packed.append('\x00' * 2)
49 packed.append(struct.pack("!L", self.role))
50 packed.append(struct.pack("!256s", self.uri))
51 return ''.join(packed)
52
53 @staticmethod
54 def unpack(reader):
55 obj = bsn_controller_connection()
56 obj.state = reader.read("!B")[0]
57 obj.auxiliary_id = reader.read("!B")[0]
58 reader.skip(2)
59 obj.role = reader.read("!L")[0]
60 obj.uri = reader.read("!256s")[0].rstrip("\x00")
61 return obj
62
63 def __eq__(self, other):
64 if type(self) != type(other): return False
65 if self.state != other.state: return False
66 if self.auxiliary_id != other.auxiliary_id: return False
67 if self.role != other.role: return False
68 if self.uri != other.uri: return False
69 return True
70
71 def pretty_print(self, q):
72 q.text("bsn_controller_connection {")
73 with q.group():
74 with q.indent(2):
75 q.breakable()
76 q.text("state = ");
77 q.text("%#x" % self.state)
78 q.text(","); q.breakable()
79 q.text("auxiliary_id = ");
80 q.text("%#x" % self.auxiliary_id)
81 q.text(","); q.breakable()
82 q.text("role = ");
83 q.text("%#x" % self.role)
84 q.text(","); q.breakable()
85 q.text("uri = ");
86 q.pp(self.uri)
87 q.breakable()
88 q.text('}')
89
90
Rich Lane9ec3fca2014-02-26 16:22:56 -080091class bsn_flow_checksum_bucket_stats_entry(loxi.OFObject):
92
93 def __init__(self, checksum=None):
94 if checksum != None:
95 self.checksum = checksum
96 else:
97 self.checksum = 0
98 return
99
100 def pack(self):
101 packed = []
102 packed.append(struct.pack("!Q", self.checksum))
103 return ''.join(packed)
104
105 @staticmethod
106 def unpack(reader):
107 obj = bsn_flow_checksum_bucket_stats_entry()
108 obj.checksum = reader.read("!Q")[0]
109 return obj
110
111 def __eq__(self, other):
112 if type(self) != type(other): return False
113 if self.checksum != other.checksum: return False
114 return True
115
116 def pretty_print(self, q):
117 q.text("bsn_flow_checksum_bucket_stats_entry {")
118 with q.group():
119 with q.indent(2):
120 q.breakable()
121 q.text("checksum = ");
122 q.text("%#x" % self.checksum)
123 q.breakable()
124 q.text('}')
125
126
Rich Lane5454b682014-01-14 17:07:36 -0800127class bsn_gentable_bucket_stats_entry(loxi.OFObject):
128
129 def __init__(self, checksum=None):
130 if checksum != None:
131 self.checksum = checksum
132 else:
133 self.checksum = 0
134 return
135
136 def pack(self):
137 packed = []
138 packed.append(util.pack_checksum_128(self.checksum))
139 return ''.join(packed)
140
141 @staticmethod
142 def unpack(reader):
143 obj = bsn_gentable_bucket_stats_entry()
144 obj.checksum = util.unpack_checksum_128(reader)
145 return obj
146
147 def __eq__(self, other):
148 if type(self) != type(other): return False
149 if self.checksum != other.checksum: return False
150 return True
151
152 def pretty_print(self, q):
153 q.text("bsn_gentable_bucket_stats_entry {")
154 with q.group():
155 with q.indent(2):
156 q.breakable()
157 q.text("checksum = ");
158 q.pp(self.checksum)
159 q.breakable()
160 q.text('}')
161
162
163class bsn_gentable_desc_stats_entry(loxi.OFObject):
164
165 def __init__(self, table_id=None, name=None, buckets_size=None, max_entries=None):
166 if table_id != None:
167 self.table_id = table_id
168 else:
169 self.table_id = 0
170 if name != None:
171 self.name = name
172 else:
173 self.name = ""
174 if buckets_size != None:
175 self.buckets_size = buckets_size
176 else:
177 self.buckets_size = 0
178 if max_entries != None:
179 self.max_entries = max_entries
180 else:
181 self.max_entries = 0
182 return
183
184 def pack(self):
185 packed = []
186 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
187 packed.append(struct.pack("!H", self.table_id))
188 packed.append(struct.pack("!32s", self.name))
189 packed.append(struct.pack("!L", self.buckets_size))
190 packed.append(struct.pack("!L", self.max_entries))
191 packed.append('\x00' * 4)
192 length = sum([len(x) for x in packed])
193 packed[0] = struct.pack("!H", length)
194 return ''.join(packed)
195
196 @staticmethod
197 def unpack(reader):
198 obj = bsn_gentable_desc_stats_entry()
199 _length = reader.read("!H")[0]
200 orig_reader = reader
201 reader = orig_reader.slice(_length - (0 + 2))
202 obj.table_id = reader.read("!H")[0]
203 obj.name = reader.read("!32s")[0].rstrip("\x00")
204 obj.buckets_size = reader.read("!L")[0]
205 obj.max_entries = reader.read("!L")[0]
206 reader.skip(4)
207 return obj
208
209 def __eq__(self, other):
210 if type(self) != type(other): return False
211 if self.table_id != other.table_id: return False
212 if self.name != other.name: return False
213 if self.buckets_size != other.buckets_size: return False
214 if self.max_entries != other.max_entries: return False
215 return True
216
217 def pretty_print(self, q):
218 q.text("bsn_gentable_desc_stats_entry {")
219 with q.group():
220 with q.indent(2):
221 q.breakable()
222 q.text("table_id = ");
223 q.text("%#x" % self.table_id)
224 q.text(","); q.breakable()
225 q.text("name = ");
226 q.pp(self.name)
227 q.text(","); q.breakable()
228 q.text("buckets_size = ");
229 q.text("%#x" % self.buckets_size)
230 q.text(","); q.breakable()
231 q.text("max_entries = ");
232 q.text("%#x" % self.max_entries)
233 q.breakable()
234 q.text('}')
235
236
237class bsn_gentable_entry_desc_stats_entry(loxi.OFObject):
238
239 def __init__(self, checksum=None, key=None, value=None):
240 if checksum != None:
241 self.checksum = checksum
242 else:
243 self.checksum = 0
244 if key != None:
245 self.key = key
246 else:
247 self.key = []
248 if value != None:
249 self.value = value
250 else:
251 self.value = []
252 return
253
254 def pack(self):
255 packed = []
256 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
257 packed.append(struct.pack("!H", 0)) # placeholder for key_length at index 1
258 packed.append(util.pack_checksum_128(self.checksum))
259 packed.append(loxi.generic_util.pack_list(self.key))
260 packed[1] = struct.pack("!H", len(packed[-1]))
261 packed.append(loxi.generic_util.pack_list(self.value))
262 length = sum([len(x) for x in packed])
263 packed[0] = struct.pack("!H", length)
264 return ''.join(packed)
265
266 @staticmethod
267 def unpack(reader):
268 obj = bsn_gentable_entry_desc_stats_entry()
269 _length = reader.read("!H")[0]
270 orig_reader = reader
271 reader = orig_reader.slice(_length - (0 + 2))
272 _key_length = reader.read("!H")[0]
273 obj.checksum = util.unpack_checksum_128(reader)
274 obj.key = loxi.generic_util.unpack_list(reader.slice(_key_length), bsn_tlv.bsn_tlv.unpack)
275 obj.value = loxi.generic_util.unpack_list(reader, bsn_tlv.bsn_tlv.unpack)
276 return obj
277
278 def __eq__(self, other):
279 if type(self) != type(other): return False
280 if self.checksum != other.checksum: return False
281 if self.key != other.key: return False
282 if self.value != other.value: return False
283 return True
284
285 def pretty_print(self, q):
286 q.text("bsn_gentable_entry_desc_stats_entry {")
287 with q.group():
288 with q.indent(2):
289 q.breakable()
290 q.text("checksum = ");
291 q.pp(self.checksum)
292 q.text(","); q.breakable()
293 q.text("key = ");
294 q.pp(self.key)
295 q.text(","); q.breakable()
296 q.text("value = ");
297 q.pp(self.value)
298 q.breakable()
299 q.text('}')
300
301
302class bsn_gentable_entry_stats_entry(loxi.OFObject):
303
304 def __init__(self, key=None, stats=None):
305 if key != None:
306 self.key = key
307 else:
308 self.key = []
309 if stats != None:
310 self.stats = stats
311 else:
312 self.stats = []
313 return
314
315 def pack(self):
316 packed = []
317 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
318 packed.append(struct.pack("!H", 0)) # placeholder for key_length at index 1
319 packed.append(loxi.generic_util.pack_list(self.key))
320 packed[1] = struct.pack("!H", len(packed[-1]))
321 packed.append(loxi.generic_util.pack_list(self.stats))
322 length = sum([len(x) for x in packed])
323 packed[0] = struct.pack("!H", length)
324 return ''.join(packed)
325
326 @staticmethod
327 def unpack(reader):
328 obj = bsn_gentable_entry_stats_entry()
329 _length = reader.read("!H")[0]
330 orig_reader = reader
331 reader = orig_reader.slice(_length - (0 + 2))
332 _key_length = reader.read("!H")[0]
333 obj.key = loxi.generic_util.unpack_list(reader.slice(_key_length), bsn_tlv.bsn_tlv.unpack)
334 obj.stats = loxi.generic_util.unpack_list(reader, bsn_tlv.bsn_tlv.unpack)
335 return obj
336
337 def __eq__(self, other):
338 if type(self) != type(other): return False
339 if self.key != other.key: return False
340 if self.stats != other.stats: return False
341 return True
342
343 def pretty_print(self, q):
344 q.text("bsn_gentable_entry_stats_entry {")
345 with q.group():
346 with q.indent(2):
347 q.breakable()
348 q.text("key = ");
349 q.pp(self.key)
350 q.text(","); q.breakable()
351 q.text("stats = ");
352 q.pp(self.stats)
353 q.breakable()
354 q.text('}')
355
356
357class bsn_gentable_stats_entry(loxi.OFObject):
358
359 def __init__(self, table_id=None, entry_count=None, checksum=None):
360 if table_id != None:
361 self.table_id = table_id
362 else:
363 self.table_id = 0
364 if entry_count != None:
365 self.entry_count = entry_count
366 else:
367 self.entry_count = 0
368 if checksum != None:
369 self.checksum = checksum
370 else:
371 self.checksum = 0
372 return
373
374 def pack(self):
375 packed = []
376 packed.append(struct.pack("!H", self.table_id))
377 packed.append('\x00' * 2)
378 packed.append(struct.pack("!L", self.entry_count))
379 packed.append(util.pack_checksum_128(self.checksum))
380 return ''.join(packed)
381
382 @staticmethod
383 def unpack(reader):
384 obj = bsn_gentable_stats_entry()
385 obj.table_id = reader.read("!H")[0]
386 reader.skip(2)
387 obj.entry_count = reader.read("!L")[0]
388 obj.checksum = util.unpack_checksum_128(reader)
389 return obj
390
391 def __eq__(self, other):
392 if type(self) != type(other): return False
393 if self.table_id != other.table_id: return False
394 if self.entry_count != other.entry_count: return False
395 if self.checksum != other.checksum: return False
396 return True
397
398 def pretty_print(self, q):
399 q.text("bsn_gentable_stats_entry {")
400 with q.group():
401 with q.indent(2):
402 q.breakable()
403 q.text("table_id = ");
404 q.text("%#x" % self.table_id)
405 q.text(","); q.breakable()
406 q.text("entry_count = ");
407 q.text("%#x" % self.entry_count)
408 q.text(","); q.breakable()
409 q.text("checksum = ");
410 q.pp(self.checksum)
411 q.breakable()
412 q.text('}')
413
414
Rich Lane7dcdf022013-12-11 14:45:27 -0800415class bsn_interface(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700416
417 def __init__(self, hw_addr=None, name=None, ipv4_addr=None, ipv4_netmask=None):
418 if hw_addr != None:
419 self.hw_addr = hw_addr
420 else:
421 self.hw_addr = [0,0,0,0,0,0]
422 if name != None:
423 self.name = name
424 else:
425 self.name = ""
426 if ipv4_addr != None:
427 self.ipv4_addr = ipv4_addr
428 else:
429 self.ipv4_addr = 0
430 if ipv4_netmask != None:
431 self.ipv4_netmask = ipv4_netmask
432 else:
433 self.ipv4_netmask = 0
434 return
435
436 def pack(self):
437 packed = []
438 packed.append(struct.pack("!6B", *self.hw_addr))
439 packed.append('\x00' * 2)
440 packed.append(struct.pack("!16s", self.name))
441 packed.append(struct.pack("!L", self.ipv4_addr))
442 packed.append(struct.pack("!L", self.ipv4_netmask))
443 return ''.join(packed)
444
445 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800446 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700447 obj = bsn_interface()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700448 obj.hw_addr = list(reader.read('!6B'))
449 reader.skip(2)
450 obj.name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -0700451 obj.ipv4_addr = reader.read("!L")[0]
452 obj.ipv4_netmask = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700453 return obj
454
455 def __eq__(self, other):
456 if type(self) != type(other): return False
457 if self.hw_addr != other.hw_addr: return False
458 if self.name != other.name: return False
459 if self.ipv4_addr != other.ipv4_addr: return False
460 if self.ipv4_netmask != other.ipv4_netmask: return False
461 return True
462
Rich Lanec2ee4b82013-04-24 17:12:38 -0700463 def pretty_print(self, q):
464 q.text("bsn_interface {")
465 with q.group():
466 with q.indent(2):
467 q.breakable()
468 q.text("hw_addr = ");
469 q.text(util.pretty_mac(self.hw_addr))
470 q.text(","); q.breakable()
471 q.text("name = ");
472 q.pp(self.name)
473 q.text(","); q.breakable()
474 q.text("ipv4_addr = ");
475 q.text(util.pretty_ipv4(self.ipv4_addr))
476 q.text(","); q.breakable()
477 q.text("ipv4_netmask = ");
478 q.text(util.pretty_ipv4(self.ipv4_netmask))
479 q.breakable()
480 q.text('}')
481
Rich Lane7dcdf022013-12-11 14:45:27 -0800482
483class bsn_lacp_stats_entry(loxi.OFObject):
Rich Lane7b0f2012013-11-22 14:15:26 -0800484
485 def __init__(self, port_no=None, actor_sys_priority=None, actor_sys_mac=None, actor_port_priority=None, actor_port_num=None, actor_key=None, convergence_status=None, partner_sys_priority=None, partner_sys_mac=None, partner_port_priority=None, partner_port_num=None, partner_key=None):
486 if port_no != None:
487 self.port_no = port_no
488 else:
489 self.port_no = 0
490 if actor_sys_priority != None:
491 self.actor_sys_priority = actor_sys_priority
492 else:
493 self.actor_sys_priority = 0
494 if actor_sys_mac != None:
495 self.actor_sys_mac = actor_sys_mac
496 else:
497 self.actor_sys_mac = [0,0,0,0,0,0]
498 if actor_port_priority != None:
499 self.actor_port_priority = actor_port_priority
500 else:
501 self.actor_port_priority = 0
502 if actor_port_num != None:
503 self.actor_port_num = actor_port_num
504 else:
505 self.actor_port_num = 0
506 if actor_key != None:
507 self.actor_key = actor_key
508 else:
509 self.actor_key = 0
510 if convergence_status != None:
511 self.convergence_status = convergence_status
512 else:
513 self.convergence_status = 0
514 if partner_sys_priority != None:
515 self.partner_sys_priority = partner_sys_priority
516 else:
517 self.partner_sys_priority = 0
518 if partner_sys_mac != None:
519 self.partner_sys_mac = partner_sys_mac
520 else:
521 self.partner_sys_mac = [0,0,0,0,0,0]
522 if partner_port_priority != None:
523 self.partner_port_priority = partner_port_priority
524 else:
525 self.partner_port_priority = 0
526 if partner_port_num != None:
527 self.partner_port_num = partner_port_num
528 else:
529 self.partner_port_num = 0
530 if partner_key != None:
531 self.partner_key = partner_key
532 else:
533 self.partner_key = 0
534 return
535
536 def pack(self):
537 packed = []
538 packed.append(util.pack_port_no(self.port_no))
539 packed.append(struct.pack("!H", self.actor_sys_priority))
540 packed.append(struct.pack("!6B", *self.actor_sys_mac))
541 packed.append(struct.pack("!H", self.actor_port_priority))
542 packed.append(struct.pack("!H", self.actor_port_num))
543 packed.append(struct.pack("!H", self.actor_key))
544 packed.append(struct.pack("!B", self.convergence_status))
545 packed.append('\x00' * 1)
546 packed.append(struct.pack("!H", self.partner_sys_priority))
547 packed.append(struct.pack("!6B", *self.partner_sys_mac))
548 packed.append(struct.pack("!H", self.partner_port_priority))
549 packed.append(struct.pack("!H", self.partner_port_num))
550 packed.append(struct.pack("!H", self.partner_key))
551 packed.append('\x00' * 2)
552 return ''.join(packed)
553
554 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800555 def unpack(reader):
Rich Lane7b0f2012013-11-22 14:15:26 -0800556 obj = bsn_lacp_stats_entry()
Rich Lane7b0f2012013-11-22 14:15:26 -0800557 obj.port_no = util.unpack_port_no(reader)
558 obj.actor_sys_priority = reader.read("!H")[0]
559 obj.actor_sys_mac = list(reader.read('!6B'))
560 obj.actor_port_priority = reader.read("!H")[0]
561 obj.actor_port_num = reader.read("!H")[0]
562 obj.actor_key = reader.read("!H")[0]
563 obj.convergence_status = reader.read("!B")[0]
564 reader.skip(1)
565 obj.partner_sys_priority = reader.read("!H")[0]
566 obj.partner_sys_mac = list(reader.read('!6B'))
567 obj.partner_port_priority = reader.read("!H")[0]
568 obj.partner_port_num = reader.read("!H")[0]
569 obj.partner_key = reader.read("!H")[0]
570 reader.skip(2)
571 return obj
572
573 def __eq__(self, other):
574 if type(self) != type(other): return False
575 if self.port_no != other.port_no: return False
576 if self.actor_sys_priority != other.actor_sys_priority: return False
577 if self.actor_sys_mac != other.actor_sys_mac: return False
578 if self.actor_port_priority != other.actor_port_priority: return False
579 if self.actor_port_num != other.actor_port_num: return False
580 if self.actor_key != other.actor_key: return False
581 if self.convergence_status != other.convergence_status: return False
582 if self.partner_sys_priority != other.partner_sys_priority: return False
583 if self.partner_sys_mac != other.partner_sys_mac: return False
584 if self.partner_port_priority != other.partner_port_priority: return False
585 if self.partner_port_num != other.partner_port_num: return False
586 if self.partner_key != other.partner_key: return False
587 return True
588
Rich Lane7b0f2012013-11-22 14:15:26 -0800589 def pretty_print(self, q):
590 q.text("bsn_lacp_stats_entry {")
591 with q.group():
592 with q.indent(2):
593 q.breakable()
594 q.text("port_no = ");
595 q.text(util.pretty_port(self.port_no))
596 q.text(","); q.breakable()
597 q.text("actor_sys_priority = ");
598 q.text("%#x" % self.actor_sys_priority)
599 q.text(","); q.breakable()
600 q.text("actor_sys_mac = ");
601 q.text(util.pretty_mac(self.actor_sys_mac))
602 q.text(","); q.breakable()
603 q.text("actor_port_priority = ");
604 q.text("%#x" % self.actor_port_priority)
605 q.text(","); q.breakable()
606 q.text("actor_port_num = ");
607 q.text("%#x" % self.actor_port_num)
608 q.text(","); q.breakable()
609 q.text("actor_key = ");
610 q.text("%#x" % self.actor_key)
611 q.text(","); q.breakable()
612 q.text("convergence_status = ");
613 q.text("%#x" % self.convergence_status)
614 q.text(","); q.breakable()
615 q.text("partner_sys_priority = ");
616 q.text("%#x" % self.partner_sys_priority)
617 q.text(","); q.breakable()
618 q.text("partner_sys_mac = ");
619 q.text(util.pretty_mac(self.partner_sys_mac))
620 q.text(","); q.breakable()
621 q.text("partner_port_priority = ");
622 q.text("%#x" % self.partner_port_priority)
623 q.text(","); q.breakable()
624 q.text("partner_port_num = ");
625 q.text("%#x" % self.partner_port_num)
626 q.text(","); q.breakable()
627 q.text("partner_key = ");
628 q.text("%#x" % self.partner_key)
629 q.breakable()
630 q.text('}')
631
Rich Lane7dcdf022013-12-11 14:45:27 -0800632
633class bsn_port_counter_stats_entry(loxi.OFObject):
634
635 def __init__(self, port_no=None, values=None):
636 if port_no != None:
637 self.port_no = port_no
638 else:
639 self.port_no = 0
640 if values != None:
641 self.values = values
642 else:
643 self.values = []
644 return
645
646 def pack(self):
647 packed = []
648 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
649 packed.append('\x00' * 2)
650 packed.append(util.pack_port_no(self.port_no))
651 packed.append(loxi.generic_util.pack_list(self.values))
652 length = sum([len(x) for x in packed])
653 packed[0] = struct.pack("!H", length)
654 return ''.join(packed)
655
656 @staticmethod
657 def unpack(reader):
658 obj = bsn_port_counter_stats_entry()
659 _length = reader.read("!H")[0]
660 orig_reader = reader
661 reader = orig_reader.slice(_length - (0 + 2))
662 reader.skip(2)
663 obj.port_no = util.unpack_port_no(reader)
664 obj.values = loxi.generic_util.unpack_list(reader, common.uint64.unpack)
665 return obj
666
667 def __eq__(self, other):
668 if type(self) != type(other): return False
669 if self.port_no != other.port_no: return False
670 if self.values != other.values: return False
671 return True
672
673 def pretty_print(self, q):
674 q.text("bsn_port_counter_stats_entry {")
675 with q.group():
676 with q.indent(2):
677 q.breakable()
678 q.text("port_no = ");
679 q.text(util.pretty_port(self.port_no))
680 q.text(","); q.breakable()
681 q.text("values = ");
682 q.pp(self.values)
683 q.breakable()
684 q.text('}')
685
686
687class bsn_switch_pipeline_stats_entry(loxi.OFObject):
688
689 def __init__(self, pipeline=None):
690 if pipeline != None:
691 self.pipeline = pipeline
692 else:
693 self.pipeline = ""
694 return
695
696 def pack(self):
697 packed = []
698 packed.append(struct.pack("!256s", self.pipeline))
699 return ''.join(packed)
700
701 @staticmethod
702 def unpack(reader):
703 obj = bsn_switch_pipeline_stats_entry()
704 obj.pipeline = reader.read("!256s")[0].rstrip("\x00")
705 return obj
706
707 def __eq__(self, other):
708 if type(self) != type(other): return False
709 if self.pipeline != other.pipeline: return False
710 return True
711
712 def pretty_print(self, q):
713 q.text("bsn_switch_pipeline_stats_entry {")
714 with q.group():
715 with q.indent(2):
716 q.breakable()
717 q.text("pipeline = ");
718 q.pp(self.pipeline)
719 q.breakable()
720 q.text('}')
721
722
Rich Lane9ec3fca2014-02-26 16:22:56 -0800723class bsn_table_checksum_stats_entry(loxi.OFObject):
724
725 def __init__(self, table_id=None, checksum=None):
726 if table_id != None:
727 self.table_id = table_id
728 else:
729 self.table_id = 0
730 if checksum != None:
731 self.checksum = checksum
732 else:
733 self.checksum = 0
734 return
735
736 def pack(self):
737 packed = []
738 packed.append(struct.pack("!B", self.table_id))
739 packed.append(struct.pack("!Q", self.checksum))
740 return ''.join(packed)
741
742 @staticmethod
743 def unpack(reader):
744 obj = bsn_table_checksum_stats_entry()
745 obj.table_id = reader.read("!B")[0]
746 obj.checksum = reader.read("!Q")[0]
747 return obj
748
749 def __eq__(self, other):
750 if type(self) != type(other): return False
751 if self.table_id != other.table_id: return False
752 if self.checksum != other.checksum: return False
753 return True
754
755 def pretty_print(self, q):
756 q.text("bsn_table_checksum_stats_entry {")
757 with q.group():
758 with q.indent(2):
759 q.breakable()
760 q.text("table_id = ");
761 q.text("%#x" % self.table_id)
762 q.text(","); q.breakable()
763 q.text("checksum = ");
764 q.text("%#x" % self.checksum)
765 q.breakable()
766 q.text('}')
767
768
Rich Lane7dcdf022013-12-11 14:45:27 -0800769class bsn_vport(loxi.OFObject):
770 subtypes = {}
771
Rich Lane95f7fc92014-01-27 17:08:16 -0800772
773 def __init__(self, type=None):
774 if type != None:
775 self.type = type
776 else:
777 self.type = 0
778 return
779
780 def pack(self):
781 packed = []
782 packed.append(struct.pack("!H", self.type))
783 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
784 length = sum([len(x) for x in packed])
785 packed[1] = struct.pack("!H", length)
786 return ''.join(packed)
787
Rich Lane7dcdf022013-12-11 14:45:27 -0800788 @staticmethod
789 def unpack(reader):
790 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -0800791 subclass = bsn_vport.subtypes.get(subtype)
792 if subclass:
793 return subclass.unpack(reader)
794
795 obj = bsn_vport()
796 obj.type = reader.read("!H")[0]
797 _length = reader.read("!H")[0]
798 orig_reader = reader
799 reader = orig_reader.slice(_length - (2 + 2))
800 return obj
801
802 def __eq__(self, other):
803 if type(self) != type(other): return False
804 if self.type != other.type: return False
805 return True
806
807 def pretty_print(self, q):
808 q.text("bsn_vport {")
809 with q.group():
810 with q.indent(2):
811 q.breakable()
812 q.breakable()
813 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800814
815
816class bsn_vport_q_in_q(bsn_vport):
Dan Talaycof6202252013-07-02 01:00:29 -0700817 type = 0
818
Kiran Poola150d8b02013-09-20 13:30:39 -0700819 def __init__(self, port_no=None, ingress_tpid=None, ingress_vlan_id=None, egress_tpid=None, egress_vlan_id=None, if_name=None):
Dan Talaycof6202252013-07-02 01:00:29 -0700820 if port_no != None:
821 self.port_no = port_no
822 else:
823 self.port_no = 0
824 if ingress_tpid != None:
825 self.ingress_tpid = ingress_tpid
826 else:
827 self.ingress_tpid = 0
828 if ingress_vlan_id != None:
829 self.ingress_vlan_id = ingress_vlan_id
830 else:
831 self.ingress_vlan_id = 0
832 if egress_tpid != None:
833 self.egress_tpid = egress_tpid
834 else:
835 self.egress_tpid = 0
836 if egress_vlan_id != None:
837 self.egress_vlan_id = egress_vlan_id
838 else:
839 self.egress_vlan_id = 0
Kiran Poola150d8b02013-09-20 13:30:39 -0700840 if if_name != None:
841 self.if_name = if_name
842 else:
843 self.if_name = ""
Dan Talaycof6202252013-07-02 01:00:29 -0700844 return
845
846 def pack(self):
847 packed = []
848 packed.append(struct.pack("!H", self.type))
Kiran Poola150d8b02013-09-20 13:30:39 -0700849 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700850 packed.append(struct.pack("!L", self.port_no))
851 packed.append(struct.pack("!H", self.ingress_tpid))
852 packed.append(struct.pack("!H", self.ingress_vlan_id))
853 packed.append(struct.pack("!H", self.egress_tpid))
854 packed.append(struct.pack("!H", self.egress_vlan_id))
Kiran Poola150d8b02013-09-20 13:30:39 -0700855 packed.append(struct.pack("!16s", self.if_name))
Dan Talaycof6202252013-07-02 01:00:29 -0700856 length = sum([len(x) for x in packed])
Kiran Poola150d8b02013-09-20 13:30:39 -0700857 packed[1] = struct.pack("!H", length)
Dan Talaycof6202252013-07-02 01:00:29 -0700858 return ''.join(packed)
859
860 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800861 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -0700862 obj = bsn_vport_q_in_q()
Dan Talaycof6202252013-07-02 01:00:29 -0700863 _type = reader.read("!H")[0]
864 assert(_type == 0)
865 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800866 orig_reader = reader
867 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700868 obj.port_no = reader.read("!L")[0]
869 obj.ingress_tpid = reader.read("!H")[0]
870 obj.ingress_vlan_id = reader.read("!H")[0]
871 obj.egress_tpid = reader.read("!H")[0]
872 obj.egress_vlan_id = reader.read("!H")[0]
Kiran Poola150d8b02013-09-20 13:30:39 -0700873 obj.if_name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -0700874 return obj
875
876 def __eq__(self, other):
877 if type(self) != type(other): return False
878 if self.port_no != other.port_no: return False
879 if self.ingress_tpid != other.ingress_tpid: return False
880 if self.ingress_vlan_id != other.ingress_vlan_id: return False
881 if self.egress_tpid != other.egress_tpid: return False
882 if self.egress_vlan_id != other.egress_vlan_id: return False
Kiran Poola150d8b02013-09-20 13:30:39 -0700883 if self.if_name != other.if_name: return False
Dan Talaycof6202252013-07-02 01:00:29 -0700884 return True
885
Dan Talaycof6202252013-07-02 01:00:29 -0700886 def pretty_print(self, q):
887 q.text("bsn_vport_q_in_q {")
888 with q.group():
889 with q.indent(2):
890 q.breakable()
891 q.text("port_no = ");
892 q.text("%#x" % self.port_no)
893 q.text(","); q.breakable()
894 q.text("ingress_tpid = ");
895 q.text("%#x" % self.ingress_tpid)
896 q.text(","); q.breakable()
897 q.text("ingress_vlan_id = ");
898 q.text("%#x" % self.ingress_vlan_id)
899 q.text(","); q.breakable()
900 q.text("egress_tpid = ");
901 q.text("%#x" % self.egress_tpid)
902 q.text(","); q.breakable()
903 q.text("egress_vlan_id = ");
904 q.text("%#x" % self.egress_vlan_id)
Kiran Poola150d8b02013-09-20 13:30:39 -0700905 q.text(","); q.breakable()
906 q.text("if_name = ");
907 q.pp(self.if_name)
Dan Talaycof6202252013-07-02 01:00:29 -0700908 q.breakable()
909 q.text('}')
910
Rich Lane7dcdf022013-12-11 14:45:27 -0800911bsn_vport.subtypes[0] = bsn_vport_q_in_q
912
913class bsn_vlan_counter_stats_entry(loxi.OFObject):
914
915 def __init__(self, vlan_vid=None, values=None):
916 if vlan_vid != None:
917 self.vlan_vid = vlan_vid
918 else:
919 self.vlan_vid = 0
920 if values != None:
921 self.values = values
922 else:
923 self.values = []
924 return
925
926 def pack(self):
927 packed = []
928 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
929 packed.append(struct.pack("!H", self.vlan_vid))
930 packed.append('\x00' * 4)
931 packed.append(loxi.generic_util.pack_list(self.values))
932 length = sum([len(x) for x in packed])
933 packed[0] = struct.pack("!H", length)
934 return ''.join(packed)
935
936 @staticmethod
937 def unpack(reader):
938 obj = bsn_vlan_counter_stats_entry()
939 _length = reader.read("!H")[0]
940 orig_reader = reader
941 reader = orig_reader.slice(_length - (0 + 2))
942 obj.vlan_vid = reader.read("!H")[0]
943 reader.skip(4)
944 obj.values = loxi.generic_util.unpack_list(reader, common.uint64.unpack)
945 return obj
946
947 def __eq__(self, other):
948 if type(self) != type(other): return False
949 if self.vlan_vid != other.vlan_vid: return False
950 if self.values != other.values: return False
951 return True
952
953 def pretty_print(self, q):
954 q.text("bsn_vlan_counter_stats_entry {")
955 with q.group():
956 with q.indent(2):
957 q.breakable()
958 q.text("vlan_vid = ");
959 q.text("%#x" % self.vlan_vid)
960 q.text(","); q.breakable()
961 q.text("values = ");
962 q.pp(self.values)
963 q.breakable()
964 q.text('}')
965
966
967class bucket(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700968
969 def __init__(self, weight=None, watch_port=None, watch_group=None, actions=None):
970 if weight != None:
971 self.weight = weight
972 else:
973 self.weight = 0
974 if watch_port != None:
975 self.watch_port = watch_port
976 else:
977 self.watch_port = 0
978 if watch_group != None:
979 self.watch_group = watch_group
980 else:
981 self.watch_group = 0
982 if actions != None:
983 self.actions = actions
984 else:
985 self.actions = []
986 return
987
988 def pack(self):
989 packed = []
990 packed.append(struct.pack("!H", 0)) # placeholder for len at index 0
991 packed.append(struct.pack("!H", self.weight))
Dan Talaycof6202252013-07-02 01:00:29 -0700992 packed.append(util.pack_port_no(self.watch_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700993 packed.append(struct.pack("!L", self.watch_group))
994 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -0800995 packed.append(loxi.generic_util.pack_list(self.actions))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700996 length = sum([len(x) for x in packed])
997 packed[0] = struct.pack("!H", length)
998 return ''.join(packed)
999
1000 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001001 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001002 obj = bucket()
Dan Talaycof6202252013-07-02 01:00:29 -07001003 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001004 orig_reader = reader
1005 reader = orig_reader.slice(_len - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001006 obj.weight = reader.read("!H")[0]
1007 obj.watch_port = util.unpack_port_no(reader)
1008 obj.watch_group = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001009 reader.skip(4)
Rich Lane7dcdf022013-12-11 14:45:27 -08001010 obj.actions = loxi.generic_util.unpack_list(reader, action.action.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001011 return obj
1012
1013 def __eq__(self, other):
1014 if type(self) != type(other): return False
1015 if self.weight != other.weight: return False
1016 if self.watch_port != other.watch_port: return False
1017 if self.watch_group != other.watch_group: return False
1018 if self.actions != other.actions: return False
1019 return True
1020
Rich Lanec2ee4b82013-04-24 17:12:38 -07001021 def pretty_print(self, q):
1022 q.text("bucket {")
1023 with q.group():
1024 with q.indent(2):
1025 q.breakable()
1026 q.text("weight = ");
1027 q.text("%#x" % self.weight)
1028 q.text(","); q.breakable()
1029 q.text("watch_port = ");
1030 q.text(util.pretty_port(self.watch_port))
1031 q.text(","); q.breakable()
1032 q.text("watch_group = ");
1033 q.text("%#x" % self.watch_group)
1034 q.text(","); q.breakable()
1035 q.text("actions = ");
1036 q.pp(self.actions)
1037 q.breakable()
1038 q.text('}')
1039
Rich Lane7dcdf022013-12-11 14:45:27 -08001040
1041class bucket_counter(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001042
1043 def __init__(self, packet_count=None, byte_count=None):
1044 if packet_count != None:
1045 self.packet_count = packet_count
1046 else:
1047 self.packet_count = 0
1048 if byte_count != None:
1049 self.byte_count = byte_count
1050 else:
1051 self.byte_count = 0
1052 return
1053
1054 def pack(self):
1055 packed = []
1056 packed.append(struct.pack("!Q", self.packet_count))
1057 packed.append(struct.pack("!Q", self.byte_count))
1058 return ''.join(packed)
1059
1060 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001061 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001062 obj = bucket_counter()
Dan Talaycof6202252013-07-02 01:00:29 -07001063 obj.packet_count = reader.read("!Q")[0]
1064 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001065 return obj
1066
1067 def __eq__(self, other):
1068 if type(self) != type(other): return False
1069 if self.packet_count != other.packet_count: return False
1070 if self.byte_count != other.byte_count: return False
1071 return True
1072
Rich Lanec2ee4b82013-04-24 17:12:38 -07001073 def pretty_print(self, q):
1074 q.text("bucket_counter {")
1075 with q.group():
1076 with q.indent(2):
1077 q.breakable()
1078 q.text("packet_count = ");
1079 q.text("%#x" % self.packet_count)
1080 q.text(","); q.breakable()
1081 q.text("byte_count = ");
1082 q.text("%#x" % self.byte_count)
1083 q.breakable()
1084 q.text('}')
1085
Rich Lane7dcdf022013-12-11 14:45:27 -08001086
1087class experimenter_stats_header(loxi.OFObject):
1088 subtypes = {}
1089
Rich Lane95f7fc92014-01-27 17:08:16 -08001090
1091 def __init__(self, experimenter=None, subtype=None):
1092 if experimenter != None:
1093 self.experimenter = experimenter
1094 else:
1095 self.experimenter = 0
1096 if subtype != None:
1097 self.subtype = subtype
1098 else:
1099 self.subtype = 0
1100 return
1101
1102 def pack(self):
1103 packed = []
1104 packed.append(struct.pack("!L", self.experimenter))
1105 packed.append(struct.pack("!L", self.subtype))
1106 return ''.join(packed)
1107
Rich Lane7dcdf022013-12-11 14:45:27 -08001108 @staticmethod
1109 def unpack(reader):
1110 subtype, = reader.peek('!L', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -08001111 subclass = experimenter_stats_header.subtypes.get(subtype)
1112 if subclass:
1113 return subclass.unpack(reader)
1114
1115 obj = experimenter_stats_header()
1116 obj.experimenter = reader.read("!L")[0]
1117 obj.subtype = reader.read("!L")[0]
1118 return obj
1119
1120 def __eq__(self, other):
1121 if type(self) != type(other): return False
1122 if self.experimenter != other.experimenter: return False
1123 if self.subtype != other.subtype: return False
1124 return True
1125
1126 def pretty_print(self, q):
1127 q.text("experimenter_stats_header {")
1128 with q.group():
1129 with q.indent(2):
1130 q.breakable()
1131 q.text("subtype = ");
1132 q.text("%#x" % self.subtype)
1133 q.breakable()
1134 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08001135
1136
1137class flow_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001138
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001139 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 -07001140 if table_id != None:
1141 self.table_id = table_id
1142 else:
1143 self.table_id = 0
1144 if duration_sec != None:
1145 self.duration_sec = duration_sec
1146 else:
1147 self.duration_sec = 0
1148 if duration_nsec != None:
1149 self.duration_nsec = duration_nsec
1150 else:
1151 self.duration_nsec = 0
1152 if priority != None:
1153 self.priority = priority
1154 else:
1155 self.priority = 0
1156 if idle_timeout != None:
1157 self.idle_timeout = idle_timeout
1158 else:
1159 self.idle_timeout = 0
1160 if hard_timeout != None:
1161 self.hard_timeout = hard_timeout
1162 else:
1163 self.hard_timeout = 0
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001164 if flags != None:
1165 self.flags = flags
1166 else:
1167 self.flags = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07001168 if cookie != None:
1169 self.cookie = cookie
1170 else:
1171 self.cookie = 0
1172 if packet_count != None:
1173 self.packet_count = packet_count
1174 else:
1175 self.packet_count = 0
1176 if byte_count != None:
1177 self.byte_count = byte_count
1178 else:
1179 self.byte_count = 0
1180 if match != None:
1181 self.match = match
1182 else:
1183 self.match = common.match()
1184 if instructions != None:
1185 self.instructions = instructions
1186 else:
1187 self.instructions = []
1188 return
1189
1190 def pack(self):
1191 packed = []
1192 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
1193 packed.append(struct.pack("!B", self.table_id))
1194 packed.append('\x00' * 1)
1195 packed.append(struct.pack("!L", self.duration_sec))
1196 packed.append(struct.pack("!L", self.duration_nsec))
1197 packed.append(struct.pack("!H", self.priority))
1198 packed.append(struct.pack("!H", self.idle_timeout))
1199 packed.append(struct.pack("!H", self.hard_timeout))
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001200 packed.append(struct.pack("!H", self.flags))
1201 packed.append('\x00' * 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001202 packed.append(struct.pack("!Q", self.cookie))
1203 packed.append(struct.pack("!Q", self.packet_count))
1204 packed.append(struct.pack("!Q", self.byte_count))
1205 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08001206 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001207 length = sum([len(x) for x in packed])
1208 packed[0] = struct.pack("!H", length)
1209 return ''.join(packed)
1210
1211 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001212 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001213 obj = flow_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001214 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001215 orig_reader = reader
1216 reader = orig_reader.slice(_length - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001217 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001218 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -07001219 obj.duration_sec = reader.read("!L")[0]
1220 obj.duration_nsec = reader.read("!L")[0]
1221 obj.priority = reader.read("!H")[0]
1222 obj.idle_timeout = reader.read("!H")[0]
1223 obj.hard_timeout = reader.read("!H")[0]
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001224 obj.flags = reader.read("!H")[0]
1225 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001226 obj.cookie = reader.read("!Q")[0]
1227 obj.packet_count = reader.read("!Q")[0]
1228 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001229 obj.match = common.match.unpack(reader)
Rich Lane7dcdf022013-12-11 14:45:27 -08001230 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001231 return obj
1232
1233 def __eq__(self, other):
1234 if type(self) != type(other): return False
1235 if self.table_id != other.table_id: return False
1236 if self.duration_sec != other.duration_sec: return False
1237 if self.duration_nsec != other.duration_nsec: return False
1238 if self.priority != other.priority: return False
1239 if self.idle_timeout != other.idle_timeout: return False
1240 if self.hard_timeout != other.hard_timeout: return False
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001241 if self.flags != other.flags: return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001242 if self.cookie != other.cookie: return False
1243 if self.packet_count != other.packet_count: return False
1244 if self.byte_count != other.byte_count: return False
1245 if self.match != other.match: return False
1246 if self.instructions != other.instructions: return False
1247 return True
1248
Rich Lanec2ee4b82013-04-24 17:12:38 -07001249 def pretty_print(self, q):
1250 q.text("flow_stats_entry {")
1251 with q.group():
1252 with q.indent(2):
1253 q.breakable()
1254 q.text("table_id = ");
1255 q.text("%#x" % self.table_id)
1256 q.text(","); q.breakable()
1257 q.text("duration_sec = ");
1258 q.text("%#x" % self.duration_sec)
1259 q.text(","); q.breakable()
1260 q.text("duration_nsec = ");
1261 q.text("%#x" % self.duration_nsec)
1262 q.text(","); q.breakable()
1263 q.text("priority = ");
1264 q.text("%#x" % self.priority)
1265 q.text(","); q.breakable()
1266 q.text("idle_timeout = ");
1267 q.text("%#x" % self.idle_timeout)
1268 q.text(","); q.breakable()
1269 q.text("hard_timeout = ");
1270 q.text("%#x" % self.hard_timeout)
1271 q.text(","); q.breakable()
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001272 q.text("flags = ");
1273 q.text("%#x" % self.flags)
1274 q.text(","); q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001275 q.text("cookie = ");
1276 q.text("%#x" % self.cookie)
1277 q.text(","); q.breakable()
1278 q.text("packet_count = ");
1279 q.text("%#x" % self.packet_count)
1280 q.text(","); q.breakable()
1281 q.text("byte_count = ");
1282 q.text("%#x" % self.byte_count)
1283 q.text(","); q.breakable()
1284 q.text("match = ");
1285 q.pp(self.match)
1286 q.text(","); q.breakable()
1287 q.text("instructions = ");
1288 q.pp(self.instructions)
1289 q.breakable()
1290 q.text('}')
1291
Rich Lane7dcdf022013-12-11 14:45:27 -08001292
1293class group_desc_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001294
Rich Lane6f4978c2013-10-20 21:33:52 -07001295 def __init__(self, group_type=None, group_id=None, buckets=None):
1296 if group_type != None:
1297 self.group_type = group_type
Rich Lanec2ee4b82013-04-24 17:12:38 -07001298 else:
Rich Lane6f4978c2013-10-20 21:33:52 -07001299 self.group_type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07001300 if group_id != None:
1301 self.group_id = group_id
1302 else:
1303 self.group_id = 0
1304 if buckets != None:
1305 self.buckets = buckets
1306 else:
1307 self.buckets = []
1308 return
1309
1310 def pack(self):
1311 packed = []
1312 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
Rich Lane6f4978c2013-10-20 21:33:52 -07001313 packed.append(struct.pack("!B", self.group_type))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001314 packed.append('\x00' * 1)
1315 packed.append(struct.pack("!L", self.group_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08001316 packed.append(loxi.generic_util.pack_list(self.buckets))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001317 length = sum([len(x) for x in packed])
1318 packed[0] = struct.pack("!H", length)
1319 return ''.join(packed)
1320
1321 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001322 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001323 obj = group_desc_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001324 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001325 orig_reader = reader
1326 reader = orig_reader.slice(_length - (0 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07001327 obj.group_type = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001328 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -07001329 obj.group_id = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001330 obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001331 return obj
1332
1333 def __eq__(self, other):
1334 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001335 if self.group_type != other.group_type: return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001336 if self.group_id != other.group_id: return False
1337 if self.buckets != other.buckets: return False
1338 return True
1339
Rich Lanec2ee4b82013-04-24 17:12:38 -07001340 def pretty_print(self, q):
1341 q.text("group_desc_stats_entry {")
1342 with q.group():
1343 with q.indent(2):
1344 q.breakable()
Rich Lane6f4978c2013-10-20 21:33:52 -07001345 q.text("group_type = ");
1346 q.text("%#x" % self.group_type)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001347 q.text(","); q.breakable()
1348 q.text("group_id = ");
1349 q.text("%#x" % self.group_id)
1350 q.text(","); q.breakable()
1351 q.text("buckets = ");
1352 q.pp(self.buckets)
1353 q.breakable()
1354 q.text('}')
1355
Rich Lane7dcdf022013-12-11 14:45:27 -08001356
1357class group_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001358
1359 def __init__(self, group_id=None, ref_count=None, packet_count=None, byte_count=None, duration_sec=None, duration_nsec=None, bucket_stats=None):
1360 if group_id != None:
1361 self.group_id = group_id
1362 else:
1363 self.group_id = 0
1364 if ref_count != None:
1365 self.ref_count = ref_count
1366 else:
1367 self.ref_count = 0
1368 if packet_count != None:
1369 self.packet_count = packet_count
1370 else:
1371 self.packet_count = 0
1372 if byte_count != None:
1373 self.byte_count = byte_count
1374 else:
1375 self.byte_count = 0
1376 if duration_sec != None:
1377 self.duration_sec = duration_sec
1378 else:
1379 self.duration_sec = 0
1380 if duration_nsec != None:
1381 self.duration_nsec = duration_nsec
1382 else:
1383 self.duration_nsec = 0
1384 if bucket_stats != None:
1385 self.bucket_stats = bucket_stats
1386 else:
1387 self.bucket_stats = []
1388 return
1389
1390 def pack(self):
1391 packed = []
1392 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
1393 packed.append('\x00' * 2)
1394 packed.append(struct.pack("!L", self.group_id))
1395 packed.append(struct.pack("!L", self.ref_count))
1396 packed.append('\x00' * 4)
1397 packed.append(struct.pack("!Q", self.packet_count))
1398 packed.append(struct.pack("!Q", self.byte_count))
1399 packed.append(struct.pack("!L", self.duration_sec))
1400 packed.append(struct.pack("!L", self.duration_nsec))
Rich Lane7dcdf022013-12-11 14:45:27 -08001401 packed.append(loxi.generic_util.pack_list(self.bucket_stats))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001402 length = sum([len(x) for x in packed])
1403 packed[0] = struct.pack("!H", length)
1404 return ''.join(packed)
1405
1406 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001407 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001408 obj = group_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001409 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001410 orig_reader = reader
1411 reader = orig_reader.slice(_length - (0 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001412 reader.skip(2)
Dan Talaycof6202252013-07-02 01:00:29 -07001413 obj.group_id = reader.read("!L")[0]
1414 obj.ref_count = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001415 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001416 obj.packet_count = reader.read("!Q")[0]
1417 obj.byte_count = reader.read("!Q")[0]
1418 obj.duration_sec = reader.read("!L")[0]
1419 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001420 obj.bucket_stats = loxi.generic_util.unpack_list(reader, common.bucket_counter.unpack)
1421 return obj
1422
1423 def __eq__(self, other):
1424 if type(self) != type(other): return False
1425 if self.group_id != other.group_id: return False
1426 if self.ref_count != other.ref_count: return False
1427 if self.packet_count != other.packet_count: return False
1428 if self.byte_count != other.byte_count: return False
1429 if self.duration_sec != other.duration_sec: return False
1430 if self.duration_nsec != other.duration_nsec: return False
1431 if self.bucket_stats != other.bucket_stats: return False
1432 return True
1433
Rich Lanec2ee4b82013-04-24 17:12:38 -07001434 def pretty_print(self, q):
1435 q.text("group_stats_entry {")
1436 with q.group():
1437 with q.indent(2):
1438 q.breakable()
1439 q.text("group_id = ");
1440 q.text("%#x" % self.group_id)
1441 q.text(","); q.breakable()
1442 q.text("ref_count = ");
1443 q.text("%#x" % self.ref_count)
1444 q.text(","); q.breakable()
1445 q.text("packet_count = ");
1446 q.text("%#x" % self.packet_count)
1447 q.text(","); q.breakable()
1448 q.text("byte_count = ");
1449 q.text("%#x" % self.byte_count)
1450 q.text(","); q.breakable()
1451 q.text("duration_sec = ");
1452 q.text("%#x" % self.duration_sec)
1453 q.text(","); q.breakable()
1454 q.text("duration_nsec = ");
1455 q.text("%#x" % self.duration_nsec)
1456 q.text(","); q.breakable()
1457 q.text("bucket_stats = ");
1458 q.pp(self.bucket_stats)
1459 q.breakable()
1460 q.text('}')
1461
Rich Lane7dcdf022013-12-11 14:45:27 -08001462
1463class hello_elem(loxi.OFObject):
1464 subtypes = {}
1465
Rich Lane95f7fc92014-01-27 17:08:16 -08001466
1467 def __init__(self, type=None):
1468 if type != None:
1469 self.type = type
1470 else:
1471 self.type = 0
1472 return
1473
1474 def pack(self):
1475 packed = []
1476 packed.append(struct.pack("!H", self.type))
1477 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
1478 length = sum([len(x) for x in packed])
1479 packed[1] = struct.pack("!H", length)
1480 return ''.join(packed)
1481
Rich Lane7dcdf022013-12-11 14:45:27 -08001482 @staticmethod
1483 def unpack(reader):
1484 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -08001485 subclass = hello_elem.subtypes.get(subtype)
1486 if subclass:
1487 return subclass.unpack(reader)
1488
1489 obj = hello_elem()
1490 obj.type = reader.read("!H")[0]
1491 _length = reader.read("!H")[0]
1492 orig_reader = reader
1493 reader = orig_reader.slice(_length - (2 + 2))
1494 return obj
1495
1496 def __eq__(self, other):
1497 if type(self) != type(other): return False
1498 if self.type != other.type: return False
1499 return True
1500
1501 def pretty_print(self, q):
1502 q.text("hello_elem {")
1503 with q.group():
1504 with q.indent(2):
1505 q.breakable()
1506 q.breakable()
1507 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08001508
1509
1510class hello_elem_versionbitmap(hello_elem):
Dan Talaycof6202252013-07-02 01:00:29 -07001511 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07001512
1513 def __init__(self, bitmaps=None):
1514 if bitmaps != None:
1515 self.bitmaps = bitmaps
1516 else:
1517 self.bitmaps = []
1518 return
1519
1520 def pack(self):
1521 packed = []
1522 packed.append(struct.pack("!H", self.type))
1523 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08001524 packed.append(loxi.generic_util.pack_list(self.bitmaps))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001525 length = sum([len(x) for x in packed])
1526 packed[1] = struct.pack("!H", length)
1527 return ''.join(packed)
1528
1529 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001530 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001531 obj = hello_elem_versionbitmap()
Dan Talaycof6202252013-07-02 01:00:29 -07001532 _type = reader.read("!H")[0]
1533 assert(_type == 1)
1534 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001535 orig_reader = reader
1536 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001537 obj.bitmaps = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
1538 return obj
1539
1540 def __eq__(self, other):
1541 if type(self) != type(other): return False
1542 if self.bitmaps != other.bitmaps: return False
1543 return True
1544
Rich Lanec2ee4b82013-04-24 17:12:38 -07001545 def pretty_print(self, q):
1546 q.text("hello_elem_versionbitmap {")
1547 with q.group():
1548 with q.indent(2):
1549 q.breakable()
1550 q.text("bitmaps = ");
1551 q.pp(self.bitmaps)
1552 q.breakable()
1553 q.text('}')
1554
Rich Lane7dcdf022013-12-11 14:45:27 -08001555hello_elem.subtypes[1] = hello_elem_versionbitmap
1556
1557class match_v3(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001558 type = 1
1559
1560 def __init__(self, oxm_list=None):
1561 if oxm_list != None:
1562 self.oxm_list = oxm_list
1563 else:
1564 self.oxm_list = []
1565 return
1566
1567 def pack(self):
1568 packed = []
1569 packed.append(struct.pack("!H", self.type))
1570 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08001571 packed.append(loxi.generic_util.pack_list(self.oxm_list))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001572 length = sum([len(x) for x in packed])
1573 packed[1] = struct.pack("!H", length)
Rich Laned53156a2013-08-05 17:17:33 -07001574 packed.append(loxi.generic_util.pad_to(8, length))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001575 return ''.join(packed)
1576
1577 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001578 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001579 obj = match_v3()
Dan Talaycof6202252013-07-02 01:00:29 -07001580 _type = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001581 assert(_type == 1)
Dan Talaycof6202252013-07-02 01:00:29 -07001582 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001583 orig_reader = reader
1584 reader = orig_reader.slice(_length - (2 + 2))
1585 obj.oxm_list = loxi.generic_util.unpack_list(reader, oxm.oxm.unpack)
1586 orig_reader.skip_align()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001587 return obj
1588
1589 def __eq__(self, other):
1590 if type(self) != type(other): return False
1591 if self.oxm_list != other.oxm_list: return False
1592 return True
1593
Rich Lanec2ee4b82013-04-24 17:12:38 -07001594 def pretty_print(self, q):
1595 q.text("match_v3 {")
1596 with q.group():
1597 with q.indent(2):
1598 q.breakable()
1599 q.text("oxm_list = ");
1600 q.pp(self.oxm_list)
1601 q.breakable()
1602 q.text('}')
1603
Rich Lane7dcdf022013-12-11 14:45:27 -08001604
1605class meter_band_stats(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001606
1607 def __init__(self, packet_band_count=None, byte_band_count=None):
1608 if packet_band_count != None:
1609 self.packet_band_count = packet_band_count
1610 else:
1611 self.packet_band_count = 0
1612 if byte_band_count != None:
1613 self.byte_band_count = byte_band_count
1614 else:
1615 self.byte_band_count = 0
1616 return
1617
1618 def pack(self):
1619 packed = []
1620 packed.append(struct.pack("!Q", self.packet_band_count))
1621 packed.append(struct.pack("!Q", self.byte_band_count))
1622 return ''.join(packed)
1623
1624 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001625 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001626 obj = meter_band_stats()
Dan Talaycof6202252013-07-02 01:00:29 -07001627 obj.packet_band_count = reader.read("!Q")[0]
1628 obj.byte_band_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001629 return obj
1630
1631 def __eq__(self, other):
1632 if type(self) != type(other): return False
1633 if self.packet_band_count != other.packet_band_count: return False
1634 if self.byte_band_count != other.byte_band_count: return False
1635 return True
1636
Rich Lanec2ee4b82013-04-24 17:12:38 -07001637 def pretty_print(self, q):
1638 q.text("meter_band_stats {")
1639 with q.group():
1640 with q.indent(2):
1641 q.breakable()
1642 q.text("packet_band_count = ");
1643 q.text("%#x" % self.packet_band_count)
1644 q.text(","); q.breakable()
1645 q.text("byte_band_count = ");
1646 q.text("%#x" % self.byte_band_count)
1647 q.breakable()
1648 q.text('}')
1649
Rich Lane7dcdf022013-12-11 14:45:27 -08001650
1651class meter_config(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001652
1653 def __init__(self, flags=None, meter_id=None, entries=None):
1654 if flags != None:
1655 self.flags = flags
1656 else:
1657 self.flags = 0
1658 if meter_id != None:
1659 self.meter_id = meter_id
1660 else:
1661 self.meter_id = 0
1662 if entries != None:
1663 self.entries = entries
1664 else:
1665 self.entries = []
1666 return
1667
1668 def pack(self):
1669 packed = []
1670 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
1671 packed.append(struct.pack("!H", self.flags))
1672 packed.append(struct.pack("!L", self.meter_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08001673 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001674 length = sum([len(x) for x in packed])
1675 packed[0] = struct.pack("!H", length)
1676 return ''.join(packed)
1677
1678 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001679 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001680 obj = meter_config()
Dan Talaycof6202252013-07-02 01:00:29 -07001681 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001682 orig_reader = reader
1683 reader = orig_reader.slice(_length - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001684 obj.flags = reader.read("!H")[0]
1685 obj.meter_id = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001686 obj.entries = loxi.generic_util.unpack_list(reader, meter_band.meter_band.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001687 return obj
1688
1689 def __eq__(self, other):
1690 if type(self) != type(other): return False
1691 if self.flags != other.flags: return False
1692 if self.meter_id != other.meter_id: return False
1693 if self.entries != other.entries: return False
1694 return True
1695
Rich Lanec2ee4b82013-04-24 17:12:38 -07001696 def pretty_print(self, q):
1697 q.text("meter_config {")
1698 with q.group():
1699 with q.indent(2):
1700 q.breakable()
1701 q.text("flags = ");
1702 q.text("%#x" % self.flags)
1703 q.text(","); q.breakable()
1704 q.text("meter_id = ");
1705 q.text("%#x" % self.meter_id)
1706 q.text(","); q.breakable()
1707 q.text("entries = ");
1708 q.pp(self.entries)
1709 q.breakable()
1710 q.text('}')
1711
Rich Lane7dcdf022013-12-11 14:45:27 -08001712
1713class meter_features(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001714
1715 def __init__(self, max_meter=None, band_types=None, capabilities=None, max_bands=None, max_color=None):
1716 if max_meter != None:
1717 self.max_meter = max_meter
1718 else:
1719 self.max_meter = 0
1720 if band_types != None:
1721 self.band_types = band_types
1722 else:
1723 self.band_types = 0
1724 if capabilities != None:
1725 self.capabilities = capabilities
1726 else:
1727 self.capabilities = 0
1728 if max_bands != None:
1729 self.max_bands = max_bands
1730 else:
1731 self.max_bands = 0
1732 if max_color != None:
1733 self.max_color = max_color
1734 else:
1735 self.max_color = 0
1736 return
1737
1738 def pack(self):
1739 packed = []
1740 packed.append(struct.pack("!L", self.max_meter))
1741 packed.append(struct.pack("!L", self.band_types))
1742 packed.append(struct.pack("!L", self.capabilities))
1743 packed.append(struct.pack("!B", self.max_bands))
1744 packed.append(struct.pack("!B", self.max_color))
1745 packed.append('\x00' * 2)
1746 return ''.join(packed)
1747
1748 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001749 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001750 obj = meter_features()
Dan Talaycof6202252013-07-02 01:00:29 -07001751 obj.max_meter = reader.read("!L")[0]
1752 obj.band_types = reader.read("!L")[0]
1753 obj.capabilities = reader.read("!L")[0]
1754 obj.max_bands = reader.read("!B")[0]
1755 obj.max_color = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001756 reader.skip(2)
1757 return obj
1758
1759 def __eq__(self, other):
1760 if type(self) != type(other): return False
1761 if self.max_meter != other.max_meter: return False
1762 if self.band_types != other.band_types: return False
1763 if self.capabilities != other.capabilities: return False
1764 if self.max_bands != other.max_bands: return False
1765 if self.max_color != other.max_color: return False
1766 return True
1767
Rich Lanec2ee4b82013-04-24 17:12:38 -07001768 def pretty_print(self, q):
1769 q.text("meter_features {")
1770 with q.group():
1771 with q.indent(2):
1772 q.breakable()
1773 q.text("max_meter = ");
1774 q.text("%#x" % self.max_meter)
1775 q.text(","); q.breakable()
1776 q.text("band_types = ");
1777 q.text("%#x" % self.band_types)
1778 q.text(","); q.breakable()
1779 q.text("capabilities = ");
1780 q.text("%#x" % self.capabilities)
1781 q.text(","); q.breakable()
1782 q.text("max_bands = ");
1783 q.text("%#x" % self.max_bands)
1784 q.text(","); q.breakable()
1785 q.text("max_color = ");
1786 q.text("%#x" % self.max_color)
1787 q.breakable()
1788 q.text('}')
1789
Rich Lane7dcdf022013-12-11 14:45:27 -08001790
1791class meter_stats(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001792
1793 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):
1794 if meter_id != None:
1795 self.meter_id = meter_id
1796 else:
1797 self.meter_id = 0
1798 if flow_count != None:
1799 self.flow_count = flow_count
1800 else:
1801 self.flow_count = 0
1802 if packet_in_count != None:
1803 self.packet_in_count = packet_in_count
1804 else:
1805 self.packet_in_count = 0
1806 if byte_in_count != None:
1807 self.byte_in_count = byte_in_count
1808 else:
1809 self.byte_in_count = 0
1810 if duration_sec != None:
1811 self.duration_sec = duration_sec
1812 else:
1813 self.duration_sec = 0
1814 if duration_nsec != None:
1815 self.duration_nsec = duration_nsec
1816 else:
1817 self.duration_nsec = 0
1818 if band_stats != None:
1819 self.band_stats = band_stats
1820 else:
1821 self.band_stats = []
1822 return
1823
1824 def pack(self):
1825 packed = []
1826 packed.append(struct.pack("!L", self.meter_id))
1827 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1828 packed.append('\x00' * 6)
1829 packed.append(struct.pack("!L", self.flow_count))
1830 packed.append(struct.pack("!Q", self.packet_in_count))
1831 packed.append(struct.pack("!Q", self.byte_in_count))
1832 packed.append(struct.pack("!L", self.duration_sec))
1833 packed.append(struct.pack("!L", self.duration_nsec))
Rich Lane7dcdf022013-12-11 14:45:27 -08001834 packed.append(loxi.generic_util.pack_list(self.band_stats))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001835 length = sum([len(x) for x in packed])
1836 packed[1] = struct.pack("!H", length)
1837 return ''.join(packed)
1838
1839 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001840 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001841 obj = meter_stats()
Dan Talaycof6202252013-07-02 01:00:29 -07001842 obj.meter_id = reader.read("!L")[0]
1843 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001844 orig_reader = reader
1845 reader = orig_reader.slice(_len - (4 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001846 reader.skip(6)
Dan Talaycof6202252013-07-02 01:00:29 -07001847 obj.flow_count = reader.read("!L")[0]
1848 obj.packet_in_count = reader.read("!Q")[0]
1849 obj.byte_in_count = reader.read("!Q")[0]
1850 obj.duration_sec = reader.read("!L")[0]
1851 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001852 obj.band_stats = loxi.generic_util.unpack_list(reader, common.meter_band_stats.unpack)
1853 return obj
1854
1855 def __eq__(self, other):
1856 if type(self) != type(other): return False
1857 if self.meter_id != other.meter_id: return False
1858 if self.flow_count != other.flow_count: return False
1859 if self.packet_in_count != other.packet_in_count: return False
1860 if self.byte_in_count != other.byte_in_count: return False
1861 if self.duration_sec != other.duration_sec: return False
1862 if self.duration_nsec != other.duration_nsec: return False
1863 if self.band_stats != other.band_stats: return False
1864 return True
1865
Rich Lanec2ee4b82013-04-24 17:12:38 -07001866 def pretty_print(self, q):
1867 q.text("meter_stats {")
1868 with q.group():
1869 with q.indent(2):
1870 q.breakable()
1871 q.text("meter_id = ");
1872 q.text("%#x" % self.meter_id)
1873 q.text(","); q.breakable()
1874 q.text("flow_count = ");
1875 q.text("%#x" % self.flow_count)
1876 q.text(","); q.breakable()
1877 q.text("packet_in_count = ");
1878 q.text("%#x" % self.packet_in_count)
1879 q.text(","); q.breakable()
1880 q.text("byte_in_count = ");
1881 q.text("%#x" % self.byte_in_count)
1882 q.text(","); q.breakable()
1883 q.text("duration_sec = ");
1884 q.text("%#x" % self.duration_sec)
1885 q.text(","); q.breakable()
1886 q.text("duration_nsec = ");
1887 q.text("%#x" % self.duration_nsec)
1888 q.text(","); q.breakable()
1889 q.text("band_stats = ");
1890 q.pp(self.band_stats)
1891 q.breakable()
1892 q.text('}')
1893
Rich Lane7dcdf022013-12-11 14:45:27 -08001894
1895class packet_queue(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001896
1897 def __init__(self, queue_id=None, port=None, properties=None):
1898 if queue_id != None:
1899 self.queue_id = queue_id
1900 else:
1901 self.queue_id = 0
1902 if port != None:
1903 self.port = port
1904 else:
1905 self.port = 0
1906 if properties != None:
1907 self.properties = properties
1908 else:
1909 self.properties = []
1910 return
1911
1912 def pack(self):
1913 packed = []
1914 packed.append(struct.pack("!L", self.queue_id))
Dan Talaycof6202252013-07-02 01:00:29 -07001915 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001916 packed.append(struct.pack("!H", 0)) # placeholder for len at index 2
1917 packed.append('\x00' * 6)
Rich Lane7dcdf022013-12-11 14:45:27 -08001918 packed.append(loxi.generic_util.pack_list(self.properties))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001919 length = sum([len(x) for x in packed])
1920 packed[2] = struct.pack("!H", length)
1921 return ''.join(packed)
1922
1923 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001924 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001925 obj = packet_queue()
Dan Talaycof6202252013-07-02 01:00:29 -07001926 obj.queue_id = reader.read("!L")[0]
1927 obj.port = util.unpack_port_no(reader)
1928 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001929 orig_reader = reader
1930 reader = orig_reader.slice(_len - (8 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001931 reader.skip(6)
Rich Lane7dcdf022013-12-11 14:45:27 -08001932 obj.properties = loxi.generic_util.unpack_list(reader, common.queue_prop.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001933 return obj
1934
1935 def __eq__(self, other):
1936 if type(self) != type(other): return False
1937 if self.queue_id != other.queue_id: return False
1938 if self.port != other.port: return False
1939 if self.properties != other.properties: return False
1940 return True
1941
Rich Lanec2ee4b82013-04-24 17:12:38 -07001942 def pretty_print(self, q):
1943 q.text("packet_queue {")
1944 with q.group():
1945 with q.indent(2):
1946 q.breakable()
1947 q.text("queue_id = ");
1948 q.text("%#x" % self.queue_id)
1949 q.text(","); q.breakable()
1950 q.text("port = ");
1951 q.text(util.pretty_port(self.port))
1952 q.text(","); q.breakable()
1953 q.text("properties = ");
1954 q.pp(self.properties)
1955 q.breakable()
1956 q.text('}')
1957
Rich Lane7dcdf022013-12-11 14:45:27 -08001958
1959class port_desc(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001960
1961 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):
1962 if port_no != None:
1963 self.port_no = port_no
1964 else:
1965 self.port_no = 0
1966 if hw_addr != None:
1967 self.hw_addr = hw_addr
1968 else:
1969 self.hw_addr = [0,0,0,0,0,0]
1970 if name != None:
1971 self.name = name
1972 else:
1973 self.name = ""
1974 if config != None:
1975 self.config = config
1976 else:
1977 self.config = 0
1978 if state != None:
1979 self.state = state
1980 else:
1981 self.state = 0
1982 if curr != None:
1983 self.curr = curr
1984 else:
1985 self.curr = 0
1986 if advertised != None:
1987 self.advertised = advertised
1988 else:
1989 self.advertised = 0
1990 if supported != None:
1991 self.supported = supported
1992 else:
1993 self.supported = 0
1994 if peer != None:
1995 self.peer = peer
1996 else:
1997 self.peer = 0
1998 if curr_speed != None:
1999 self.curr_speed = curr_speed
2000 else:
2001 self.curr_speed = 0
2002 if max_speed != None:
2003 self.max_speed = max_speed
2004 else:
2005 self.max_speed = 0
2006 return
2007
2008 def pack(self):
2009 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07002010 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002011 packed.append('\x00' * 4)
2012 packed.append(struct.pack("!6B", *self.hw_addr))
2013 packed.append('\x00' * 2)
2014 packed.append(struct.pack("!16s", self.name))
2015 packed.append(struct.pack("!L", self.config))
2016 packed.append(struct.pack("!L", self.state))
2017 packed.append(struct.pack("!L", self.curr))
2018 packed.append(struct.pack("!L", self.advertised))
2019 packed.append(struct.pack("!L", self.supported))
2020 packed.append(struct.pack("!L", self.peer))
2021 packed.append(struct.pack("!L", self.curr_speed))
2022 packed.append(struct.pack("!L", self.max_speed))
2023 return ''.join(packed)
2024
2025 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002026 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002027 obj = port_desc()
Dan Talaycof6202252013-07-02 01:00:29 -07002028 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002029 reader.skip(4)
2030 obj.hw_addr = list(reader.read('!6B'))
2031 reader.skip(2)
2032 obj.name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -07002033 obj.config = reader.read("!L")[0]
2034 obj.state = reader.read("!L")[0]
2035 obj.curr = reader.read("!L")[0]
2036 obj.advertised = reader.read("!L")[0]
2037 obj.supported = reader.read("!L")[0]
2038 obj.peer = reader.read("!L")[0]
2039 obj.curr_speed = reader.read("!L")[0]
2040 obj.max_speed = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002041 return obj
2042
2043 def __eq__(self, other):
2044 if type(self) != type(other): return False
2045 if self.port_no != other.port_no: return False
2046 if self.hw_addr != other.hw_addr: return False
2047 if self.name != other.name: return False
2048 if self.config != other.config: return False
2049 if self.state != other.state: return False
2050 if self.curr != other.curr: return False
2051 if self.advertised != other.advertised: return False
2052 if self.supported != other.supported: return False
2053 if self.peer != other.peer: return False
2054 if self.curr_speed != other.curr_speed: return False
2055 if self.max_speed != other.max_speed: return False
2056 return True
2057
Rich Lanec2ee4b82013-04-24 17:12:38 -07002058 def pretty_print(self, q):
2059 q.text("port_desc {")
2060 with q.group():
2061 with q.indent(2):
2062 q.breakable()
2063 q.text("port_no = ");
2064 q.text(util.pretty_port(self.port_no))
2065 q.text(","); q.breakable()
2066 q.text("hw_addr = ");
2067 q.text(util.pretty_mac(self.hw_addr))
2068 q.text(","); q.breakable()
2069 q.text("name = ");
2070 q.pp(self.name)
2071 q.text(","); q.breakable()
2072 q.text("config = ");
2073 q.text("%#x" % self.config)
2074 q.text(","); q.breakable()
2075 q.text("state = ");
2076 q.text("%#x" % self.state)
2077 q.text(","); q.breakable()
2078 q.text("curr = ");
2079 q.text("%#x" % self.curr)
2080 q.text(","); q.breakable()
2081 q.text("advertised = ");
2082 q.text("%#x" % self.advertised)
2083 q.text(","); q.breakable()
2084 q.text("supported = ");
2085 q.text("%#x" % self.supported)
2086 q.text(","); q.breakable()
2087 q.text("peer = ");
2088 q.text("%#x" % self.peer)
2089 q.text(","); q.breakable()
2090 q.text("curr_speed = ");
2091 q.text("%#x" % self.curr_speed)
2092 q.text(","); q.breakable()
2093 q.text("max_speed = ");
2094 q.text("%#x" % self.max_speed)
2095 q.breakable()
2096 q.text('}')
2097
Rich Lane7dcdf022013-12-11 14:45:27 -08002098
2099class port_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002100
2101 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):
2102 if port_no != None:
2103 self.port_no = port_no
2104 else:
2105 self.port_no = 0
2106 if rx_packets != None:
2107 self.rx_packets = rx_packets
2108 else:
2109 self.rx_packets = 0
2110 if tx_packets != None:
2111 self.tx_packets = tx_packets
2112 else:
2113 self.tx_packets = 0
2114 if rx_bytes != None:
2115 self.rx_bytes = rx_bytes
2116 else:
2117 self.rx_bytes = 0
2118 if tx_bytes != None:
2119 self.tx_bytes = tx_bytes
2120 else:
2121 self.tx_bytes = 0
2122 if rx_dropped != None:
2123 self.rx_dropped = rx_dropped
2124 else:
2125 self.rx_dropped = 0
2126 if tx_dropped != None:
2127 self.tx_dropped = tx_dropped
2128 else:
2129 self.tx_dropped = 0
2130 if rx_errors != None:
2131 self.rx_errors = rx_errors
2132 else:
2133 self.rx_errors = 0
2134 if tx_errors != None:
2135 self.tx_errors = tx_errors
2136 else:
2137 self.tx_errors = 0
2138 if rx_frame_err != None:
2139 self.rx_frame_err = rx_frame_err
2140 else:
2141 self.rx_frame_err = 0
2142 if rx_over_err != None:
2143 self.rx_over_err = rx_over_err
2144 else:
2145 self.rx_over_err = 0
2146 if rx_crc_err != None:
2147 self.rx_crc_err = rx_crc_err
2148 else:
2149 self.rx_crc_err = 0
2150 if collisions != None:
2151 self.collisions = collisions
2152 else:
2153 self.collisions = 0
2154 if duration_sec != None:
2155 self.duration_sec = duration_sec
2156 else:
2157 self.duration_sec = 0
2158 if duration_nsec != None:
2159 self.duration_nsec = duration_nsec
2160 else:
2161 self.duration_nsec = 0
2162 return
2163
2164 def pack(self):
2165 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07002166 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002167 packed.append('\x00' * 4)
2168 packed.append(struct.pack("!Q", self.rx_packets))
2169 packed.append(struct.pack("!Q", self.tx_packets))
2170 packed.append(struct.pack("!Q", self.rx_bytes))
2171 packed.append(struct.pack("!Q", self.tx_bytes))
2172 packed.append(struct.pack("!Q", self.rx_dropped))
2173 packed.append(struct.pack("!Q", self.tx_dropped))
2174 packed.append(struct.pack("!Q", self.rx_errors))
2175 packed.append(struct.pack("!Q", self.tx_errors))
2176 packed.append(struct.pack("!Q", self.rx_frame_err))
2177 packed.append(struct.pack("!Q", self.rx_over_err))
2178 packed.append(struct.pack("!Q", self.rx_crc_err))
2179 packed.append(struct.pack("!Q", self.collisions))
2180 packed.append(struct.pack("!L", self.duration_sec))
2181 packed.append(struct.pack("!L", self.duration_nsec))
2182 return ''.join(packed)
2183
2184 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002185 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002186 obj = port_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07002187 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002188 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07002189 obj.rx_packets = reader.read("!Q")[0]
2190 obj.tx_packets = reader.read("!Q")[0]
2191 obj.rx_bytes = reader.read("!Q")[0]
2192 obj.tx_bytes = reader.read("!Q")[0]
2193 obj.rx_dropped = reader.read("!Q")[0]
2194 obj.tx_dropped = reader.read("!Q")[0]
2195 obj.rx_errors = reader.read("!Q")[0]
2196 obj.tx_errors = reader.read("!Q")[0]
2197 obj.rx_frame_err = reader.read("!Q")[0]
2198 obj.rx_over_err = reader.read("!Q")[0]
2199 obj.rx_crc_err = reader.read("!Q")[0]
2200 obj.collisions = reader.read("!Q")[0]
2201 obj.duration_sec = reader.read("!L")[0]
2202 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002203 return obj
2204
2205 def __eq__(self, other):
2206 if type(self) != type(other): return False
2207 if self.port_no != other.port_no: return False
2208 if self.rx_packets != other.rx_packets: return False
2209 if self.tx_packets != other.tx_packets: return False
2210 if self.rx_bytes != other.rx_bytes: return False
2211 if self.tx_bytes != other.tx_bytes: return False
2212 if self.rx_dropped != other.rx_dropped: return False
2213 if self.tx_dropped != other.tx_dropped: return False
2214 if self.rx_errors != other.rx_errors: return False
2215 if self.tx_errors != other.tx_errors: return False
2216 if self.rx_frame_err != other.rx_frame_err: return False
2217 if self.rx_over_err != other.rx_over_err: return False
2218 if self.rx_crc_err != other.rx_crc_err: return False
2219 if self.collisions != other.collisions: return False
2220 if self.duration_sec != other.duration_sec: return False
2221 if self.duration_nsec != other.duration_nsec: return False
2222 return True
2223
Rich Lanec2ee4b82013-04-24 17:12:38 -07002224 def pretty_print(self, q):
2225 q.text("port_stats_entry {")
2226 with q.group():
2227 with q.indent(2):
2228 q.breakable()
2229 q.text("port_no = ");
2230 q.text(util.pretty_port(self.port_no))
2231 q.text(","); q.breakable()
2232 q.text("rx_packets = ");
2233 q.text("%#x" % self.rx_packets)
2234 q.text(","); q.breakable()
2235 q.text("tx_packets = ");
2236 q.text("%#x" % self.tx_packets)
2237 q.text(","); q.breakable()
2238 q.text("rx_bytes = ");
2239 q.text("%#x" % self.rx_bytes)
2240 q.text(","); q.breakable()
2241 q.text("tx_bytes = ");
2242 q.text("%#x" % self.tx_bytes)
2243 q.text(","); q.breakable()
2244 q.text("rx_dropped = ");
2245 q.text("%#x" % self.rx_dropped)
2246 q.text(","); q.breakable()
2247 q.text("tx_dropped = ");
2248 q.text("%#x" % self.tx_dropped)
2249 q.text(","); q.breakable()
2250 q.text("rx_errors = ");
2251 q.text("%#x" % self.rx_errors)
2252 q.text(","); q.breakable()
2253 q.text("tx_errors = ");
2254 q.text("%#x" % self.tx_errors)
2255 q.text(","); q.breakable()
2256 q.text("rx_frame_err = ");
2257 q.text("%#x" % self.rx_frame_err)
2258 q.text(","); q.breakable()
2259 q.text("rx_over_err = ");
2260 q.text("%#x" % self.rx_over_err)
2261 q.text(","); q.breakable()
2262 q.text("rx_crc_err = ");
2263 q.text("%#x" % self.rx_crc_err)
2264 q.text(","); q.breakable()
2265 q.text("collisions = ");
2266 q.text("%#x" % self.collisions)
2267 q.text(","); q.breakable()
2268 q.text("duration_sec = ");
2269 q.text("%#x" % self.duration_sec)
2270 q.text(","); q.breakable()
2271 q.text("duration_nsec = ");
2272 q.text("%#x" % self.duration_nsec)
2273 q.breakable()
2274 q.text('}')
2275
Rich Lane7dcdf022013-12-11 14:45:27 -08002276
2277class queue_prop(loxi.OFObject):
2278 subtypes = {}
2279
Rich Lane95f7fc92014-01-27 17:08:16 -08002280
2281 def __init__(self, type=None):
2282 if type != None:
2283 self.type = type
2284 else:
2285 self.type = 0
2286 return
2287
2288 def pack(self):
2289 packed = []
2290 packed.append(struct.pack("!H", self.type))
2291 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2292 packed.append('\x00' * 4)
2293 length = sum([len(x) for x in packed])
2294 packed[1] = struct.pack("!H", length)
2295 return ''.join(packed)
2296
Rich Lane7dcdf022013-12-11 14:45:27 -08002297 @staticmethod
2298 def unpack(reader):
2299 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -08002300 subclass = queue_prop.subtypes.get(subtype)
2301 if subclass:
2302 return subclass.unpack(reader)
2303
2304 obj = queue_prop()
2305 obj.type = reader.read("!H")[0]
2306 _len = reader.read("!H")[0]
2307 orig_reader = reader
2308 reader = orig_reader.slice(_len - (2 + 2))
2309 reader.skip(4)
2310 return obj
2311
2312 def __eq__(self, other):
2313 if type(self) != type(other): return False
2314 if self.type != other.type: return False
2315 return True
2316
2317 def pretty_print(self, q):
2318 q.text("queue_prop {")
2319 with q.group():
2320 with q.indent(2):
2321 q.breakable()
2322 q.breakable()
2323 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002324
2325
2326class queue_prop_experimenter(queue_prop):
2327 subtypes = {}
2328
Rich Lane95f7fc92014-01-27 17:08:16 -08002329 type = 65535
2330
2331 def __init__(self, experimenter=None, data=None):
2332 if experimenter != None:
2333 self.experimenter = experimenter
2334 else:
2335 self.experimenter = 0
2336 if data != None:
2337 self.data = data
2338 else:
2339 self.data = ''
2340 return
2341
2342 def pack(self):
2343 packed = []
2344 packed.append(struct.pack("!H", self.type))
2345 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2346 packed.append('\x00' * 4)
2347 packed.append(struct.pack("!L", self.experimenter))
2348 packed.append('\x00' * 4)
2349 packed.append(self.data)
2350 length = sum([len(x) for x in packed])
2351 packed[1] = struct.pack("!H", length)
2352 return ''.join(packed)
2353
Rich Lane7dcdf022013-12-11 14:45:27 -08002354 @staticmethod
2355 def unpack(reader):
2356 subtype, = reader.peek('!L', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -08002357 subclass = queue_prop_experimenter.subtypes.get(subtype)
2358 if subclass:
2359 return subclass.unpack(reader)
2360
2361 obj = queue_prop_experimenter()
2362 _type = reader.read("!H")[0]
2363 assert(_type == 65535)
2364 _len = reader.read("!H")[0]
2365 orig_reader = reader
2366 reader = orig_reader.slice(_len - (2 + 2))
2367 reader.skip(4)
2368 obj.experimenter = reader.read("!L")[0]
2369 reader.skip(4)
2370 obj.data = str(reader.read_all())
2371 return obj
2372
2373 def __eq__(self, other):
2374 if type(self) != type(other): return False
2375 if self.experimenter != other.experimenter: return False
2376 if self.data != other.data: return False
2377 return True
2378
2379 def pretty_print(self, q):
2380 q.text("queue_prop_experimenter {")
2381 with q.group():
2382 with q.indent(2):
2383 q.breakable()
2384 q.text("data = ");
2385 q.pp(self.data)
2386 q.breakable()
2387 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002388
2389queue_prop.subtypes[65535] = queue_prop_experimenter
2390
2391class queue_prop_max_rate(queue_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002392 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07002393
2394 def __init__(self, rate=None):
2395 if rate != None:
2396 self.rate = rate
2397 else:
2398 self.rate = 0
2399 return
2400
2401 def pack(self):
2402 packed = []
2403 packed.append(struct.pack("!H", self.type))
2404 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2405 packed.append('\x00' * 4)
2406 packed.append(struct.pack("!H", self.rate))
2407 packed.append('\x00' * 6)
2408 length = sum([len(x) for x in packed])
2409 packed[1] = struct.pack("!H", length)
2410 return ''.join(packed)
2411
2412 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002413 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002414 obj = queue_prop_max_rate()
Dan Talaycof6202252013-07-02 01:00:29 -07002415 _type = reader.read("!H")[0]
2416 assert(_type == 2)
2417 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002418 orig_reader = reader
2419 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002420 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07002421 obj.rate = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002422 reader.skip(6)
2423 return obj
2424
2425 def __eq__(self, other):
2426 if type(self) != type(other): return False
2427 if self.rate != other.rate: return False
2428 return True
2429
Rich Lanec2ee4b82013-04-24 17:12:38 -07002430 def pretty_print(self, q):
2431 q.text("queue_prop_max_rate {")
2432 with q.group():
2433 with q.indent(2):
2434 q.breakable()
2435 q.text("rate = ");
2436 q.text("%#x" % self.rate)
2437 q.breakable()
2438 q.text('}')
2439
Rich Lane7dcdf022013-12-11 14:45:27 -08002440queue_prop.subtypes[2] = queue_prop_max_rate
2441
2442class queue_prop_min_rate(queue_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002443 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07002444
2445 def __init__(self, rate=None):
2446 if rate != None:
2447 self.rate = rate
2448 else:
2449 self.rate = 0
2450 return
2451
2452 def pack(self):
2453 packed = []
2454 packed.append(struct.pack("!H", self.type))
2455 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2456 packed.append('\x00' * 4)
2457 packed.append(struct.pack("!H", self.rate))
2458 packed.append('\x00' * 6)
2459 length = sum([len(x) for x in packed])
2460 packed[1] = struct.pack("!H", length)
2461 return ''.join(packed)
2462
2463 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002464 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002465 obj = queue_prop_min_rate()
Dan Talaycof6202252013-07-02 01:00:29 -07002466 _type = reader.read("!H")[0]
2467 assert(_type == 1)
2468 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002469 orig_reader = reader
2470 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002471 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07002472 obj.rate = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002473 reader.skip(6)
2474 return obj
2475
2476 def __eq__(self, other):
2477 if type(self) != type(other): return False
2478 if self.rate != other.rate: return False
2479 return True
2480
Rich Lanec2ee4b82013-04-24 17:12:38 -07002481 def pretty_print(self, q):
2482 q.text("queue_prop_min_rate {")
2483 with q.group():
2484 with q.indent(2):
2485 q.breakable()
2486 q.text("rate = ");
2487 q.text("%#x" % self.rate)
2488 q.breakable()
2489 q.text('}')
2490
Rich Lane7dcdf022013-12-11 14:45:27 -08002491queue_prop.subtypes[1] = queue_prop_min_rate
2492
2493class queue_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002494
2495 def __init__(self, port_no=None, queue_id=None, tx_bytes=None, tx_packets=None, tx_errors=None, duration_sec=None, duration_nsec=None):
2496 if port_no != None:
2497 self.port_no = port_no
2498 else:
2499 self.port_no = 0
2500 if queue_id != None:
2501 self.queue_id = queue_id
2502 else:
2503 self.queue_id = 0
2504 if tx_bytes != None:
2505 self.tx_bytes = tx_bytes
2506 else:
2507 self.tx_bytes = 0
2508 if tx_packets != None:
2509 self.tx_packets = tx_packets
2510 else:
2511 self.tx_packets = 0
2512 if tx_errors != None:
2513 self.tx_errors = tx_errors
2514 else:
2515 self.tx_errors = 0
2516 if duration_sec != None:
2517 self.duration_sec = duration_sec
2518 else:
2519 self.duration_sec = 0
2520 if duration_nsec != None:
2521 self.duration_nsec = duration_nsec
2522 else:
2523 self.duration_nsec = 0
2524 return
2525
2526 def pack(self):
2527 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07002528 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002529 packed.append(struct.pack("!L", self.queue_id))
2530 packed.append(struct.pack("!Q", self.tx_bytes))
2531 packed.append(struct.pack("!Q", self.tx_packets))
2532 packed.append(struct.pack("!Q", self.tx_errors))
2533 packed.append(struct.pack("!L", self.duration_sec))
2534 packed.append(struct.pack("!L", self.duration_nsec))
2535 return ''.join(packed)
2536
2537 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002538 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002539 obj = queue_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07002540 obj.port_no = util.unpack_port_no(reader)
2541 obj.queue_id = reader.read("!L")[0]
2542 obj.tx_bytes = reader.read("!Q")[0]
2543 obj.tx_packets = reader.read("!Q")[0]
2544 obj.tx_errors = reader.read("!Q")[0]
2545 obj.duration_sec = reader.read("!L")[0]
2546 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002547 return obj
2548
2549 def __eq__(self, other):
2550 if type(self) != type(other): return False
2551 if self.port_no != other.port_no: return False
2552 if self.queue_id != other.queue_id: return False
2553 if self.tx_bytes != other.tx_bytes: return False
2554 if self.tx_packets != other.tx_packets: return False
2555 if self.tx_errors != other.tx_errors: return False
2556 if self.duration_sec != other.duration_sec: return False
2557 if self.duration_nsec != other.duration_nsec: return False
2558 return True
2559
Rich Lanec2ee4b82013-04-24 17:12:38 -07002560 def pretty_print(self, q):
2561 q.text("queue_stats_entry {")
2562 with q.group():
2563 with q.indent(2):
2564 q.breakable()
2565 q.text("port_no = ");
2566 q.text(util.pretty_port(self.port_no))
2567 q.text(","); q.breakable()
2568 q.text("queue_id = ");
2569 q.text("%#x" % self.queue_id)
2570 q.text(","); q.breakable()
2571 q.text("tx_bytes = ");
2572 q.text("%#x" % self.tx_bytes)
2573 q.text(","); q.breakable()
2574 q.text("tx_packets = ");
2575 q.text("%#x" % self.tx_packets)
2576 q.text(","); q.breakable()
2577 q.text("tx_errors = ");
2578 q.text("%#x" % self.tx_errors)
2579 q.text(","); q.breakable()
2580 q.text("duration_sec = ");
2581 q.text("%#x" % self.duration_sec)
2582 q.text(","); q.breakable()
2583 q.text("duration_nsec = ");
2584 q.text("%#x" % self.duration_nsec)
2585 q.breakable()
2586 q.text('}')
2587
Rich Lane7dcdf022013-12-11 14:45:27 -08002588
2589class table_feature_prop(loxi.OFObject):
2590 subtypes = {}
2591
Rich Lane95f7fc92014-01-27 17:08:16 -08002592
2593 def __init__(self, type=None):
2594 if type != None:
2595 self.type = type
2596 else:
2597 self.type = 0
2598 return
2599
2600 def pack(self):
2601 packed = []
2602 packed.append(struct.pack("!H", self.type))
2603 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
2604 length = sum([len(x) for x in packed])
2605 packed[1] = struct.pack("!H", length)
2606 return ''.join(packed)
2607
Rich Lane7dcdf022013-12-11 14:45:27 -08002608 @staticmethod
2609 def unpack(reader):
2610 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -08002611 subclass = table_feature_prop.subtypes.get(subtype)
2612 if subclass:
2613 return subclass.unpack(reader)
2614
2615 obj = table_feature_prop()
2616 obj.type = reader.read("!H")[0]
2617 _length = reader.read("!H")[0]
2618 orig_reader = reader
2619 reader = orig_reader.slice(_length - (2 + 2))
2620 return obj
2621
2622 def __eq__(self, other):
2623 if type(self) != type(other): return False
2624 if self.type != other.type: return False
2625 return True
2626
2627 def pretty_print(self, q):
2628 q.text("table_feature_prop {")
2629 with q.group():
2630 with q.indent(2):
2631 q.breakable()
2632 q.breakable()
2633 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002634
2635
2636class table_feature_prop_apply_actions(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002637 type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07002638
Dan Talaycof6202252013-07-02 01:00:29 -07002639 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002640 if action_ids != None:
2641 self.action_ids = action_ids
2642 else:
2643 self.action_ids = []
2644 return
2645
2646 def pack(self):
2647 packed = []
2648 packed.append(struct.pack("!H", self.type))
2649 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002650 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002651 length = sum([len(x) for x in packed])
2652 packed[1] = struct.pack("!H", length)
2653 return ''.join(packed)
2654
2655 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002656 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002657 obj = table_feature_prop_apply_actions()
Dan Talaycof6202252013-07-02 01:00:29 -07002658 _type = reader.read("!H")[0]
2659 assert(_type == 6)
2660 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002661 orig_reader = reader
2662 reader = orig_reader.slice(_length - (2 + 2))
2663 obj.action_ids = loxi.generic_util.unpack_list(reader, action_id.action_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002664 return obj
2665
2666 def __eq__(self, other):
2667 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002668 if self.action_ids != other.action_ids: return False
2669 return True
2670
Rich Lanec2ee4b82013-04-24 17:12:38 -07002671 def pretty_print(self, q):
2672 q.text("table_feature_prop_apply_actions {")
2673 with q.group():
2674 with q.indent(2):
2675 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002676 q.text("action_ids = ");
2677 q.pp(self.action_ids)
2678 q.breakable()
2679 q.text('}')
2680
Rich Lane7dcdf022013-12-11 14:45:27 -08002681table_feature_prop.subtypes[6] = table_feature_prop_apply_actions
2682
2683class table_feature_prop_apply_actions_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002684 type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07002685
Dan Talaycof6202252013-07-02 01:00:29 -07002686 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002687 if action_ids != None:
2688 self.action_ids = action_ids
2689 else:
2690 self.action_ids = []
2691 return
2692
2693 def pack(self):
2694 packed = []
2695 packed.append(struct.pack("!H", self.type))
2696 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002697 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002698 length = sum([len(x) for x in packed])
2699 packed[1] = struct.pack("!H", length)
2700 return ''.join(packed)
2701
2702 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002703 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002704 obj = table_feature_prop_apply_actions_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07002705 _type = reader.read("!H")[0]
2706 assert(_type == 7)
2707 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002708 orig_reader = reader
2709 reader = orig_reader.slice(_length - (2 + 2))
2710 obj.action_ids = loxi.generic_util.unpack_list(reader, action_id.action_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002711 return obj
2712
2713 def __eq__(self, other):
2714 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002715 if self.action_ids != other.action_ids: return False
2716 return True
2717
Rich Lanec2ee4b82013-04-24 17:12:38 -07002718 def pretty_print(self, q):
2719 q.text("table_feature_prop_apply_actions_miss {")
2720 with q.group():
2721 with q.indent(2):
2722 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002723 q.text("action_ids = ");
2724 q.pp(self.action_ids)
2725 q.breakable()
2726 q.text('}')
2727
Rich Lane7dcdf022013-12-11 14:45:27 -08002728table_feature_prop.subtypes[7] = table_feature_prop_apply_actions_miss
2729
2730class table_feature_prop_apply_setfield(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002731 type = 14
Rich Lanec2ee4b82013-04-24 17:12:38 -07002732
Dan Talaycof6202252013-07-02 01:00:29 -07002733 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002734 if oxm_ids != None:
2735 self.oxm_ids = oxm_ids
2736 else:
2737 self.oxm_ids = []
2738 return
2739
2740 def pack(self):
2741 packed = []
2742 packed.append(struct.pack("!H", self.type))
2743 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002744 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002745 length = sum([len(x) for x in packed])
2746 packed[1] = struct.pack("!H", length)
2747 return ''.join(packed)
2748
2749 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002750 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002751 obj = table_feature_prop_apply_setfield()
Dan Talaycof6202252013-07-02 01:00:29 -07002752 _type = reader.read("!H")[0]
2753 assert(_type == 14)
2754 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002755 orig_reader = reader
2756 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002757 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
2758 return obj
2759
2760 def __eq__(self, other):
2761 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002762 if self.oxm_ids != other.oxm_ids: return False
2763 return True
2764
Rich Lanec2ee4b82013-04-24 17:12:38 -07002765 def pretty_print(self, q):
2766 q.text("table_feature_prop_apply_setfield {")
2767 with q.group():
2768 with q.indent(2):
2769 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002770 q.text("oxm_ids = ");
2771 q.pp(self.oxm_ids)
2772 q.breakable()
2773 q.text('}')
2774
Rich Lane7dcdf022013-12-11 14:45:27 -08002775table_feature_prop.subtypes[14] = table_feature_prop_apply_setfield
2776
2777class table_feature_prop_apply_setfield_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002778 type = 15
Rich Lanec2ee4b82013-04-24 17:12:38 -07002779
Dan Talaycof6202252013-07-02 01:00:29 -07002780 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002781 if oxm_ids != None:
2782 self.oxm_ids = oxm_ids
2783 else:
2784 self.oxm_ids = []
2785 return
2786
2787 def pack(self):
2788 packed = []
2789 packed.append(struct.pack("!H", self.type))
2790 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002791 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002792 length = sum([len(x) for x in packed])
2793 packed[1] = struct.pack("!H", length)
2794 return ''.join(packed)
2795
2796 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002797 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002798 obj = table_feature_prop_apply_setfield_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07002799 _type = reader.read("!H")[0]
2800 assert(_type == 15)
2801 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002802 orig_reader = reader
2803 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002804 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
2805 return obj
2806
2807 def __eq__(self, other):
2808 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002809 if self.oxm_ids != other.oxm_ids: return False
2810 return True
2811
Rich Lanec2ee4b82013-04-24 17:12:38 -07002812 def pretty_print(self, q):
2813 q.text("table_feature_prop_apply_setfield_miss {")
2814 with q.group():
2815 with q.indent(2):
2816 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002817 q.text("oxm_ids = ");
2818 q.pp(self.oxm_ids)
2819 q.breakable()
2820 q.text('}')
2821
Rich Lane7dcdf022013-12-11 14:45:27 -08002822table_feature_prop.subtypes[15] = table_feature_prop_apply_setfield_miss
2823
2824class table_feature_prop_experimenter(table_feature_prop):
Rich Lane9ec3fca2014-02-26 16:22:56 -08002825 type = 65534
Rich Lanec2ee4b82013-04-24 17:12:38 -07002826
Dan Talaycof6202252013-07-02 01:00:29 -07002827 def __init__(self, experimenter=None, subtype=None, experimenter_data=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002828 if experimenter != None:
2829 self.experimenter = experimenter
2830 else:
2831 self.experimenter = 0
2832 if subtype != None:
2833 self.subtype = subtype
2834 else:
2835 self.subtype = 0
2836 if experimenter_data != None:
2837 self.experimenter_data = experimenter_data
2838 else:
Dan Talaycof6202252013-07-02 01:00:29 -07002839 self.experimenter_data = ''
Rich Lanec2ee4b82013-04-24 17:12:38 -07002840 return
2841
2842 def pack(self):
2843 packed = []
2844 packed.append(struct.pack("!H", self.type))
2845 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
2846 packed.append(struct.pack("!L", self.experimenter))
2847 packed.append(struct.pack("!L", self.subtype))
2848 packed.append(self.experimenter_data)
2849 length = sum([len(x) for x in packed])
2850 packed[1] = struct.pack("!H", length)
2851 return ''.join(packed)
2852
2853 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002854 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002855 obj = table_feature_prop_experimenter()
Dan Talaycof6202252013-07-02 01:00:29 -07002856 _type = reader.read("!H")[0]
Rich Lane9ec3fca2014-02-26 16:22:56 -08002857 assert(_type == 65534)
Dan Talaycof6202252013-07-02 01:00:29 -07002858 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002859 orig_reader = reader
2860 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002861 obj.experimenter = reader.read("!L")[0]
2862 obj.subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002863 obj.experimenter_data = str(reader.read_all())
2864 return obj
2865
2866 def __eq__(self, other):
2867 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002868 if self.experimenter != other.experimenter: return False
2869 if self.subtype != other.subtype: return False
2870 if self.experimenter_data != other.experimenter_data: return False
2871 return True
2872
Rich Lanec2ee4b82013-04-24 17:12:38 -07002873 def pretty_print(self, q):
2874 q.text("table_feature_prop_experimenter {")
2875 with q.group():
2876 with q.indent(2):
2877 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002878 q.text("experimenter = ");
2879 q.text("%#x" % self.experimenter)
2880 q.text(","); q.breakable()
2881 q.text("subtype = ");
2882 q.text("%#x" % self.subtype)
2883 q.text(","); q.breakable()
2884 q.text("experimenter_data = ");
2885 q.pp(self.experimenter_data)
2886 q.breakable()
2887 q.text('}')
2888
Rich Lane9ec3fca2014-02-26 16:22:56 -08002889table_feature_prop.subtypes[65534] = table_feature_prop_experimenter
2890
2891class table_feature_prop_experimenter_miss(table_feature_prop):
2892 type = 65535
2893
2894 def __init__(self, experimenter=None, subtype=None, experimenter_data=None):
2895 if experimenter != None:
2896 self.experimenter = experimenter
2897 else:
2898 self.experimenter = 0
2899 if subtype != None:
2900 self.subtype = subtype
2901 else:
2902 self.subtype = 0
2903 if experimenter_data != None:
2904 self.experimenter_data = experimenter_data
2905 else:
2906 self.experimenter_data = ''
2907 return
2908
2909 def pack(self):
2910 packed = []
2911 packed.append(struct.pack("!H", self.type))
2912 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
2913 packed.append(struct.pack("!L", self.experimenter))
2914 packed.append(struct.pack("!L", self.subtype))
2915 packed.append(self.experimenter_data)
2916 length = sum([len(x) for x in packed])
2917 packed[1] = struct.pack("!H", length)
2918 return ''.join(packed)
2919
2920 @staticmethod
2921 def unpack(reader):
2922 obj = table_feature_prop_experimenter_miss()
2923 _type = reader.read("!H")[0]
2924 assert(_type == 65535)
2925 _length = reader.read("!H")[0]
2926 orig_reader = reader
2927 reader = orig_reader.slice(_length - (2 + 2))
2928 obj.experimenter = reader.read("!L")[0]
2929 obj.subtype = reader.read("!L")[0]
2930 obj.experimenter_data = str(reader.read_all())
2931 return obj
2932
2933 def __eq__(self, other):
2934 if type(self) != type(other): return False
2935 if self.experimenter != other.experimenter: return False
2936 if self.subtype != other.subtype: return False
2937 if self.experimenter_data != other.experimenter_data: return False
2938 return True
2939
2940 def pretty_print(self, q):
2941 q.text("table_feature_prop_experimenter_miss {")
2942 with q.group():
2943 with q.indent(2):
2944 q.breakable()
2945 q.text("experimenter = ");
2946 q.text("%#x" % self.experimenter)
2947 q.text(","); q.breakable()
2948 q.text("subtype = ");
2949 q.text("%#x" % self.subtype)
2950 q.text(","); q.breakable()
2951 q.text("experimenter_data = ");
2952 q.pp(self.experimenter_data)
2953 q.breakable()
2954 q.text('}')
2955
2956table_feature_prop.subtypes[65535] = table_feature_prop_experimenter_miss
Rich Lane7dcdf022013-12-11 14:45:27 -08002957
2958class table_feature_prop_instructions(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002959 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07002960
Dan Talaycof6202252013-07-02 01:00:29 -07002961 def __init__(self, instruction_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002962 if instruction_ids != None:
2963 self.instruction_ids = instruction_ids
2964 else:
2965 self.instruction_ids = []
2966 return
2967
2968 def pack(self):
2969 packed = []
2970 packed.append(struct.pack("!H", self.type))
2971 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002972 packed.append(loxi.generic_util.pack_list(self.instruction_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002973 length = sum([len(x) for x in packed])
2974 packed[1] = struct.pack("!H", length)
2975 return ''.join(packed)
2976
2977 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002978 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002979 obj = table_feature_prop_instructions()
Dan Talaycof6202252013-07-02 01:00:29 -07002980 _type = reader.read("!H")[0]
2981 assert(_type == 0)
2982 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002983 orig_reader = reader
2984 reader = orig_reader.slice(_length - (2 + 2))
2985 obj.instruction_ids = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002986 return obj
2987
2988 def __eq__(self, other):
2989 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002990 if self.instruction_ids != other.instruction_ids: return False
2991 return True
2992
Rich Lanec2ee4b82013-04-24 17:12:38 -07002993 def pretty_print(self, q):
2994 q.text("table_feature_prop_instructions {")
2995 with q.group():
2996 with q.indent(2):
2997 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002998 q.text("instruction_ids = ");
2999 q.pp(self.instruction_ids)
3000 q.breakable()
3001 q.text('}')
3002
Rich Lane7dcdf022013-12-11 14:45:27 -08003003table_feature_prop.subtypes[0] = table_feature_prop_instructions
3004
3005class table_feature_prop_instructions_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003006 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07003007
Dan Talaycof6202252013-07-02 01:00:29 -07003008 def __init__(self, instruction_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003009 if instruction_ids != None:
3010 self.instruction_ids = instruction_ids
3011 else:
3012 self.instruction_ids = []
3013 return
3014
3015 def pack(self):
3016 packed = []
3017 packed.append(struct.pack("!H", self.type))
3018 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003019 packed.append(loxi.generic_util.pack_list(self.instruction_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003020 length = sum([len(x) for x in packed])
3021 packed[1] = struct.pack("!H", length)
3022 return ''.join(packed)
3023
3024 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003025 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003026 obj = table_feature_prop_instructions_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07003027 _type = reader.read("!H")[0]
3028 assert(_type == 1)
3029 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003030 orig_reader = reader
3031 reader = orig_reader.slice(_length - (2 + 2))
3032 obj.instruction_ids = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003033 return obj
3034
3035 def __eq__(self, other):
3036 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003037 if self.instruction_ids != other.instruction_ids: return False
3038 return True
3039
Rich Lanec2ee4b82013-04-24 17:12:38 -07003040 def pretty_print(self, q):
3041 q.text("table_feature_prop_instructions_miss {")
3042 with q.group():
3043 with q.indent(2):
3044 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003045 q.text("instruction_ids = ");
3046 q.pp(self.instruction_ids)
3047 q.breakable()
3048 q.text('}')
3049
Rich Lane7dcdf022013-12-11 14:45:27 -08003050table_feature_prop.subtypes[1] = table_feature_prop_instructions_miss
3051
3052class table_feature_prop_match(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003053 type = 8
Rich Lanec2ee4b82013-04-24 17:12:38 -07003054
Dan Talaycof6202252013-07-02 01:00:29 -07003055 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003056 if oxm_ids != None:
3057 self.oxm_ids = oxm_ids
3058 else:
3059 self.oxm_ids = []
3060 return
3061
3062 def pack(self):
3063 packed = []
3064 packed.append(struct.pack("!H", self.type))
3065 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003066 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003067 length = sum([len(x) for x in packed])
3068 packed[1] = struct.pack("!H", length)
3069 return ''.join(packed)
3070
3071 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003072 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003073 obj = table_feature_prop_match()
Dan Talaycof6202252013-07-02 01:00:29 -07003074 _type = reader.read("!H")[0]
3075 assert(_type == 8)
3076 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003077 orig_reader = reader
3078 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003079 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
3080 return obj
3081
3082 def __eq__(self, other):
3083 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003084 if self.oxm_ids != other.oxm_ids: return False
3085 return True
3086
Rich Lanec2ee4b82013-04-24 17:12:38 -07003087 def pretty_print(self, q):
3088 q.text("table_feature_prop_match {")
3089 with q.group():
3090 with q.indent(2):
3091 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003092 q.text("oxm_ids = ");
3093 q.pp(self.oxm_ids)
3094 q.breakable()
3095 q.text('}')
3096
Rich Lane7dcdf022013-12-11 14:45:27 -08003097table_feature_prop.subtypes[8] = table_feature_prop_match
3098
3099class table_feature_prop_next_tables(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003100 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07003101
Dan Talaycof6202252013-07-02 01:00:29 -07003102 def __init__(self, next_table_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003103 if next_table_ids != None:
3104 self.next_table_ids = next_table_ids
3105 else:
3106 self.next_table_ids = []
3107 return
3108
3109 def pack(self):
3110 packed = []
3111 packed.append(struct.pack("!H", self.type))
3112 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003113 packed.append(loxi.generic_util.pack_list(self.next_table_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003114 length = sum([len(x) for x in packed])
3115 packed[1] = struct.pack("!H", length)
3116 return ''.join(packed)
3117
3118 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003119 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003120 obj = table_feature_prop_next_tables()
Dan Talaycof6202252013-07-02 01:00:29 -07003121 _type = reader.read("!H")[0]
3122 assert(_type == 2)
3123 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003124 orig_reader = reader
3125 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003126 obj.next_table_ids = loxi.generic_util.unpack_list(reader, common.uint8.unpack)
3127 return obj
3128
3129 def __eq__(self, other):
3130 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003131 if self.next_table_ids != other.next_table_ids: return False
3132 return True
3133
Rich Lanec2ee4b82013-04-24 17:12:38 -07003134 def pretty_print(self, q):
3135 q.text("table_feature_prop_next_tables {")
3136 with q.group():
3137 with q.indent(2):
3138 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003139 q.text("next_table_ids = ");
3140 q.pp(self.next_table_ids)
3141 q.breakable()
3142 q.text('}')
3143
Rich Lane7dcdf022013-12-11 14:45:27 -08003144table_feature_prop.subtypes[2] = table_feature_prop_next_tables
3145
3146class table_feature_prop_next_tables_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003147 type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07003148
Dan Talaycof6202252013-07-02 01:00:29 -07003149 def __init__(self, next_table_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003150 if next_table_ids != None:
3151 self.next_table_ids = next_table_ids
3152 else:
3153 self.next_table_ids = []
3154 return
3155
3156 def pack(self):
3157 packed = []
3158 packed.append(struct.pack("!H", self.type))
3159 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003160 packed.append(loxi.generic_util.pack_list(self.next_table_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003161 length = sum([len(x) for x in packed])
3162 packed[1] = struct.pack("!H", length)
3163 return ''.join(packed)
3164
3165 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003166 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003167 obj = table_feature_prop_next_tables_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07003168 _type = reader.read("!H")[0]
3169 assert(_type == 3)
3170 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003171 orig_reader = reader
3172 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003173 obj.next_table_ids = loxi.generic_util.unpack_list(reader, common.uint8.unpack)
3174 return obj
3175
3176 def __eq__(self, other):
3177 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003178 if self.next_table_ids != other.next_table_ids: return False
3179 return True
3180
Rich Lanec2ee4b82013-04-24 17:12:38 -07003181 def pretty_print(self, q):
3182 q.text("table_feature_prop_next_tables_miss {")
3183 with q.group():
3184 with q.indent(2):
3185 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003186 q.text("next_table_ids = ");
3187 q.pp(self.next_table_ids)
3188 q.breakable()
3189 q.text('}')
3190
Rich Lane7dcdf022013-12-11 14:45:27 -08003191table_feature_prop.subtypes[3] = table_feature_prop_next_tables_miss
3192
3193class table_feature_prop_wildcards(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003194 type = 10
Rich Lanec2ee4b82013-04-24 17:12:38 -07003195
Dan Talaycof6202252013-07-02 01:00:29 -07003196 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003197 if oxm_ids != None:
3198 self.oxm_ids = oxm_ids
3199 else:
3200 self.oxm_ids = []
3201 return
3202
3203 def pack(self):
3204 packed = []
3205 packed.append(struct.pack("!H", self.type))
3206 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003207 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003208 length = sum([len(x) for x in packed])
3209 packed[1] = struct.pack("!H", length)
3210 return ''.join(packed)
3211
3212 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003213 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003214 obj = table_feature_prop_wildcards()
Dan Talaycof6202252013-07-02 01:00:29 -07003215 _type = reader.read("!H")[0]
3216 assert(_type == 10)
3217 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003218 orig_reader = reader
3219 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003220 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
3221 return obj
3222
3223 def __eq__(self, other):
3224 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003225 if self.oxm_ids != other.oxm_ids: return False
3226 return True
3227
Rich Lanec2ee4b82013-04-24 17:12:38 -07003228 def pretty_print(self, q):
3229 q.text("table_feature_prop_wildcards {")
3230 with q.group():
3231 with q.indent(2):
3232 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003233 q.text("oxm_ids = ");
3234 q.pp(self.oxm_ids)
3235 q.breakable()
3236 q.text('}')
3237
Rich Lane7dcdf022013-12-11 14:45:27 -08003238table_feature_prop.subtypes[10] = table_feature_prop_wildcards
3239
3240class table_feature_prop_write_actions(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003241 type = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07003242
Dan Talaycof6202252013-07-02 01:00:29 -07003243 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003244 if action_ids != None:
3245 self.action_ids = action_ids
3246 else:
3247 self.action_ids = []
3248 return
3249
3250 def pack(self):
3251 packed = []
3252 packed.append(struct.pack("!H", self.type))
3253 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003254 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003255 length = sum([len(x) for x in packed])
3256 packed[1] = struct.pack("!H", length)
3257 return ''.join(packed)
3258
3259 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003260 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003261 obj = table_feature_prop_write_actions()
Dan Talaycof6202252013-07-02 01:00:29 -07003262 _type = reader.read("!H")[0]
3263 assert(_type == 4)
3264 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003265 orig_reader = reader
3266 reader = orig_reader.slice(_length - (2 + 2))
3267 obj.action_ids = loxi.generic_util.unpack_list(reader, action_id.action_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003268 return obj
3269
3270 def __eq__(self, other):
3271 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003272 if self.action_ids != other.action_ids: return False
3273 return True
3274
Rich Lanec2ee4b82013-04-24 17:12:38 -07003275 def pretty_print(self, q):
3276 q.text("table_feature_prop_write_actions {")
3277 with q.group():
3278 with q.indent(2):
3279 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003280 q.text("action_ids = ");
3281 q.pp(self.action_ids)
3282 q.breakable()
3283 q.text('}')
3284
Rich Lane7dcdf022013-12-11 14:45:27 -08003285table_feature_prop.subtypes[4] = table_feature_prop_write_actions
3286
3287class table_feature_prop_write_actions_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003288 type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07003289
Dan Talaycof6202252013-07-02 01:00:29 -07003290 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003291 if action_ids != None:
3292 self.action_ids = action_ids
3293 else:
3294 self.action_ids = []
3295 return
3296
3297 def pack(self):
3298 packed = []
3299 packed.append(struct.pack("!H", self.type))
3300 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003301 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003302 length = sum([len(x) for x in packed])
3303 packed[1] = struct.pack("!H", length)
3304 return ''.join(packed)
3305
3306 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003307 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003308 obj = table_feature_prop_write_actions_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07003309 _type = reader.read("!H")[0]
3310 assert(_type == 5)
3311 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003312 orig_reader = reader
3313 reader = orig_reader.slice(_length - (2 + 2))
3314 obj.action_ids = loxi.generic_util.unpack_list(reader, action_id.action_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003315 return obj
3316
3317 def __eq__(self, other):
3318 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003319 if self.action_ids != other.action_ids: return False
3320 return True
3321
Rich Lanec2ee4b82013-04-24 17:12:38 -07003322 def pretty_print(self, q):
3323 q.text("table_feature_prop_write_actions_miss {")
3324 with q.group():
3325 with q.indent(2):
3326 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003327 q.text("action_ids = ");
3328 q.pp(self.action_ids)
3329 q.breakable()
3330 q.text('}')
3331
Rich Lane7dcdf022013-12-11 14:45:27 -08003332table_feature_prop.subtypes[5] = table_feature_prop_write_actions_miss
3333
3334class table_feature_prop_write_setfield(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003335 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -07003336
Dan Talaycof6202252013-07-02 01:00:29 -07003337 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003338 if oxm_ids != None:
3339 self.oxm_ids = oxm_ids
3340 else:
3341 self.oxm_ids = []
3342 return
3343
3344 def pack(self):
3345 packed = []
3346 packed.append(struct.pack("!H", self.type))
3347 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003348 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003349 length = sum([len(x) for x in packed])
3350 packed[1] = struct.pack("!H", length)
3351 return ''.join(packed)
3352
3353 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003354 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003355 obj = table_feature_prop_write_setfield()
Dan Talaycof6202252013-07-02 01:00:29 -07003356 _type = reader.read("!H")[0]
3357 assert(_type == 12)
3358 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003359 orig_reader = reader
3360 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003361 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
3362 return obj
3363
3364 def __eq__(self, other):
3365 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003366 if self.oxm_ids != other.oxm_ids: return False
3367 return True
3368
Rich Lanec2ee4b82013-04-24 17:12:38 -07003369 def pretty_print(self, q):
3370 q.text("table_feature_prop_write_setfield {")
3371 with q.group():
3372 with q.indent(2):
3373 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003374 q.text("oxm_ids = ");
3375 q.pp(self.oxm_ids)
3376 q.breakable()
3377 q.text('}')
3378
Rich Lane7dcdf022013-12-11 14:45:27 -08003379table_feature_prop.subtypes[12] = table_feature_prop_write_setfield
3380
3381class table_feature_prop_write_setfield_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003382 type = 13
Rich Lanec2ee4b82013-04-24 17:12:38 -07003383
Dan Talaycof6202252013-07-02 01:00:29 -07003384 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003385 if oxm_ids != None:
3386 self.oxm_ids = oxm_ids
3387 else:
3388 self.oxm_ids = []
3389 return
3390
3391 def pack(self):
3392 packed = []
3393 packed.append(struct.pack("!H", self.type))
3394 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003395 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003396 length = sum([len(x) for x in packed])
3397 packed[1] = struct.pack("!H", length)
3398 return ''.join(packed)
3399
3400 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003401 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003402 obj = table_feature_prop_write_setfield_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07003403 _type = reader.read("!H")[0]
3404 assert(_type == 13)
3405 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003406 orig_reader = reader
3407 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003408 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
3409 return obj
3410
3411 def __eq__(self, other):
3412 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003413 if self.oxm_ids != other.oxm_ids: return False
3414 return True
3415
Rich Lanec2ee4b82013-04-24 17:12:38 -07003416 def pretty_print(self, q):
3417 q.text("table_feature_prop_write_setfield_miss {")
3418 with q.group():
3419 with q.indent(2):
3420 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003421 q.text("oxm_ids = ");
3422 q.pp(self.oxm_ids)
3423 q.breakable()
3424 q.text('}')
3425
Rich Lane7dcdf022013-12-11 14:45:27 -08003426table_feature_prop.subtypes[13] = table_feature_prop_write_setfield_miss
3427
3428class table_features(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003429
3430 def __init__(self, table_id=None, name=None, metadata_match=None, metadata_write=None, config=None, max_entries=None, properties=None):
3431 if table_id != None:
3432 self.table_id = table_id
3433 else:
3434 self.table_id = 0
3435 if name != None:
3436 self.name = name
3437 else:
3438 self.name = ""
3439 if metadata_match != None:
3440 self.metadata_match = metadata_match
3441 else:
3442 self.metadata_match = 0
3443 if metadata_write != None:
3444 self.metadata_write = metadata_write
3445 else:
3446 self.metadata_write = 0
3447 if config != None:
3448 self.config = config
3449 else:
3450 self.config = 0
3451 if max_entries != None:
3452 self.max_entries = max_entries
3453 else:
3454 self.max_entries = 0
3455 if properties != None:
3456 self.properties = properties
3457 else:
3458 self.properties = []
3459 return
3460
3461 def pack(self):
3462 packed = []
3463 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
3464 packed.append(struct.pack("!B", self.table_id))
3465 packed.append('\x00' * 5)
3466 packed.append(struct.pack("!32s", self.name))
3467 packed.append(struct.pack("!Q", self.metadata_match))
3468 packed.append(struct.pack("!Q", self.metadata_write))
3469 packed.append(struct.pack("!L", self.config))
3470 packed.append(struct.pack("!L", self.max_entries))
Rich Lane7dcdf022013-12-11 14:45:27 -08003471 packed.append(loxi.generic_util.pack_list(self.properties))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003472 length = sum([len(x) for x in packed])
3473 packed[0] = struct.pack("!H", length)
3474 return ''.join(packed)
3475
3476 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003477 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003478 obj = table_features()
Dan Talaycof6202252013-07-02 01:00:29 -07003479 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003480 orig_reader = reader
3481 reader = orig_reader.slice(_length - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003482 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003483 reader.skip(5)
3484 obj.name = reader.read("!32s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -07003485 obj.metadata_match = reader.read("!Q")[0]
3486 obj.metadata_write = reader.read("!Q")[0]
3487 obj.config = reader.read("!L")[0]
3488 obj.max_entries = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003489 obj.properties = loxi.generic_util.unpack_list(reader, common.table_feature_prop.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003490 return obj
3491
3492 def __eq__(self, other):
3493 if type(self) != type(other): return False
3494 if self.table_id != other.table_id: return False
3495 if self.name != other.name: return False
3496 if self.metadata_match != other.metadata_match: return False
3497 if self.metadata_write != other.metadata_write: return False
3498 if self.config != other.config: return False
3499 if self.max_entries != other.max_entries: return False
3500 if self.properties != other.properties: return False
3501 return True
3502
Rich Lanec2ee4b82013-04-24 17:12:38 -07003503 def pretty_print(self, q):
3504 q.text("table_features {")
3505 with q.group():
3506 with q.indent(2):
3507 q.breakable()
3508 q.text("table_id = ");
3509 q.text("%#x" % self.table_id)
3510 q.text(","); q.breakable()
3511 q.text("name = ");
3512 q.pp(self.name)
3513 q.text(","); q.breakable()
3514 q.text("metadata_match = ");
3515 q.text("%#x" % self.metadata_match)
3516 q.text(","); q.breakable()
3517 q.text("metadata_write = ");
3518 q.text("%#x" % self.metadata_write)
3519 q.text(","); q.breakable()
3520 q.text("config = ");
3521 q.text("%#x" % self.config)
3522 q.text(","); q.breakable()
3523 q.text("max_entries = ");
3524 q.text("%#x" % self.max_entries)
3525 q.text(","); q.breakable()
3526 q.text("properties = ");
3527 q.pp(self.properties)
3528 q.breakable()
3529 q.text('}')
3530
Rich Lane7dcdf022013-12-11 14:45:27 -08003531
3532class table_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003533
3534 def __init__(self, table_id=None, active_count=None, lookup_count=None, matched_count=None):
3535 if table_id != None:
3536 self.table_id = table_id
3537 else:
3538 self.table_id = 0
3539 if active_count != None:
3540 self.active_count = active_count
3541 else:
3542 self.active_count = 0
3543 if lookup_count != None:
3544 self.lookup_count = lookup_count
3545 else:
3546 self.lookup_count = 0
3547 if matched_count != None:
3548 self.matched_count = matched_count
3549 else:
3550 self.matched_count = 0
3551 return
3552
3553 def pack(self):
3554 packed = []
3555 packed.append(struct.pack("!B", self.table_id))
3556 packed.append('\x00' * 3)
3557 packed.append(struct.pack("!L", self.active_count))
3558 packed.append(struct.pack("!Q", self.lookup_count))
3559 packed.append(struct.pack("!Q", self.matched_count))
3560 return ''.join(packed)
3561
3562 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003563 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003564 obj = table_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07003565 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003566 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07003567 obj.active_count = reader.read("!L")[0]
3568 obj.lookup_count = reader.read("!Q")[0]
3569 obj.matched_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003570 return obj
3571
3572 def __eq__(self, other):
3573 if type(self) != type(other): return False
3574 if self.table_id != other.table_id: return False
3575 if self.active_count != other.active_count: return False
3576 if self.lookup_count != other.lookup_count: return False
3577 if self.matched_count != other.matched_count: return False
3578 return True
3579
Rich Lanec2ee4b82013-04-24 17:12:38 -07003580 def pretty_print(self, q):
3581 q.text("table_stats_entry {")
3582 with q.group():
3583 with q.indent(2):
3584 q.breakable()
3585 q.text("table_id = ");
3586 q.text("%#x" % self.table_id)
3587 q.text(","); q.breakable()
3588 q.text("active_count = ");
3589 q.text("%#x" % self.active_count)
3590 q.text(","); q.breakable()
3591 q.text("lookup_count = ");
3592 q.text("%#x" % self.lookup_count)
3593 q.text(","); q.breakable()
3594 q.text("matched_count = ");
3595 q.text("%#x" % self.matched_count)
3596 q.breakable()
3597 q.text('}')
3598
Rich Lane7dcdf022013-12-11 14:45:27 -08003599
3600class uint32(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003601
3602 def __init__(self, value=None):
3603 if value != None:
3604 self.value = value
3605 else:
3606 self.value = 0
3607 return
3608
3609 def pack(self):
3610 packed = []
3611 packed.append(struct.pack("!L", self.value))
3612 return ''.join(packed)
3613
3614 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003615 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003616 obj = uint32()
Dan Talaycof6202252013-07-02 01:00:29 -07003617 obj.value = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003618 return obj
3619
3620 def __eq__(self, other):
3621 if type(self) != type(other): return False
3622 if self.value != other.value: return False
3623 return True
3624
Rich Lanec2ee4b82013-04-24 17:12:38 -07003625 def pretty_print(self, q):
3626 q.text("uint32 {")
3627 with q.group():
3628 with q.indent(2):
3629 q.breakable()
3630 q.text("value = ");
3631 q.text("%#x" % self.value)
3632 q.breakable()
3633 q.text('}')
3634
Rich Lane7dcdf022013-12-11 14:45:27 -08003635
3636class uint64(loxi.OFObject):
3637
3638 def __init__(self, value=None):
3639 if value != None:
3640 self.value = value
3641 else:
3642 self.value = 0
3643 return
3644
3645 def pack(self):
3646 packed = []
3647 packed.append(struct.pack("!Q", self.value))
3648 return ''.join(packed)
3649
3650 @staticmethod
3651 def unpack(reader):
3652 obj = uint64()
3653 obj.value = reader.read("!Q")[0]
3654 return obj
3655
3656 def __eq__(self, other):
3657 if type(self) != type(other): return False
3658 if self.value != other.value: return False
3659 return True
3660
3661 def pretty_print(self, q):
3662 q.text("uint64 {")
3663 with q.group():
3664 with q.indent(2):
3665 q.breakable()
3666 q.text("value = ");
3667 q.text("%#x" % self.value)
3668 q.breakable()
3669 q.text('}')
3670
3671
3672class uint8(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003673
3674 def __init__(self, value=None):
3675 if value != None:
3676 self.value = value
3677 else:
3678 self.value = 0
3679 return
3680
3681 def pack(self):
3682 packed = []
3683 packed.append(struct.pack("!B", self.value))
3684 return ''.join(packed)
3685
3686 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003687 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003688 obj = uint8()
Dan Talaycof6202252013-07-02 01:00:29 -07003689 obj.value = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003690 return obj
3691
3692 def __eq__(self, other):
3693 if type(self) != type(other): return False
3694 if self.value != other.value: return False
3695 return True
3696
Rich Lanec2ee4b82013-04-24 17:12:38 -07003697 def pretty_print(self, q):
3698 q.text("uint8 {")
3699 with q.group():
3700 with q.indent(2):
3701 q.breakable()
3702 q.text("value = ");
3703 q.text("%#x" % self.value)
3704 q.breakable()
3705 q.text('}')
3706
3707
Rich Lane7dcdf022013-12-11 14:45:27 -08003708
Rich Lanec2ee4b82013-04-24 17:12:38 -07003709match = match_v3