blob: 8080503fb4efdfad06df6949bdeb45a385c8d5d5 [file] [log] [blame]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001# Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2# Copyright (c) 2011, 2012 Open Networking Foundation
3# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
Dan Talaycof6202252013-07-02 01:00:29 -07004# See the file LICENSE.pyloxi which should have been included in the source distribution
Rich Lane7dcdf022013-12-11 14:45:27 -08005
6# Automatically generated by LOXI from template module.py
Rich Lanec2ee4b82013-04-24 17:12:38 -07007# Do not modify
8
Rich Lanec2ee4b82013-04-24 17:12:38 -07009import struct
Rich Lane7dcdf022013-12-11 14:45:27 -080010import loxi
Rich Lanec2ee4b82013-04-24 17:12:38 -070011import const
Rich Lane7dcdf022013-12-11 14:45:27 -080012import common
13import action
14import instruction
15import oxm
16import action_id
17import instruction_id
18import meter_band
Rich Lane5454b682014-01-14 17:07:36 -080019import bsn_tlv
Rich Lanec2ee4b82013-04-24 17:12:38 -070020import util
21import loxi.generic_util
22
Rich Lane5454b682014-01-14 17:07:36 -080023class bsn_controller_connection(loxi.OFObject):
24
25 def __init__(self, state=None, auxiliary_id=None, role=None, uri=None):
26 if state != None:
27 self.state = state
28 else:
29 self.state = 0
30 if auxiliary_id != None:
31 self.auxiliary_id = auxiliary_id
32 else:
33 self.auxiliary_id = 0
34 if role != None:
35 self.role = role
36 else:
37 self.role = 0
38 if uri != None:
39 self.uri = uri
40 else:
41 self.uri = ""
42 return
43
44 def pack(self):
45 packed = []
46 packed.append(struct.pack("!B", self.state))
47 packed.append(struct.pack("!B", self.auxiliary_id))
48 packed.append('\x00' * 2)
49 packed.append(struct.pack("!L", self.role))
50 packed.append(struct.pack("!256s", self.uri))
51 return ''.join(packed)
52
53 @staticmethod
54 def unpack(reader):
55 obj = bsn_controller_connection()
56 obj.state = reader.read("!B")[0]
57 obj.auxiliary_id = reader.read("!B")[0]
58 reader.skip(2)
59 obj.role = reader.read("!L")[0]
60 obj.uri = reader.read("!256s")[0].rstrip("\x00")
61 return obj
62
63 def __eq__(self, other):
64 if type(self) != type(other): return False
65 if self.state != other.state: return False
66 if self.auxiliary_id != other.auxiliary_id: return False
67 if self.role != other.role: return False
68 if self.uri != other.uri: return False
69 return True
70
71 def pretty_print(self, q):
72 q.text("bsn_controller_connection {")
73 with q.group():
74 with q.indent(2):
75 q.breakable()
76 q.text("state = ");
77 q.text("%#x" % self.state)
78 q.text(","); q.breakable()
79 q.text("auxiliary_id = ");
80 q.text("%#x" % self.auxiliary_id)
81 q.text(","); q.breakable()
82 q.text("role = ");
83 q.text("%#x" % self.role)
84 q.text(","); q.breakable()
85 q.text("uri = ");
86 q.pp(self.uri)
87 q.breakable()
88 q.text('}')
89
90
91class bsn_gentable_bucket_stats_entry(loxi.OFObject):
92
93 def __init__(self, checksum=None):
94 if checksum != None:
95 self.checksum = checksum
96 else:
97 self.checksum = 0
98 return
99
100 def pack(self):
101 packed = []
102 packed.append(util.pack_checksum_128(self.checksum))
103 return ''.join(packed)
104
105 @staticmethod
106 def unpack(reader):
107 obj = bsn_gentable_bucket_stats_entry()
108 obj.checksum = util.unpack_checksum_128(reader)
109 return obj
110
111 def __eq__(self, other):
112 if type(self) != type(other): return False
113 if self.checksum != other.checksum: return False
114 return True
115
116 def pretty_print(self, q):
117 q.text("bsn_gentable_bucket_stats_entry {")
118 with q.group():
119 with q.indent(2):
120 q.breakable()
121 q.text("checksum = ");
122 q.pp(self.checksum)
123 q.breakable()
124 q.text('}')
125
126
127class bsn_gentable_desc_stats_entry(loxi.OFObject):
128
129 def __init__(self, table_id=None, name=None, buckets_size=None, max_entries=None):
130 if table_id != None:
131 self.table_id = table_id
132 else:
133 self.table_id = 0
134 if name != None:
135 self.name = name
136 else:
137 self.name = ""
138 if buckets_size != None:
139 self.buckets_size = buckets_size
140 else:
141 self.buckets_size = 0
142 if max_entries != None:
143 self.max_entries = max_entries
144 else:
145 self.max_entries = 0
146 return
147
148 def pack(self):
149 packed = []
150 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
151 packed.append(struct.pack("!H", self.table_id))
152 packed.append(struct.pack("!32s", self.name))
153 packed.append(struct.pack("!L", self.buckets_size))
154 packed.append(struct.pack("!L", self.max_entries))
155 packed.append('\x00' * 4)
156 length = sum([len(x) for x in packed])
157 packed[0] = struct.pack("!H", length)
158 return ''.join(packed)
159
160 @staticmethod
161 def unpack(reader):
162 obj = bsn_gentable_desc_stats_entry()
163 _length = reader.read("!H")[0]
164 orig_reader = reader
165 reader = orig_reader.slice(_length - (0 + 2))
166 obj.table_id = reader.read("!H")[0]
167 obj.name = reader.read("!32s")[0].rstrip("\x00")
168 obj.buckets_size = reader.read("!L")[0]
169 obj.max_entries = reader.read("!L")[0]
170 reader.skip(4)
171 return obj
172
173 def __eq__(self, other):
174 if type(self) != type(other): return False
175 if self.table_id != other.table_id: return False
176 if self.name != other.name: return False
177 if self.buckets_size != other.buckets_size: return False
178 if self.max_entries != other.max_entries: return False
179 return True
180
181 def pretty_print(self, q):
182 q.text("bsn_gentable_desc_stats_entry {")
183 with q.group():
184 with q.indent(2):
185 q.breakable()
186 q.text("table_id = ");
187 q.text("%#x" % self.table_id)
188 q.text(","); q.breakable()
189 q.text("name = ");
190 q.pp(self.name)
191 q.text(","); q.breakable()
192 q.text("buckets_size = ");
193 q.text("%#x" % self.buckets_size)
194 q.text(","); q.breakable()
195 q.text("max_entries = ");
196 q.text("%#x" % self.max_entries)
197 q.breakable()
198 q.text('}')
199
200
201class bsn_gentable_entry_desc_stats_entry(loxi.OFObject):
202
203 def __init__(self, checksum=None, key=None, value=None):
204 if checksum != None:
205 self.checksum = checksum
206 else:
207 self.checksum = 0
208 if key != None:
209 self.key = key
210 else:
211 self.key = []
212 if value != None:
213 self.value = value
214 else:
215 self.value = []
216 return
217
218 def pack(self):
219 packed = []
220 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
221 packed.append(struct.pack("!H", 0)) # placeholder for key_length at index 1
222 packed.append(util.pack_checksum_128(self.checksum))
223 packed.append(loxi.generic_util.pack_list(self.key))
224 packed[1] = struct.pack("!H", len(packed[-1]))
225 packed.append(loxi.generic_util.pack_list(self.value))
226 length = sum([len(x) for x in packed])
227 packed[0] = struct.pack("!H", length)
228 return ''.join(packed)
229
230 @staticmethod
231 def unpack(reader):
232 obj = bsn_gentable_entry_desc_stats_entry()
233 _length = reader.read("!H")[0]
234 orig_reader = reader
235 reader = orig_reader.slice(_length - (0 + 2))
236 _key_length = reader.read("!H")[0]
237 obj.checksum = util.unpack_checksum_128(reader)
238 obj.key = loxi.generic_util.unpack_list(reader.slice(_key_length), bsn_tlv.bsn_tlv.unpack)
239 obj.value = loxi.generic_util.unpack_list(reader, bsn_tlv.bsn_tlv.unpack)
240 return obj
241
242 def __eq__(self, other):
243 if type(self) != type(other): return False
244 if self.checksum != other.checksum: return False
245 if self.key != other.key: return False
246 if self.value != other.value: return False
247 return True
248
249 def pretty_print(self, q):
250 q.text("bsn_gentable_entry_desc_stats_entry {")
251 with q.group():
252 with q.indent(2):
253 q.breakable()
254 q.text("checksum = ");
255 q.pp(self.checksum)
256 q.text(","); q.breakable()
257 q.text("key = ");
258 q.pp(self.key)
259 q.text(","); q.breakable()
260 q.text("value = ");
261 q.pp(self.value)
262 q.breakable()
263 q.text('}')
264
265
266class bsn_gentable_entry_stats_entry(loxi.OFObject):
267
268 def __init__(self, key=None, stats=None):
269 if key != None:
270 self.key = key
271 else:
272 self.key = []
273 if stats != None:
274 self.stats = stats
275 else:
276 self.stats = []
277 return
278
279 def pack(self):
280 packed = []
281 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
282 packed.append(struct.pack("!H", 0)) # placeholder for key_length at index 1
283 packed.append(loxi.generic_util.pack_list(self.key))
284 packed[1] = struct.pack("!H", len(packed[-1]))
285 packed.append(loxi.generic_util.pack_list(self.stats))
286 length = sum([len(x) for x in packed])
287 packed[0] = struct.pack("!H", length)
288 return ''.join(packed)
289
290 @staticmethod
291 def unpack(reader):
292 obj = bsn_gentable_entry_stats_entry()
293 _length = reader.read("!H")[0]
294 orig_reader = reader
295 reader = orig_reader.slice(_length - (0 + 2))
296 _key_length = reader.read("!H")[0]
297 obj.key = loxi.generic_util.unpack_list(reader.slice(_key_length), bsn_tlv.bsn_tlv.unpack)
298 obj.stats = loxi.generic_util.unpack_list(reader, bsn_tlv.bsn_tlv.unpack)
299 return obj
300
301 def __eq__(self, other):
302 if type(self) != type(other): return False
303 if self.key != other.key: return False
304 if self.stats != other.stats: return False
305 return True
306
307 def pretty_print(self, q):
308 q.text("bsn_gentable_entry_stats_entry {")
309 with q.group():
310 with q.indent(2):
311 q.breakable()
312 q.text("key = ");
313 q.pp(self.key)
314 q.text(","); q.breakable()
315 q.text("stats = ");
316 q.pp(self.stats)
317 q.breakable()
318 q.text('}')
319
320
321class bsn_gentable_stats_entry(loxi.OFObject):
322
323 def __init__(self, table_id=None, entry_count=None, checksum=None):
324 if table_id != None:
325 self.table_id = table_id
326 else:
327 self.table_id = 0
328 if entry_count != None:
329 self.entry_count = entry_count
330 else:
331 self.entry_count = 0
332 if checksum != None:
333 self.checksum = checksum
334 else:
335 self.checksum = 0
336 return
337
338 def pack(self):
339 packed = []
340 packed.append(struct.pack("!H", self.table_id))
341 packed.append('\x00' * 2)
342 packed.append(struct.pack("!L", self.entry_count))
343 packed.append(util.pack_checksum_128(self.checksum))
344 return ''.join(packed)
345
346 @staticmethod
347 def unpack(reader):
348 obj = bsn_gentable_stats_entry()
349 obj.table_id = reader.read("!H")[0]
350 reader.skip(2)
351 obj.entry_count = reader.read("!L")[0]
352 obj.checksum = util.unpack_checksum_128(reader)
353 return obj
354
355 def __eq__(self, other):
356 if type(self) != type(other): return False
357 if self.table_id != other.table_id: return False
358 if self.entry_count != other.entry_count: return False
359 if self.checksum != other.checksum: return False
360 return True
361
362 def pretty_print(self, q):
363 q.text("bsn_gentable_stats_entry {")
364 with q.group():
365 with q.indent(2):
366 q.breakable()
367 q.text("table_id = ");
368 q.text("%#x" % self.table_id)
369 q.text(","); q.breakable()
370 q.text("entry_count = ");
371 q.text("%#x" % self.entry_count)
372 q.text(","); q.breakable()
373 q.text("checksum = ");
374 q.pp(self.checksum)
375 q.breakable()
376 q.text('}')
377
378
Rich Lane7dcdf022013-12-11 14:45:27 -0800379class bsn_interface(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700380
381 def __init__(self, hw_addr=None, name=None, ipv4_addr=None, ipv4_netmask=None):
382 if hw_addr != None:
383 self.hw_addr = hw_addr
384 else:
385 self.hw_addr = [0,0,0,0,0,0]
386 if name != None:
387 self.name = name
388 else:
389 self.name = ""
390 if ipv4_addr != None:
391 self.ipv4_addr = ipv4_addr
392 else:
393 self.ipv4_addr = 0
394 if ipv4_netmask != None:
395 self.ipv4_netmask = ipv4_netmask
396 else:
397 self.ipv4_netmask = 0
398 return
399
400 def pack(self):
401 packed = []
402 packed.append(struct.pack("!6B", *self.hw_addr))
403 packed.append('\x00' * 2)
404 packed.append(struct.pack("!16s", self.name))
405 packed.append(struct.pack("!L", self.ipv4_addr))
406 packed.append(struct.pack("!L", self.ipv4_netmask))
407 return ''.join(packed)
408
409 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800410 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700411 obj = bsn_interface()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700412 obj.hw_addr = list(reader.read('!6B'))
413 reader.skip(2)
414 obj.name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -0700415 obj.ipv4_addr = reader.read("!L")[0]
416 obj.ipv4_netmask = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700417 return obj
418
419 def __eq__(self, other):
420 if type(self) != type(other): return False
421 if self.hw_addr != other.hw_addr: return False
422 if self.name != other.name: return False
423 if self.ipv4_addr != other.ipv4_addr: return False
424 if self.ipv4_netmask != other.ipv4_netmask: return False
425 return True
426
Rich Lanec2ee4b82013-04-24 17:12:38 -0700427 def pretty_print(self, q):
428 q.text("bsn_interface {")
429 with q.group():
430 with q.indent(2):
431 q.breakable()
432 q.text("hw_addr = ");
433 q.text(util.pretty_mac(self.hw_addr))
434 q.text(","); q.breakable()
435 q.text("name = ");
436 q.pp(self.name)
437 q.text(","); q.breakable()
438 q.text("ipv4_addr = ");
439 q.text(util.pretty_ipv4(self.ipv4_addr))
440 q.text(","); q.breakable()
441 q.text("ipv4_netmask = ");
442 q.text(util.pretty_ipv4(self.ipv4_netmask))
443 q.breakable()
444 q.text('}')
445
Rich Lane7dcdf022013-12-11 14:45:27 -0800446
447class bsn_lacp_stats_entry(loxi.OFObject):
Rich Lane7b0f2012013-11-22 14:15:26 -0800448
449 def __init__(self, port_no=None, actor_sys_priority=None, actor_sys_mac=None, actor_port_priority=None, actor_port_num=None, actor_key=None, convergence_status=None, partner_sys_priority=None, partner_sys_mac=None, partner_port_priority=None, partner_port_num=None, partner_key=None):
450 if port_no != None:
451 self.port_no = port_no
452 else:
453 self.port_no = 0
454 if actor_sys_priority != None:
455 self.actor_sys_priority = actor_sys_priority
456 else:
457 self.actor_sys_priority = 0
458 if actor_sys_mac != None:
459 self.actor_sys_mac = actor_sys_mac
460 else:
461 self.actor_sys_mac = [0,0,0,0,0,0]
462 if actor_port_priority != None:
463 self.actor_port_priority = actor_port_priority
464 else:
465 self.actor_port_priority = 0
466 if actor_port_num != None:
467 self.actor_port_num = actor_port_num
468 else:
469 self.actor_port_num = 0
470 if actor_key != None:
471 self.actor_key = actor_key
472 else:
473 self.actor_key = 0
474 if convergence_status != None:
475 self.convergence_status = convergence_status
476 else:
477 self.convergence_status = 0
478 if partner_sys_priority != None:
479 self.partner_sys_priority = partner_sys_priority
480 else:
481 self.partner_sys_priority = 0
482 if partner_sys_mac != None:
483 self.partner_sys_mac = partner_sys_mac
484 else:
485 self.partner_sys_mac = [0,0,0,0,0,0]
486 if partner_port_priority != None:
487 self.partner_port_priority = partner_port_priority
488 else:
489 self.partner_port_priority = 0
490 if partner_port_num != None:
491 self.partner_port_num = partner_port_num
492 else:
493 self.partner_port_num = 0
494 if partner_key != None:
495 self.partner_key = partner_key
496 else:
497 self.partner_key = 0
498 return
499
500 def pack(self):
501 packed = []
502 packed.append(util.pack_port_no(self.port_no))
503 packed.append(struct.pack("!H", self.actor_sys_priority))
504 packed.append(struct.pack("!6B", *self.actor_sys_mac))
505 packed.append(struct.pack("!H", self.actor_port_priority))
506 packed.append(struct.pack("!H", self.actor_port_num))
507 packed.append(struct.pack("!H", self.actor_key))
508 packed.append(struct.pack("!B", self.convergence_status))
509 packed.append('\x00' * 1)
510 packed.append(struct.pack("!H", self.partner_sys_priority))
511 packed.append(struct.pack("!6B", *self.partner_sys_mac))
512 packed.append(struct.pack("!H", self.partner_port_priority))
513 packed.append(struct.pack("!H", self.partner_port_num))
514 packed.append(struct.pack("!H", self.partner_key))
515 packed.append('\x00' * 2)
516 return ''.join(packed)
517
518 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800519 def unpack(reader):
Rich Lane7b0f2012013-11-22 14:15:26 -0800520 obj = bsn_lacp_stats_entry()
Rich Lane7b0f2012013-11-22 14:15:26 -0800521 obj.port_no = util.unpack_port_no(reader)
522 obj.actor_sys_priority = reader.read("!H")[0]
523 obj.actor_sys_mac = list(reader.read('!6B'))
524 obj.actor_port_priority = reader.read("!H")[0]
525 obj.actor_port_num = reader.read("!H")[0]
526 obj.actor_key = reader.read("!H")[0]
527 obj.convergence_status = reader.read("!B")[0]
528 reader.skip(1)
529 obj.partner_sys_priority = reader.read("!H")[0]
530 obj.partner_sys_mac = list(reader.read('!6B'))
531 obj.partner_port_priority = reader.read("!H")[0]
532 obj.partner_port_num = reader.read("!H")[0]
533 obj.partner_key = reader.read("!H")[0]
534 reader.skip(2)
535 return obj
536
537 def __eq__(self, other):
538 if type(self) != type(other): return False
539 if self.port_no != other.port_no: return False
540 if self.actor_sys_priority != other.actor_sys_priority: return False
541 if self.actor_sys_mac != other.actor_sys_mac: return False
542 if self.actor_port_priority != other.actor_port_priority: return False
543 if self.actor_port_num != other.actor_port_num: return False
544 if self.actor_key != other.actor_key: return False
545 if self.convergence_status != other.convergence_status: return False
546 if self.partner_sys_priority != other.partner_sys_priority: return False
547 if self.partner_sys_mac != other.partner_sys_mac: return False
548 if self.partner_port_priority != other.partner_port_priority: return False
549 if self.partner_port_num != other.partner_port_num: return False
550 if self.partner_key != other.partner_key: return False
551 return True
552
Rich Lane7b0f2012013-11-22 14:15:26 -0800553 def pretty_print(self, q):
554 q.text("bsn_lacp_stats_entry {")
555 with q.group():
556 with q.indent(2):
557 q.breakable()
558 q.text("port_no = ");
559 q.text(util.pretty_port(self.port_no))
560 q.text(","); q.breakable()
561 q.text("actor_sys_priority = ");
562 q.text("%#x" % self.actor_sys_priority)
563 q.text(","); q.breakable()
564 q.text("actor_sys_mac = ");
565 q.text(util.pretty_mac(self.actor_sys_mac))
566 q.text(","); q.breakable()
567 q.text("actor_port_priority = ");
568 q.text("%#x" % self.actor_port_priority)
569 q.text(","); q.breakable()
570 q.text("actor_port_num = ");
571 q.text("%#x" % self.actor_port_num)
572 q.text(","); q.breakable()
573 q.text("actor_key = ");
574 q.text("%#x" % self.actor_key)
575 q.text(","); q.breakable()
576 q.text("convergence_status = ");
577 q.text("%#x" % self.convergence_status)
578 q.text(","); q.breakable()
579 q.text("partner_sys_priority = ");
580 q.text("%#x" % self.partner_sys_priority)
581 q.text(","); q.breakable()
582 q.text("partner_sys_mac = ");
583 q.text(util.pretty_mac(self.partner_sys_mac))
584 q.text(","); q.breakable()
585 q.text("partner_port_priority = ");
586 q.text("%#x" % self.partner_port_priority)
587 q.text(","); q.breakable()
588 q.text("partner_port_num = ");
589 q.text("%#x" % self.partner_port_num)
590 q.text(","); q.breakable()
591 q.text("partner_key = ");
592 q.text("%#x" % self.partner_key)
593 q.breakable()
594 q.text('}')
595
Rich Lane7dcdf022013-12-11 14:45:27 -0800596
597class bsn_port_counter_stats_entry(loxi.OFObject):
598
599 def __init__(self, port_no=None, values=None):
600 if port_no != None:
601 self.port_no = port_no
602 else:
603 self.port_no = 0
604 if values != None:
605 self.values = values
606 else:
607 self.values = []
608 return
609
610 def pack(self):
611 packed = []
612 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
613 packed.append('\x00' * 2)
614 packed.append(util.pack_port_no(self.port_no))
615 packed.append(loxi.generic_util.pack_list(self.values))
616 length = sum([len(x) for x in packed])
617 packed[0] = struct.pack("!H", length)
618 return ''.join(packed)
619
620 @staticmethod
621 def unpack(reader):
622 obj = bsn_port_counter_stats_entry()
623 _length = reader.read("!H")[0]
624 orig_reader = reader
625 reader = orig_reader.slice(_length - (0 + 2))
626 reader.skip(2)
627 obj.port_no = util.unpack_port_no(reader)
628 obj.values = loxi.generic_util.unpack_list(reader, common.uint64.unpack)
629 return obj
630
631 def __eq__(self, other):
632 if type(self) != type(other): return False
633 if self.port_no != other.port_no: return False
634 if self.values != other.values: return False
635 return True
636
637 def pretty_print(self, q):
638 q.text("bsn_port_counter_stats_entry {")
639 with q.group():
640 with q.indent(2):
641 q.breakable()
642 q.text("port_no = ");
643 q.text(util.pretty_port(self.port_no))
644 q.text(","); q.breakable()
645 q.text("values = ");
646 q.pp(self.values)
647 q.breakable()
648 q.text('}')
649
650
651class bsn_switch_pipeline_stats_entry(loxi.OFObject):
652
653 def __init__(self, pipeline=None):
654 if pipeline != None:
655 self.pipeline = pipeline
656 else:
657 self.pipeline = ""
658 return
659
660 def pack(self):
661 packed = []
662 packed.append(struct.pack("!256s", self.pipeline))
663 return ''.join(packed)
664
665 @staticmethod
666 def unpack(reader):
667 obj = bsn_switch_pipeline_stats_entry()
668 obj.pipeline = reader.read("!256s")[0].rstrip("\x00")
669 return obj
670
671 def __eq__(self, other):
672 if type(self) != type(other): return False
673 if self.pipeline != other.pipeline: return False
674 return True
675
676 def pretty_print(self, q):
677 q.text("bsn_switch_pipeline_stats_entry {")
678 with q.group():
679 with q.indent(2):
680 q.breakable()
681 q.text("pipeline = ");
682 q.pp(self.pipeline)
683 q.breakable()
684 q.text('}')
685
686
687class bsn_vport(loxi.OFObject):
688 subtypes = {}
689
690 @staticmethod
691 def unpack(reader):
692 subtype, = reader.peek('!H', 0)
693 try:
694 subclass = bsn_vport.subtypes[subtype]
695 except KeyError:
696 raise loxi.ProtocolError("unknown bsn_vport subtype %#x" % subtype)
697 return subclass.unpack(reader)
698
699
700class bsn_vport_q_in_q(bsn_vport):
Dan Talaycof6202252013-07-02 01:00:29 -0700701 type = 0
702
Kiran Poola150d8b02013-09-20 13:30:39 -0700703 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 -0700704 if port_no != None:
705 self.port_no = port_no
706 else:
707 self.port_no = 0
708 if ingress_tpid != None:
709 self.ingress_tpid = ingress_tpid
710 else:
711 self.ingress_tpid = 0
712 if ingress_vlan_id != None:
713 self.ingress_vlan_id = ingress_vlan_id
714 else:
715 self.ingress_vlan_id = 0
716 if egress_tpid != None:
717 self.egress_tpid = egress_tpid
718 else:
719 self.egress_tpid = 0
720 if egress_vlan_id != None:
721 self.egress_vlan_id = egress_vlan_id
722 else:
723 self.egress_vlan_id = 0
Kiran Poola150d8b02013-09-20 13:30:39 -0700724 if if_name != None:
725 self.if_name = if_name
726 else:
727 self.if_name = ""
Dan Talaycof6202252013-07-02 01:00:29 -0700728 return
729
730 def pack(self):
731 packed = []
732 packed.append(struct.pack("!H", self.type))
Kiran Poola150d8b02013-09-20 13:30:39 -0700733 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700734 packed.append(struct.pack("!L", self.port_no))
735 packed.append(struct.pack("!H", self.ingress_tpid))
736 packed.append(struct.pack("!H", self.ingress_vlan_id))
737 packed.append(struct.pack("!H", self.egress_tpid))
738 packed.append(struct.pack("!H", self.egress_vlan_id))
Kiran Poola150d8b02013-09-20 13:30:39 -0700739 packed.append(struct.pack("!16s", self.if_name))
Dan Talaycof6202252013-07-02 01:00:29 -0700740 length = sum([len(x) for x in packed])
Kiran Poola150d8b02013-09-20 13:30:39 -0700741 packed[1] = struct.pack("!H", length)
Dan Talaycof6202252013-07-02 01:00:29 -0700742 return ''.join(packed)
743
744 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800745 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -0700746 obj = bsn_vport_q_in_q()
Dan Talaycof6202252013-07-02 01:00:29 -0700747 _type = reader.read("!H")[0]
748 assert(_type == 0)
749 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800750 orig_reader = reader
751 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700752 obj.port_no = reader.read("!L")[0]
753 obj.ingress_tpid = reader.read("!H")[0]
754 obj.ingress_vlan_id = reader.read("!H")[0]
755 obj.egress_tpid = reader.read("!H")[0]
756 obj.egress_vlan_id = reader.read("!H")[0]
Kiran Poola150d8b02013-09-20 13:30:39 -0700757 obj.if_name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -0700758 return obj
759
760 def __eq__(self, other):
761 if type(self) != type(other): return False
762 if self.port_no != other.port_no: return False
763 if self.ingress_tpid != other.ingress_tpid: return False
764 if self.ingress_vlan_id != other.ingress_vlan_id: return False
765 if self.egress_tpid != other.egress_tpid: return False
766 if self.egress_vlan_id != other.egress_vlan_id: return False
Kiran Poola150d8b02013-09-20 13:30:39 -0700767 if self.if_name != other.if_name: return False
Dan Talaycof6202252013-07-02 01:00:29 -0700768 return True
769
Dan Talaycof6202252013-07-02 01:00:29 -0700770 def pretty_print(self, q):
771 q.text("bsn_vport_q_in_q {")
772 with q.group():
773 with q.indent(2):
774 q.breakable()
775 q.text("port_no = ");
776 q.text("%#x" % self.port_no)
777 q.text(","); q.breakable()
778 q.text("ingress_tpid = ");
779 q.text("%#x" % self.ingress_tpid)
780 q.text(","); q.breakable()
781 q.text("ingress_vlan_id = ");
782 q.text("%#x" % self.ingress_vlan_id)
783 q.text(","); q.breakable()
784 q.text("egress_tpid = ");
785 q.text("%#x" % self.egress_tpid)
786 q.text(","); q.breakable()
787 q.text("egress_vlan_id = ");
788 q.text("%#x" % self.egress_vlan_id)
Kiran Poola150d8b02013-09-20 13:30:39 -0700789 q.text(","); q.breakable()
790 q.text("if_name = ");
791 q.pp(self.if_name)
Dan Talaycof6202252013-07-02 01:00:29 -0700792 q.breakable()
793 q.text('}')
794
Rich Lane7dcdf022013-12-11 14:45:27 -0800795bsn_vport.subtypes[0] = bsn_vport_q_in_q
796
797class bsn_vlan_counter_stats_entry(loxi.OFObject):
798
799 def __init__(self, vlan_vid=None, values=None):
800 if vlan_vid != None:
801 self.vlan_vid = vlan_vid
802 else:
803 self.vlan_vid = 0
804 if values != None:
805 self.values = values
806 else:
807 self.values = []
808 return
809
810 def pack(self):
811 packed = []
812 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
813 packed.append(struct.pack("!H", self.vlan_vid))
814 packed.append('\x00' * 4)
815 packed.append(loxi.generic_util.pack_list(self.values))
816 length = sum([len(x) for x in packed])
817 packed[0] = struct.pack("!H", length)
818 return ''.join(packed)
819
820 @staticmethod
821 def unpack(reader):
822 obj = bsn_vlan_counter_stats_entry()
823 _length = reader.read("!H")[0]
824 orig_reader = reader
825 reader = orig_reader.slice(_length - (0 + 2))
826 obj.vlan_vid = reader.read("!H")[0]
827 reader.skip(4)
828 obj.values = loxi.generic_util.unpack_list(reader, common.uint64.unpack)
829 return obj
830
831 def __eq__(self, other):
832 if type(self) != type(other): return False
833 if self.vlan_vid != other.vlan_vid: return False
834 if self.values != other.values: return False
835 return True
836
837 def pretty_print(self, q):
838 q.text("bsn_vlan_counter_stats_entry {")
839 with q.group():
840 with q.indent(2):
841 q.breakable()
842 q.text("vlan_vid = ");
843 q.text("%#x" % self.vlan_vid)
844 q.text(","); q.breakable()
845 q.text("values = ");
846 q.pp(self.values)
847 q.breakable()
848 q.text('}')
849
850
851class bucket(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700852
853 def __init__(self, weight=None, watch_port=None, watch_group=None, actions=None):
854 if weight != None:
855 self.weight = weight
856 else:
857 self.weight = 0
858 if watch_port != None:
859 self.watch_port = watch_port
860 else:
861 self.watch_port = 0
862 if watch_group != None:
863 self.watch_group = watch_group
864 else:
865 self.watch_group = 0
866 if actions != None:
867 self.actions = actions
868 else:
869 self.actions = []
870 return
871
872 def pack(self):
873 packed = []
874 packed.append(struct.pack("!H", 0)) # placeholder for len at index 0
875 packed.append(struct.pack("!H", self.weight))
Dan Talaycof6202252013-07-02 01:00:29 -0700876 packed.append(util.pack_port_no(self.watch_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700877 packed.append(struct.pack("!L", self.watch_group))
878 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -0800879 packed.append(loxi.generic_util.pack_list(self.actions))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700880 length = sum([len(x) for x in packed])
881 packed[0] = struct.pack("!H", length)
882 return ''.join(packed)
883
884 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800885 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700886 obj = bucket()
Dan Talaycof6202252013-07-02 01:00:29 -0700887 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800888 orig_reader = reader
889 reader = orig_reader.slice(_len - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700890 obj.weight = reader.read("!H")[0]
891 obj.watch_port = util.unpack_port_no(reader)
892 obj.watch_group = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700893 reader.skip(4)
Rich Lane7dcdf022013-12-11 14:45:27 -0800894 obj.actions = loxi.generic_util.unpack_list(reader, action.action.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700895 return obj
896
897 def __eq__(self, other):
898 if type(self) != type(other): return False
899 if self.weight != other.weight: return False
900 if self.watch_port != other.watch_port: return False
901 if self.watch_group != other.watch_group: return False
902 if self.actions != other.actions: return False
903 return True
904
Rich Lanec2ee4b82013-04-24 17:12:38 -0700905 def pretty_print(self, q):
906 q.text("bucket {")
907 with q.group():
908 with q.indent(2):
909 q.breakable()
910 q.text("weight = ");
911 q.text("%#x" % self.weight)
912 q.text(","); q.breakable()
913 q.text("watch_port = ");
914 q.text(util.pretty_port(self.watch_port))
915 q.text(","); q.breakable()
916 q.text("watch_group = ");
917 q.text("%#x" % self.watch_group)
918 q.text(","); q.breakable()
919 q.text("actions = ");
920 q.pp(self.actions)
921 q.breakable()
922 q.text('}')
923
Rich Lane7dcdf022013-12-11 14:45:27 -0800924
925class bucket_counter(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700926
927 def __init__(self, packet_count=None, byte_count=None):
928 if packet_count != None:
929 self.packet_count = packet_count
930 else:
931 self.packet_count = 0
932 if byte_count != None:
933 self.byte_count = byte_count
934 else:
935 self.byte_count = 0
936 return
937
938 def pack(self):
939 packed = []
940 packed.append(struct.pack("!Q", self.packet_count))
941 packed.append(struct.pack("!Q", self.byte_count))
942 return ''.join(packed)
943
944 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800945 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700946 obj = bucket_counter()
Dan Talaycof6202252013-07-02 01:00:29 -0700947 obj.packet_count = reader.read("!Q")[0]
948 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700949 return obj
950
951 def __eq__(self, other):
952 if type(self) != type(other): return False
953 if self.packet_count != other.packet_count: return False
954 if self.byte_count != other.byte_count: return False
955 return True
956
Rich Lanec2ee4b82013-04-24 17:12:38 -0700957 def pretty_print(self, q):
958 q.text("bucket_counter {")
959 with q.group():
960 with q.indent(2):
961 q.breakable()
962 q.text("packet_count = ");
963 q.text("%#x" % self.packet_count)
964 q.text(","); q.breakable()
965 q.text("byte_count = ");
966 q.text("%#x" % self.byte_count)
967 q.breakable()
968 q.text('}')
969
Rich Lane7dcdf022013-12-11 14:45:27 -0800970
971class experimenter_stats_header(loxi.OFObject):
972 subtypes = {}
973
974 @staticmethod
975 def unpack(reader):
976 subtype, = reader.peek('!L', 0)
977 try:
978 subclass = experimenter_stats_header.subtypes[subtype]
979 except KeyError:
980 raise loxi.ProtocolError("unknown experimenter_stats_header subtype %#x" % subtype)
981 return subclass.unpack(reader)
982
983
984class flow_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700985
Kiran Poolaae8fbf12013-09-19 16:32:32 -0700986 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 -0700987 if table_id != None:
988 self.table_id = table_id
989 else:
990 self.table_id = 0
991 if duration_sec != None:
992 self.duration_sec = duration_sec
993 else:
994 self.duration_sec = 0
995 if duration_nsec != None:
996 self.duration_nsec = duration_nsec
997 else:
998 self.duration_nsec = 0
999 if priority != None:
1000 self.priority = priority
1001 else:
1002 self.priority = 0
1003 if idle_timeout != None:
1004 self.idle_timeout = idle_timeout
1005 else:
1006 self.idle_timeout = 0
1007 if hard_timeout != None:
1008 self.hard_timeout = hard_timeout
1009 else:
1010 self.hard_timeout = 0
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001011 if flags != None:
1012 self.flags = flags
1013 else:
1014 self.flags = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07001015 if cookie != None:
1016 self.cookie = cookie
1017 else:
1018 self.cookie = 0
1019 if packet_count != None:
1020 self.packet_count = packet_count
1021 else:
1022 self.packet_count = 0
1023 if byte_count != None:
1024 self.byte_count = byte_count
1025 else:
1026 self.byte_count = 0
1027 if match != None:
1028 self.match = match
1029 else:
1030 self.match = common.match()
1031 if instructions != None:
1032 self.instructions = instructions
1033 else:
1034 self.instructions = []
1035 return
1036
1037 def pack(self):
1038 packed = []
1039 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
1040 packed.append(struct.pack("!B", self.table_id))
1041 packed.append('\x00' * 1)
1042 packed.append(struct.pack("!L", self.duration_sec))
1043 packed.append(struct.pack("!L", self.duration_nsec))
1044 packed.append(struct.pack("!H", self.priority))
1045 packed.append(struct.pack("!H", self.idle_timeout))
1046 packed.append(struct.pack("!H", self.hard_timeout))
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001047 packed.append(struct.pack("!H", self.flags))
1048 packed.append('\x00' * 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001049 packed.append(struct.pack("!Q", self.cookie))
1050 packed.append(struct.pack("!Q", self.packet_count))
1051 packed.append(struct.pack("!Q", self.byte_count))
1052 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08001053 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001054 length = sum([len(x) for x in packed])
1055 packed[0] = struct.pack("!H", length)
1056 return ''.join(packed)
1057
1058 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001059 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001060 obj = flow_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001061 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001062 orig_reader = reader
1063 reader = orig_reader.slice(_length - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001064 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001065 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -07001066 obj.duration_sec = reader.read("!L")[0]
1067 obj.duration_nsec = reader.read("!L")[0]
1068 obj.priority = reader.read("!H")[0]
1069 obj.idle_timeout = reader.read("!H")[0]
1070 obj.hard_timeout = reader.read("!H")[0]
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001071 obj.flags = reader.read("!H")[0]
1072 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001073 obj.cookie = reader.read("!Q")[0]
1074 obj.packet_count = reader.read("!Q")[0]
1075 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001076 obj.match = common.match.unpack(reader)
Rich Lane7dcdf022013-12-11 14:45:27 -08001077 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001078 return obj
1079
1080 def __eq__(self, other):
1081 if type(self) != type(other): return False
1082 if self.table_id != other.table_id: return False
1083 if self.duration_sec != other.duration_sec: return False
1084 if self.duration_nsec != other.duration_nsec: return False
1085 if self.priority != other.priority: return False
1086 if self.idle_timeout != other.idle_timeout: return False
1087 if self.hard_timeout != other.hard_timeout: return False
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001088 if self.flags != other.flags: return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001089 if self.cookie != other.cookie: return False
1090 if self.packet_count != other.packet_count: return False
1091 if self.byte_count != other.byte_count: return False
1092 if self.match != other.match: return False
1093 if self.instructions != other.instructions: return False
1094 return True
1095
Rich Lanec2ee4b82013-04-24 17:12:38 -07001096 def pretty_print(self, q):
1097 q.text("flow_stats_entry {")
1098 with q.group():
1099 with q.indent(2):
1100 q.breakable()
1101 q.text("table_id = ");
1102 q.text("%#x" % self.table_id)
1103 q.text(","); q.breakable()
1104 q.text("duration_sec = ");
1105 q.text("%#x" % self.duration_sec)
1106 q.text(","); q.breakable()
1107 q.text("duration_nsec = ");
1108 q.text("%#x" % self.duration_nsec)
1109 q.text(","); q.breakable()
1110 q.text("priority = ");
1111 q.text("%#x" % self.priority)
1112 q.text(","); q.breakable()
1113 q.text("idle_timeout = ");
1114 q.text("%#x" % self.idle_timeout)
1115 q.text(","); q.breakable()
1116 q.text("hard_timeout = ");
1117 q.text("%#x" % self.hard_timeout)
1118 q.text(","); q.breakable()
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001119 q.text("flags = ");
1120 q.text("%#x" % self.flags)
1121 q.text(","); q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001122 q.text("cookie = ");
1123 q.text("%#x" % self.cookie)
1124 q.text(","); q.breakable()
1125 q.text("packet_count = ");
1126 q.text("%#x" % self.packet_count)
1127 q.text(","); q.breakable()
1128 q.text("byte_count = ");
1129 q.text("%#x" % self.byte_count)
1130 q.text(","); q.breakable()
1131 q.text("match = ");
1132 q.pp(self.match)
1133 q.text(","); q.breakable()
1134 q.text("instructions = ");
1135 q.pp(self.instructions)
1136 q.breakable()
1137 q.text('}')
1138
Rich Lane7dcdf022013-12-11 14:45:27 -08001139
1140class group_desc_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001141
Rich Lane6f4978c2013-10-20 21:33:52 -07001142 def __init__(self, group_type=None, group_id=None, buckets=None):
1143 if group_type != None:
1144 self.group_type = group_type
Rich Lanec2ee4b82013-04-24 17:12:38 -07001145 else:
Rich Lane6f4978c2013-10-20 21:33:52 -07001146 self.group_type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07001147 if group_id != None:
1148 self.group_id = group_id
1149 else:
1150 self.group_id = 0
1151 if buckets != None:
1152 self.buckets = buckets
1153 else:
1154 self.buckets = []
1155 return
1156
1157 def pack(self):
1158 packed = []
1159 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
Rich Lane6f4978c2013-10-20 21:33:52 -07001160 packed.append(struct.pack("!B", self.group_type))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001161 packed.append('\x00' * 1)
1162 packed.append(struct.pack("!L", self.group_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08001163 packed.append(loxi.generic_util.pack_list(self.buckets))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001164 length = sum([len(x) for x in packed])
1165 packed[0] = struct.pack("!H", length)
1166 return ''.join(packed)
1167
1168 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001169 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001170 obj = group_desc_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001171 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001172 orig_reader = reader
1173 reader = orig_reader.slice(_length - (0 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -07001174 obj.group_type = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001175 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -07001176 obj.group_id = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001177 obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001178 return obj
1179
1180 def __eq__(self, other):
1181 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001182 if self.group_type != other.group_type: return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001183 if self.group_id != other.group_id: return False
1184 if self.buckets != other.buckets: return False
1185 return True
1186
Rich Lanec2ee4b82013-04-24 17:12:38 -07001187 def pretty_print(self, q):
1188 q.text("group_desc_stats_entry {")
1189 with q.group():
1190 with q.indent(2):
1191 q.breakable()
Rich Lane6f4978c2013-10-20 21:33:52 -07001192 q.text("group_type = ");
1193 q.text("%#x" % self.group_type)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001194 q.text(","); q.breakable()
1195 q.text("group_id = ");
1196 q.text("%#x" % self.group_id)
1197 q.text(","); q.breakable()
1198 q.text("buckets = ");
1199 q.pp(self.buckets)
1200 q.breakable()
1201 q.text('}')
1202
Rich Lane7dcdf022013-12-11 14:45:27 -08001203
1204class group_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001205
1206 def __init__(self, group_id=None, ref_count=None, packet_count=None, byte_count=None, duration_sec=None, duration_nsec=None, bucket_stats=None):
1207 if group_id != None:
1208 self.group_id = group_id
1209 else:
1210 self.group_id = 0
1211 if ref_count != None:
1212 self.ref_count = ref_count
1213 else:
1214 self.ref_count = 0
1215 if packet_count != None:
1216 self.packet_count = packet_count
1217 else:
1218 self.packet_count = 0
1219 if byte_count != None:
1220 self.byte_count = byte_count
1221 else:
1222 self.byte_count = 0
1223 if duration_sec != None:
1224 self.duration_sec = duration_sec
1225 else:
1226 self.duration_sec = 0
1227 if duration_nsec != None:
1228 self.duration_nsec = duration_nsec
1229 else:
1230 self.duration_nsec = 0
1231 if bucket_stats != None:
1232 self.bucket_stats = bucket_stats
1233 else:
1234 self.bucket_stats = []
1235 return
1236
1237 def pack(self):
1238 packed = []
1239 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
1240 packed.append('\x00' * 2)
1241 packed.append(struct.pack("!L", self.group_id))
1242 packed.append(struct.pack("!L", self.ref_count))
1243 packed.append('\x00' * 4)
1244 packed.append(struct.pack("!Q", self.packet_count))
1245 packed.append(struct.pack("!Q", self.byte_count))
1246 packed.append(struct.pack("!L", self.duration_sec))
1247 packed.append(struct.pack("!L", self.duration_nsec))
Rich Lane7dcdf022013-12-11 14:45:27 -08001248 packed.append(loxi.generic_util.pack_list(self.bucket_stats))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001249 length = sum([len(x) for x in packed])
1250 packed[0] = struct.pack("!H", length)
1251 return ''.join(packed)
1252
1253 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001254 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001255 obj = group_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001256 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001257 orig_reader = reader
1258 reader = orig_reader.slice(_length - (0 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001259 reader.skip(2)
Dan Talaycof6202252013-07-02 01:00:29 -07001260 obj.group_id = reader.read("!L")[0]
1261 obj.ref_count = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001262 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001263 obj.packet_count = reader.read("!Q")[0]
1264 obj.byte_count = reader.read("!Q")[0]
1265 obj.duration_sec = reader.read("!L")[0]
1266 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001267 obj.bucket_stats = loxi.generic_util.unpack_list(reader, common.bucket_counter.unpack)
1268 return obj
1269
1270 def __eq__(self, other):
1271 if type(self) != type(other): return False
1272 if self.group_id != other.group_id: return False
1273 if self.ref_count != other.ref_count: return False
1274 if self.packet_count != other.packet_count: return False
1275 if self.byte_count != other.byte_count: return False
1276 if self.duration_sec != other.duration_sec: return False
1277 if self.duration_nsec != other.duration_nsec: return False
1278 if self.bucket_stats != other.bucket_stats: return False
1279 return True
1280
Rich Lanec2ee4b82013-04-24 17:12:38 -07001281 def pretty_print(self, q):
1282 q.text("group_stats_entry {")
1283 with q.group():
1284 with q.indent(2):
1285 q.breakable()
1286 q.text("group_id = ");
1287 q.text("%#x" % self.group_id)
1288 q.text(","); q.breakable()
1289 q.text("ref_count = ");
1290 q.text("%#x" % self.ref_count)
1291 q.text(","); q.breakable()
1292 q.text("packet_count = ");
1293 q.text("%#x" % self.packet_count)
1294 q.text(","); q.breakable()
1295 q.text("byte_count = ");
1296 q.text("%#x" % self.byte_count)
1297 q.text(","); q.breakable()
1298 q.text("duration_sec = ");
1299 q.text("%#x" % self.duration_sec)
1300 q.text(","); q.breakable()
1301 q.text("duration_nsec = ");
1302 q.text("%#x" % self.duration_nsec)
1303 q.text(","); q.breakable()
1304 q.text("bucket_stats = ");
1305 q.pp(self.bucket_stats)
1306 q.breakable()
1307 q.text('}')
1308
Rich Lane7dcdf022013-12-11 14:45:27 -08001309
1310class hello_elem(loxi.OFObject):
1311 subtypes = {}
1312
1313 @staticmethod
1314 def unpack(reader):
1315 subtype, = reader.peek('!H', 0)
1316 try:
1317 subclass = hello_elem.subtypes[subtype]
1318 except KeyError:
1319 raise loxi.ProtocolError("unknown hello_elem subtype %#x" % subtype)
1320 return subclass.unpack(reader)
1321
1322
1323class hello_elem_versionbitmap(hello_elem):
Dan Talaycof6202252013-07-02 01:00:29 -07001324 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07001325
1326 def __init__(self, bitmaps=None):
1327 if bitmaps != None:
1328 self.bitmaps = bitmaps
1329 else:
1330 self.bitmaps = []
1331 return
1332
1333 def pack(self):
1334 packed = []
1335 packed.append(struct.pack("!H", self.type))
1336 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08001337 packed.append(loxi.generic_util.pack_list(self.bitmaps))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001338 length = sum([len(x) for x in packed])
1339 packed[1] = struct.pack("!H", length)
1340 return ''.join(packed)
1341
1342 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001343 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001344 obj = hello_elem_versionbitmap()
Dan Talaycof6202252013-07-02 01:00:29 -07001345 _type = reader.read("!H")[0]
1346 assert(_type == 1)
1347 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001348 orig_reader = reader
1349 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001350 obj.bitmaps = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
1351 return obj
1352
1353 def __eq__(self, other):
1354 if type(self) != type(other): return False
1355 if self.bitmaps != other.bitmaps: return False
1356 return True
1357
Rich Lanec2ee4b82013-04-24 17:12:38 -07001358 def pretty_print(self, q):
1359 q.text("hello_elem_versionbitmap {")
1360 with q.group():
1361 with q.indent(2):
1362 q.breakable()
1363 q.text("bitmaps = ");
1364 q.pp(self.bitmaps)
1365 q.breakable()
1366 q.text('}')
1367
Rich Lane7dcdf022013-12-11 14:45:27 -08001368hello_elem.subtypes[1] = hello_elem_versionbitmap
1369
1370class match_v3(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001371 type = 1
1372
1373 def __init__(self, oxm_list=None):
1374 if oxm_list != None:
1375 self.oxm_list = oxm_list
1376 else:
1377 self.oxm_list = []
1378 return
1379
1380 def pack(self):
1381 packed = []
1382 packed.append(struct.pack("!H", self.type))
1383 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08001384 packed.append(loxi.generic_util.pack_list(self.oxm_list))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001385 length = sum([len(x) for x in packed])
1386 packed[1] = struct.pack("!H", length)
Rich Laned53156a2013-08-05 17:17:33 -07001387 packed.append(loxi.generic_util.pad_to(8, length))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001388 return ''.join(packed)
1389
1390 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001391 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001392 obj = match_v3()
Dan Talaycof6202252013-07-02 01:00:29 -07001393 _type = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001394 assert(_type == 1)
Dan Talaycof6202252013-07-02 01:00:29 -07001395 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001396 orig_reader = reader
1397 reader = orig_reader.slice(_length - (2 + 2))
1398 obj.oxm_list = loxi.generic_util.unpack_list(reader, oxm.oxm.unpack)
1399 orig_reader.skip_align()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001400 return obj
1401
1402 def __eq__(self, other):
1403 if type(self) != type(other): return False
1404 if self.oxm_list != other.oxm_list: return False
1405 return True
1406
Rich Lanec2ee4b82013-04-24 17:12:38 -07001407 def pretty_print(self, q):
1408 q.text("match_v3 {")
1409 with q.group():
1410 with q.indent(2):
1411 q.breakable()
1412 q.text("oxm_list = ");
1413 q.pp(self.oxm_list)
1414 q.breakable()
1415 q.text('}')
1416
Rich Lane7dcdf022013-12-11 14:45:27 -08001417
1418class meter_band_stats(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001419
1420 def __init__(self, packet_band_count=None, byte_band_count=None):
1421 if packet_band_count != None:
1422 self.packet_band_count = packet_band_count
1423 else:
1424 self.packet_band_count = 0
1425 if byte_band_count != None:
1426 self.byte_band_count = byte_band_count
1427 else:
1428 self.byte_band_count = 0
1429 return
1430
1431 def pack(self):
1432 packed = []
1433 packed.append(struct.pack("!Q", self.packet_band_count))
1434 packed.append(struct.pack("!Q", self.byte_band_count))
1435 return ''.join(packed)
1436
1437 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001438 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001439 obj = meter_band_stats()
Dan Talaycof6202252013-07-02 01:00:29 -07001440 obj.packet_band_count = reader.read("!Q")[0]
1441 obj.byte_band_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001442 return obj
1443
1444 def __eq__(self, other):
1445 if type(self) != type(other): return False
1446 if self.packet_band_count != other.packet_band_count: return False
1447 if self.byte_band_count != other.byte_band_count: return False
1448 return True
1449
Rich Lanec2ee4b82013-04-24 17:12:38 -07001450 def pretty_print(self, q):
1451 q.text("meter_band_stats {")
1452 with q.group():
1453 with q.indent(2):
1454 q.breakable()
1455 q.text("packet_band_count = ");
1456 q.text("%#x" % self.packet_band_count)
1457 q.text(","); q.breakable()
1458 q.text("byte_band_count = ");
1459 q.text("%#x" % self.byte_band_count)
1460 q.breakable()
1461 q.text('}')
1462
Rich Lane7dcdf022013-12-11 14:45:27 -08001463
1464class meter_config(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001465
1466 def __init__(self, flags=None, meter_id=None, entries=None):
1467 if flags != None:
1468 self.flags = flags
1469 else:
1470 self.flags = 0
1471 if meter_id != None:
1472 self.meter_id = meter_id
1473 else:
1474 self.meter_id = 0
1475 if entries != None:
1476 self.entries = entries
1477 else:
1478 self.entries = []
1479 return
1480
1481 def pack(self):
1482 packed = []
1483 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
1484 packed.append(struct.pack("!H", self.flags))
1485 packed.append(struct.pack("!L", self.meter_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08001486 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001487 length = sum([len(x) for x in packed])
1488 packed[0] = struct.pack("!H", length)
1489 return ''.join(packed)
1490
1491 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001492 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001493 obj = meter_config()
Dan Talaycof6202252013-07-02 01:00:29 -07001494 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001495 orig_reader = reader
1496 reader = orig_reader.slice(_length - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001497 obj.flags = reader.read("!H")[0]
1498 obj.meter_id = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001499 obj.entries = loxi.generic_util.unpack_list(reader, meter_band.meter_band.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001500 return obj
1501
1502 def __eq__(self, other):
1503 if type(self) != type(other): return False
1504 if self.flags != other.flags: return False
1505 if self.meter_id != other.meter_id: return False
1506 if self.entries != other.entries: return False
1507 return True
1508
Rich Lanec2ee4b82013-04-24 17:12:38 -07001509 def pretty_print(self, q):
1510 q.text("meter_config {")
1511 with q.group():
1512 with q.indent(2):
1513 q.breakable()
1514 q.text("flags = ");
1515 q.text("%#x" % self.flags)
1516 q.text(","); q.breakable()
1517 q.text("meter_id = ");
1518 q.text("%#x" % self.meter_id)
1519 q.text(","); q.breakable()
1520 q.text("entries = ");
1521 q.pp(self.entries)
1522 q.breakable()
1523 q.text('}')
1524
Rich Lane7dcdf022013-12-11 14:45:27 -08001525
1526class meter_features(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001527
1528 def __init__(self, max_meter=None, band_types=None, capabilities=None, max_bands=None, max_color=None):
1529 if max_meter != None:
1530 self.max_meter = max_meter
1531 else:
1532 self.max_meter = 0
1533 if band_types != None:
1534 self.band_types = band_types
1535 else:
1536 self.band_types = 0
1537 if capabilities != None:
1538 self.capabilities = capabilities
1539 else:
1540 self.capabilities = 0
1541 if max_bands != None:
1542 self.max_bands = max_bands
1543 else:
1544 self.max_bands = 0
1545 if max_color != None:
1546 self.max_color = max_color
1547 else:
1548 self.max_color = 0
1549 return
1550
1551 def pack(self):
1552 packed = []
1553 packed.append(struct.pack("!L", self.max_meter))
1554 packed.append(struct.pack("!L", self.band_types))
1555 packed.append(struct.pack("!L", self.capabilities))
1556 packed.append(struct.pack("!B", self.max_bands))
1557 packed.append(struct.pack("!B", self.max_color))
1558 packed.append('\x00' * 2)
1559 return ''.join(packed)
1560
1561 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001562 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001563 obj = meter_features()
Dan Talaycof6202252013-07-02 01:00:29 -07001564 obj.max_meter = reader.read("!L")[0]
1565 obj.band_types = reader.read("!L")[0]
1566 obj.capabilities = reader.read("!L")[0]
1567 obj.max_bands = reader.read("!B")[0]
1568 obj.max_color = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001569 reader.skip(2)
1570 return obj
1571
1572 def __eq__(self, other):
1573 if type(self) != type(other): return False
1574 if self.max_meter != other.max_meter: return False
1575 if self.band_types != other.band_types: return False
1576 if self.capabilities != other.capabilities: return False
1577 if self.max_bands != other.max_bands: return False
1578 if self.max_color != other.max_color: return False
1579 return True
1580
Rich Lanec2ee4b82013-04-24 17:12:38 -07001581 def pretty_print(self, q):
1582 q.text("meter_features {")
1583 with q.group():
1584 with q.indent(2):
1585 q.breakable()
1586 q.text("max_meter = ");
1587 q.text("%#x" % self.max_meter)
1588 q.text(","); q.breakable()
1589 q.text("band_types = ");
1590 q.text("%#x" % self.band_types)
1591 q.text(","); q.breakable()
1592 q.text("capabilities = ");
1593 q.text("%#x" % self.capabilities)
1594 q.text(","); q.breakable()
1595 q.text("max_bands = ");
1596 q.text("%#x" % self.max_bands)
1597 q.text(","); q.breakable()
1598 q.text("max_color = ");
1599 q.text("%#x" % self.max_color)
1600 q.breakable()
1601 q.text('}')
1602
Rich Lane7dcdf022013-12-11 14:45:27 -08001603
1604class meter_stats(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001605
1606 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):
1607 if meter_id != None:
1608 self.meter_id = meter_id
1609 else:
1610 self.meter_id = 0
1611 if flow_count != None:
1612 self.flow_count = flow_count
1613 else:
1614 self.flow_count = 0
1615 if packet_in_count != None:
1616 self.packet_in_count = packet_in_count
1617 else:
1618 self.packet_in_count = 0
1619 if byte_in_count != None:
1620 self.byte_in_count = byte_in_count
1621 else:
1622 self.byte_in_count = 0
1623 if duration_sec != None:
1624 self.duration_sec = duration_sec
1625 else:
1626 self.duration_sec = 0
1627 if duration_nsec != None:
1628 self.duration_nsec = duration_nsec
1629 else:
1630 self.duration_nsec = 0
1631 if band_stats != None:
1632 self.band_stats = band_stats
1633 else:
1634 self.band_stats = []
1635 return
1636
1637 def pack(self):
1638 packed = []
1639 packed.append(struct.pack("!L", self.meter_id))
1640 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1641 packed.append('\x00' * 6)
1642 packed.append(struct.pack("!L", self.flow_count))
1643 packed.append(struct.pack("!Q", self.packet_in_count))
1644 packed.append(struct.pack("!Q", self.byte_in_count))
1645 packed.append(struct.pack("!L", self.duration_sec))
1646 packed.append(struct.pack("!L", self.duration_nsec))
Rich Lane7dcdf022013-12-11 14:45:27 -08001647 packed.append(loxi.generic_util.pack_list(self.band_stats))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001648 length = sum([len(x) for x in packed])
1649 packed[1] = struct.pack("!H", length)
1650 return ''.join(packed)
1651
1652 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001653 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001654 obj = meter_stats()
Dan Talaycof6202252013-07-02 01:00:29 -07001655 obj.meter_id = reader.read("!L")[0]
1656 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001657 orig_reader = reader
1658 reader = orig_reader.slice(_len - (4 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001659 reader.skip(6)
Dan Talaycof6202252013-07-02 01:00:29 -07001660 obj.flow_count = reader.read("!L")[0]
1661 obj.packet_in_count = reader.read("!Q")[0]
1662 obj.byte_in_count = reader.read("!Q")[0]
1663 obj.duration_sec = reader.read("!L")[0]
1664 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001665 obj.band_stats = loxi.generic_util.unpack_list(reader, common.meter_band_stats.unpack)
1666 return obj
1667
1668 def __eq__(self, other):
1669 if type(self) != type(other): return False
1670 if self.meter_id != other.meter_id: return False
1671 if self.flow_count != other.flow_count: return False
1672 if self.packet_in_count != other.packet_in_count: return False
1673 if self.byte_in_count != other.byte_in_count: return False
1674 if self.duration_sec != other.duration_sec: return False
1675 if self.duration_nsec != other.duration_nsec: return False
1676 if self.band_stats != other.band_stats: return False
1677 return True
1678
Rich Lanec2ee4b82013-04-24 17:12:38 -07001679 def pretty_print(self, q):
1680 q.text("meter_stats {")
1681 with q.group():
1682 with q.indent(2):
1683 q.breakable()
1684 q.text("meter_id = ");
1685 q.text("%#x" % self.meter_id)
1686 q.text(","); q.breakable()
1687 q.text("flow_count = ");
1688 q.text("%#x" % self.flow_count)
1689 q.text(","); q.breakable()
1690 q.text("packet_in_count = ");
1691 q.text("%#x" % self.packet_in_count)
1692 q.text(","); q.breakable()
1693 q.text("byte_in_count = ");
1694 q.text("%#x" % self.byte_in_count)
1695 q.text(","); q.breakable()
1696 q.text("duration_sec = ");
1697 q.text("%#x" % self.duration_sec)
1698 q.text(","); q.breakable()
1699 q.text("duration_nsec = ");
1700 q.text("%#x" % self.duration_nsec)
1701 q.text(","); q.breakable()
1702 q.text("band_stats = ");
1703 q.pp(self.band_stats)
1704 q.breakable()
1705 q.text('}')
1706
Rich Lane7dcdf022013-12-11 14:45:27 -08001707
1708class packet_queue(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001709
1710 def __init__(self, queue_id=None, port=None, properties=None):
1711 if queue_id != None:
1712 self.queue_id = queue_id
1713 else:
1714 self.queue_id = 0
1715 if port != None:
1716 self.port = port
1717 else:
1718 self.port = 0
1719 if properties != None:
1720 self.properties = properties
1721 else:
1722 self.properties = []
1723 return
1724
1725 def pack(self):
1726 packed = []
1727 packed.append(struct.pack("!L", self.queue_id))
Dan Talaycof6202252013-07-02 01:00:29 -07001728 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001729 packed.append(struct.pack("!H", 0)) # placeholder for len at index 2
1730 packed.append('\x00' * 6)
Rich Lane7dcdf022013-12-11 14:45:27 -08001731 packed.append(loxi.generic_util.pack_list(self.properties))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001732 length = sum([len(x) for x in packed])
1733 packed[2] = struct.pack("!H", length)
1734 return ''.join(packed)
1735
1736 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001737 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001738 obj = packet_queue()
Dan Talaycof6202252013-07-02 01:00:29 -07001739 obj.queue_id = reader.read("!L")[0]
1740 obj.port = util.unpack_port_no(reader)
1741 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001742 orig_reader = reader
1743 reader = orig_reader.slice(_len - (8 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001744 reader.skip(6)
Rich Lane7dcdf022013-12-11 14:45:27 -08001745 obj.properties = loxi.generic_util.unpack_list(reader, common.queue_prop.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001746 return obj
1747
1748 def __eq__(self, other):
1749 if type(self) != type(other): return False
1750 if self.queue_id != other.queue_id: return False
1751 if self.port != other.port: return False
1752 if self.properties != other.properties: return False
1753 return True
1754
Rich Lanec2ee4b82013-04-24 17:12:38 -07001755 def pretty_print(self, q):
1756 q.text("packet_queue {")
1757 with q.group():
1758 with q.indent(2):
1759 q.breakable()
1760 q.text("queue_id = ");
1761 q.text("%#x" % self.queue_id)
1762 q.text(","); q.breakable()
1763 q.text("port = ");
1764 q.text(util.pretty_port(self.port))
1765 q.text(","); q.breakable()
1766 q.text("properties = ");
1767 q.pp(self.properties)
1768 q.breakable()
1769 q.text('}')
1770
Rich Lane7dcdf022013-12-11 14:45:27 -08001771
1772class port_desc(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001773
1774 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):
1775 if port_no != None:
1776 self.port_no = port_no
1777 else:
1778 self.port_no = 0
1779 if hw_addr != None:
1780 self.hw_addr = hw_addr
1781 else:
1782 self.hw_addr = [0,0,0,0,0,0]
1783 if name != None:
1784 self.name = name
1785 else:
1786 self.name = ""
1787 if config != None:
1788 self.config = config
1789 else:
1790 self.config = 0
1791 if state != None:
1792 self.state = state
1793 else:
1794 self.state = 0
1795 if curr != None:
1796 self.curr = curr
1797 else:
1798 self.curr = 0
1799 if advertised != None:
1800 self.advertised = advertised
1801 else:
1802 self.advertised = 0
1803 if supported != None:
1804 self.supported = supported
1805 else:
1806 self.supported = 0
1807 if peer != None:
1808 self.peer = peer
1809 else:
1810 self.peer = 0
1811 if curr_speed != None:
1812 self.curr_speed = curr_speed
1813 else:
1814 self.curr_speed = 0
1815 if max_speed != None:
1816 self.max_speed = max_speed
1817 else:
1818 self.max_speed = 0
1819 return
1820
1821 def pack(self):
1822 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07001823 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001824 packed.append('\x00' * 4)
1825 packed.append(struct.pack("!6B", *self.hw_addr))
1826 packed.append('\x00' * 2)
1827 packed.append(struct.pack("!16s", self.name))
1828 packed.append(struct.pack("!L", self.config))
1829 packed.append(struct.pack("!L", self.state))
1830 packed.append(struct.pack("!L", self.curr))
1831 packed.append(struct.pack("!L", self.advertised))
1832 packed.append(struct.pack("!L", self.supported))
1833 packed.append(struct.pack("!L", self.peer))
1834 packed.append(struct.pack("!L", self.curr_speed))
1835 packed.append(struct.pack("!L", self.max_speed))
1836 return ''.join(packed)
1837
1838 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001839 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001840 obj = port_desc()
Dan Talaycof6202252013-07-02 01:00:29 -07001841 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001842 reader.skip(4)
1843 obj.hw_addr = list(reader.read('!6B'))
1844 reader.skip(2)
1845 obj.name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -07001846 obj.config = reader.read("!L")[0]
1847 obj.state = reader.read("!L")[0]
1848 obj.curr = reader.read("!L")[0]
1849 obj.advertised = reader.read("!L")[0]
1850 obj.supported = reader.read("!L")[0]
1851 obj.peer = reader.read("!L")[0]
1852 obj.curr_speed = reader.read("!L")[0]
1853 obj.max_speed = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001854 return obj
1855
1856 def __eq__(self, other):
1857 if type(self) != type(other): return False
1858 if self.port_no != other.port_no: return False
1859 if self.hw_addr != other.hw_addr: return False
1860 if self.name != other.name: return False
1861 if self.config != other.config: return False
1862 if self.state != other.state: return False
1863 if self.curr != other.curr: return False
1864 if self.advertised != other.advertised: return False
1865 if self.supported != other.supported: return False
1866 if self.peer != other.peer: return False
1867 if self.curr_speed != other.curr_speed: return False
1868 if self.max_speed != other.max_speed: return False
1869 return True
1870
Rich Lanec2ee4b82013-04-24 17:12:38 -07001871 def pretty_print(self, q):
1872 q.text("port_desc {")
1873 with q.group():
1874 with q.indent(2):
1875 q.breakable()
1876 q.text("port_no = ");
1877 q.text(util.pretty_port(self.port_no))
1878 q.text(","); q.breakable()
1879 q.text("hw_addr = ");
1880 q.text(util.pretty_mac(self.hw_addr))
1881 q.text(","); q.breakable()
1882 q.text("name = ");
1883 q.pp(self.name)
1884 q.text(","); q.breakable()
1885 q.text("config = ");
1886 q.text("%#x" % self.config)
1887 q.text(","); q.breakable()
1888 q.text("state = ");
1889 q.text("%#x" % self.state)
1890 q.text(","); q.breakable()
1891 q.text("curr = ");
1892 q.text("%#x" % self.curr)
1893 q.text(","); q.breakable()
1894 q.text("advertised = ");
1895 q.text("%#x" % self.advertised)
1896 q.text(","); q.breakable()
1897 q.text("supported = ");
1898 q.text("%#x" % self.supported)
1899 q.text(","); q.breakable()
1900 q.text("peer = ");
1901 q.text("%#x" % self.peer)
1902 q.text(","); q.breakable()
1903 q.text("curr_speed = ");
1904 q.text("%#x" % self.curr_speed)
1905 q.text(","); q.breakable()
1906 q.text("max_speed = ");
1907 q.text("%#x" % self.max_speed)
1908 q.breakable()
1909 q.text('}')
1910
Rich Lane7dcdf022013-12-11 14:45:27 -08001911
1912class port_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001913
1914 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):
1915 if port_no != None:
1916 self.port_no = port_no
1917 else:
1918 self.port_no = 0
1919 if rx_packets != None:
1920 self.rx_packets = rx_packets
1921 else:
1922 self.rx_packets = 0
1923 if tx_packets != None:
1924 self.tx_packets = tx_packets
1925 else:
1926 self.tx_packets = 0
1927 if rx_bytes != None:
1928 self.rx_bytes = rx_bytes
1929 else:
1930 self.rx_bytes = 0
1931 if tx_bytes != None:
1932 self.tx_bytes = tx_bytes
1933 else:
1934 self.tx_bytes = 0
1935 if rx_dropped != None:
1936 self.rx_dropped = rx_dropped
1937 else:
1938 self.rx_dropped = 0
1939 if tx_dropped != None:
1940 self.tx_dropped = tx_dropped
1941 else:
1942 self.tx_dropped = 0
1943 if rx_errors != None:
1944 self.rx_errors = rx_errors
1945 else:
1946 self.rx_errors = 0
1947 if tx_errors != None:
1948 self.tx_errors = tx_errors
1949 else:
1950 self.tx_errors = 0
1951 if rx_frame_err != None:
1952 self.rx_frame_err = rx_frame_err
1953 else:
1954 self.rx_frame_err = 0
1955 if rx_over_err != None:
1956 self.rx_over_err = rx_over_err
1957 else:
1958 self.rx_over_err = 0
1959 if rx_crc_err != None:
1960 self.rx_crc_err = rx_crc_err
1961 else:
1962 self.rx_crc_err = 0
1963 if collisions != None:
1964 self.collisions = collisions
1965 else:
1966 self.collisions = 0
1967 if duration_sec != None:
1968 self.duration_sec = duration_sec
1969 else:
1970 self.duration_sec = 0
1971 if duration_nsec != None:
1972 self.duration_nsec = duration_nsec
1973 else:
1974 self.duration_nsec = 0
1975 return
1976
1977 def pack(self):
1978 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07001979 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001980 packed.append('\x00' * 4)
1981 packed.append(struct.pack("!Q", self.rx_packets))
1982 packed.append(struct.pack("!Q", self.tx_packets))
1983 packed.append(struct.pack("!Q", self.rx_bytes))
1984 packed.append(struct.pack("!Q", self.tx_bytes))
1985 packed.append(struct.pack("!Q", self.rx_dropped))
1986 packed.append(struct.pack("!Q", self.tx_dropped))
1987 packed.append(struct.pack("!Q", self.rx_errors))
1988 packed.append(struct.pack("!Q", self.tx_errors))
1989 packed.append(struct.pack("!Q", self.rx_frame_err))
1990 packed.append(struct.pack("!Q", self.rx_over_err))
1991 packed.append(struct.pack("!Q", self.rx_crc_err))
1992 packed.append(struct.pack("!Q", self.collisions))
1993 packed.append(struct.pack("!L", self.duration_sec))
1994 packed.append(struct.pack("!L", self.duration_nsec))
1995 return ''.join(packed)
1996
1997 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001998 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001999 obj = port_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07002000 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002001 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07002002 obj.rx_packets = reader.read("!Q")[0]
2003 obj.tx_packets = reader.read("!Q")[0]
2004 obj.rx_bytes = reader.read("!Q")[0]
2005 obj.tx_bytes = reader.read("!Q")[0]
2006 obj.rx_dropped = reader.read("!Q")[0]
2007 obj.tx_dropped = reader.read("!Q")[0]
2008 obj.rx_errors = reader.read("!Q")[0]
2009 obj.tx_errors = reader.read("!Q")[0]
2010 obj.rx_frame_err = reader.read("!Q")[0]
2011 obj.rx_over_err = reader.read("!Q")[0]
2012 obj.rx_crc_err = reader.read("!Q")[0]
2013 obj.collisions = reader.read("!Q")[0]
2014 obj.duration_sec = reader.read("!L")[0]
2015 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002016 return obj
2017
2018 def __eq__(self, other):
2019 if type(self) != type(other): return False
2020 if self.port_no != other.port_no: return False
2021 if self.rx_packets != other.rx_packets: return False
2022 if self.tx_packets != other.tx_packets: return False
2023 if self.rx_bytes != other.rx_bytes: return False
2024 if self.tx_bytes != other.tx_bytes: return False
2025 if self.rx_dropped != other.rx_dropped: return False
2026 if self.tx_dropped != other.tx_dropped: return False
2027 if self.rx_errors != other.rx_errors: return False
2028 if self.tx_errors != other.tx_errors: return False
2029 if self.rx_frame_err != other.rx_frame_err: return False
2030 if self.rx_over_err != other.rx_over_err: return False
2031 if self.rx_crc_err != other.rx_crc_err: return False
2032 if self.collisions != other.collisions: return False
2033 if self.duration_sec != other.duration_sec: return False
2034 if self.duration_nsec != other.duration_nsec: return False
2035 return True
2036
Rich Lanec2ee4b82013-04-24 17:12:38 -07002037 def pretty_print(self, q):
2038 q.text("port_stats_entry {")
2039 with q.group():
2040 with q.indent(2):
2041 q.breakable()
2042 q.text("port_no = ");
2043 q.text(util.pretty_port(self.port_no))
2044 q.text(","); q.breakable()
2045 q.text("rx_packets = ");
2046 q.text("%#x" % self.rx_packets)
2047 q.text(","); q.breakable()
2048 q.text("tx_packets = ");
2049 q.text("%#x" % self.tx_packets)
2050 q.text(","); q.breakable()
2051 q.text("rx_bytes = ");
2052 q.text("%#x" % self.rx_bytes)
2053 q.text(","); q.breakable()
2054 q.text("tx_bytes = ");
2055 q.text("%#x" % self.tx_bytes)
2056 q.text(","); q.breakable()
2057 q.text("rx_dropped = ");
2058 q.text("%#x" % self.rx_dropped)
2059 q.text(","); q.breakable()
2060 q.text("tx_dropped = ");
2061 q.text("%#x" % self.tx_dropped)
2062 q.text(","); q.breakable()
2063 q.text("rx_errors = ");
2064 q.text("%#x" % self.rx_errors)
2065 q.text(","); q.breakable()
2066 q.text("tx_errors = ");
2067 q.text("%#x" % self.tx_errors)
2068 q.text(","); q.breakable()
2069 q.text("rx_frame_err = ");
2070 q.text("%#x" % self.rx_frame_err)
2071 q.text(","); q.breakable()
2072 q.text("rx_over_err = ");
2073 q.text("%#x" % self.rx_over_err)
2074 q.text(","); q.breakable()
2075 q.text("rx_crc_err = ");
2076 q.text("%#x" % self.rx_crc_err)
2077 q.text(","); q.breakable()
2078 q.text("collisions = ");
2079 q.text("%#x" % self.collisions)
2080 q.text(","); q.breakable()
2081 q.text("duration_sec = ");
2082 q.text("%#x" % self.duration_sec)
2083 q.text(","); q.breakable()
2084 q.text("duration_nsec = ");
2085 q.text("%#x" % self.duration_nsec)
2086 q.breakable()
2087 q.text('}')
2088
Rich Lane7dcdf022013-12-11 14:45:27 -08002089
2090class queue_prop(loxi.OFObject):
2091 subtypes = {}
2092
2093 @staticmethod
2094 def unpack(reader):
2095 subtype, = reader.peek('!H', 0)
2096 try:
2097 subclass = queue_prop.subtypes[subtype]
2098 except KeyError:
2099 raise loxi.ProtocolError("unknown queue_prop subtype %#x" % subtype)
2100 return subclass.unpack(reader)
2101
2102
2103class queue_prop_experimenter(queue_prop):
2104 subtypes = {}
2105
2106 @staticmethod
2107 def unpack(reader):
2108 subtype, = reader.peek('!L', 8)
2109 try:
2110 subclass = queue_prop_experimenter.subtypes[subtype]
2111 except KeyError:
2112 raise loxi.ProtocolError("unknown queue_prop_experimenter queue_prop subtype %#x" % subtype)
2113 return subclass.unpack(reader)
2114
2115queue_prop.subtypes[65535] = queue_prop_experimenter
2116
2117class queue_prop_max_rate(queue_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002118 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07002119
2120 def __init__(self, rate=None):
2121 if rate != None:
2122 self.rate = rate
2123 else:
2124 self.rate = 0
2125 return
2126
2127 def pack(self):
2128 packed = []
2129 packed.append(struct.pack("!H", self.type))
2130 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2131 packed.append('\x00' * 4)
2132 packed.append(struct.pack("!H", self.rate))
2133 packed.append('\x00' * 6)
2134 length = sum([len(x) for x in packed])
2135 packed[1] = struct.pack("!H", length)
2136 return ''.join(packed)
2137
2138 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002139 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002140 obj = queue_prop_max_rate()
Dan Talaycof6202252013-07-02 01:00:29 -07002141 _type = reader.read("!H")[0]
2142 assert(_type == 2)
2143 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002144 orig_reader = reader
2145 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002146 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07002147 obj.rate = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002148 reader.skip(6)
2149 return obj
2150
2151 def __eq__(self, other):
2152 if type(self) != type(other): return False
2153 if self.rate != other.rate: return False
2154 return True
2155
Rich Lanec2ee4b82013-04-24 17:12:38 -07002156 def pretty_print(self, q):
2157 q.text("queue_prop_max_rate {")
2158 with q.group():
2159 with q.indent(2):
2160 q.breakable()
2161 q.text("rate = ");
2162 q.text("%#x" % self.rate)
2163 q.breakable()
2164 q.text('}')
2165
Rich Lane7dcdf022013-12-11 14:45:27 -08002166queue_prop.subtypes[2] = queue_prop_max_rate
2167
2168class queue_prop_min_rate(queue_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002169 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07002170
2171 def __init__(self, rate=None):
2172 if rate != None:
2173 self.rate = rate
2174 else:
2175 self.rate = 0
2176 return
2177
2178 def pack(self):
2179 packed = []
2180 packed.append(struct.pack("!H", self.type))
2181 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2182 packed.append('\x00' * 4)
2183 packed.append(struct.pack("!H", self.rate))
2184 packed.append('\x00' * 6)
2185 length = sum([len(x) for x in packed])
2186 packed[1] = struct.pack("!H", length)
2187 return ''.join(packed)
2188
2189 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002190 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002191 obj = queue_prop_min_rate()
Dan Talaycof6202252013-07-02 01:00:29 -07002192 _type = reader.read("!H")[0]
2193 assert(_type == 1)
2194 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002195 orig_reader = reader
2196 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002197 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07002198 obj.rate = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002199 reader.skip(6)
2200 return obj
2201
2202 def __eq__(self, other):
2203 if type(self) != type(other): return False
2204 if self.rate != other.rate: return False
2205 return True
2206
Rich Lanec2ee4b82013-04-24 17:12:38 -07002207 def pretty_print(self, q):
2208 q.text("queue_prop_min_rate {")
2209 with q.group():
2210 with q.indent(2):
2211 q.breakable()
2212 q.text("rate = ");
2213 q.text("%#x" % self.rate)
2214 q.breakable()
2215 q.text('}')
2216
Rich Lane7dcdf022013-12-11 14:45:27 -08002217queue_prop.subtypes[1] = queue_prop_min_rate
2218
2219class queue_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002220
2221 def __init__(self, port_no=None, queue_id=None, tx_bytes=None, tx_packets=None, tx_errors=None, duration_sec=None, duration_nsec=None):
2222 if port_no != None:
2223 self.port_no = port_no
2224 else:
2225 self.port_no = 0
2226 if queue_id != None:
2227 self.queue_id = queue_id
2228 else:
2229 self.queue_id = 0
2230 if tx_bytes != None:
2231 self.tx_bytes = tx_bytes
2232 else:
2233 self.tx_bytes = 0
2234 if tx_packets != None:
2235 self.tx_packets = tx_packets
2236 else:
2237 self.tx_packets = 0
2238 if tx_errors != None:
2239 self.tx_errors = tx_errors
2240 else:
2241 self.tx_errors = 0
2242 if duration_sec != None:
2243 self.duration_sec = duration_sec
2244 else:
2245 self.duration_sec = 0
2246 if duration_nsec != None:
2247 self.duration_nsec = duration_nsec
2248 else:
2249 self.duration_nsec = 0
2250 return
2251
2252 def pack(self):
2253 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07002254 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002255 packed.append(struct.pack("!L", self.queue_id))
2256 packed.append(struct.pack("!Q", self.tx_bytes))
2257 packed.append(struct.pack("!Q", self.tx_packets))
2258 packed.append(struct.pack("!Q", self.tx_errors))
2259 packed.append(struct.pack("!L", self.duration_sec))
2260 packed.append(struct.pack("!L", self.duration_nsec))
2261 return ''.join(packed)
2262
2263 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002264 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002265 obj = queue_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07002266 obj.port_no = util.unpack_port_no(reader)
2267 obj.queue_id = reader.read("!L")[0]
2268 obj.tx_bytes = reader.read("!Q")[0]
2269 obj.tx_packets = reader.read("!Q")[0]
2270 obj.tx_errors = reader.read("!Q")[0]
2271 obj.duration_sec = reader.read("!L")[0]
2272 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002273 return obj
2274
2275 def __eq__(self, other):
2276 if type(self) != type(other): return False
2277 if self.port_no != other.port_no: return False
2278 if self.queue_id != other.queue_id: return False
2279 if self.tx_bytes != other.tx_bytes: return False
2280 if self.tx_packets != other.tx_packets: return False
2281 if self.tx_errors != other.tx_errors: return False
2282 if self.duration_sec != other.duration_sec: return False
2283 if self.duration_nsec != other.duration_nsec: return False
2284 return True
2285
Rich Lanec2ee4b82013-04-24 17:12:38 -07002286 def pretty_print(self, q):
2287 q.text("queue_stats_entry {")
2288 with q.group():
2289 with q.indent(2):
2290 q.breakable()
2291 q.text("port_no = ");
2292 q.text(util.pretty_port(self.port_no))
2293 q.text(","); q.breakable()
2294 q.text("queue_id = ");
2295 q.text("%#x" % self.queue_id)
2296 q.text(","); q.breakable()
2297 q.text("tx_bytes = ");
2298 q.text("%#x" % self.tx_bytes)
2299 q.text(","); q.breakable()
2300 q.text("tx_packets = ");
2301 q.text("%#x" % self.tx_packets)
2302 q.text(","); q.breakable()
2303 q.text("tx_errors = ");
2304 q.text("%#x" % self.tx_errors)
2305 q.text(","); q.breakable()
2306 q.text("duration_sec = ");
2307 q.text("%#x" % self.duration_sec)
2308 q.text(","); q.breakable()
2309 q.text("duration_nsec = ");
2310 q.text("%#x" % self.duration_nsec)
2311 q.breakable()
2312 q.text('}')
2313
Rich Lane7dcdf022013-12-11 14:45:27 -08002314
2315class table_feature_prop(loxi.OFObject):
2316 subtypes = {}
2317
2318 @staticmethod
2319 def unpack(reader):
2320 subtype, = reader.peek('!H', 0)
2321 try:
2322 subclass = table_feature_prop.subtypes[subtype]
2323 except KeyError:
2324 raise loxi.ProtocolError("unknown table_feature_prop subtype %#x" % subtype)
2325 return subclass.unpack(reader)
2326
2327
2328class table_feature_prop_apply_actions(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002329 type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07002330
Dan Talaycof6202252013-07-02 01:00:29 -07002331 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002332 if action_ids != None:
2333 self.action_ids = action_ids
2334 else:
2335 self.action_ids = []
2336 return
2337
2338 def pack(self):
2339 packed = []
2340 packed.append(struct.pack("!H", self.type))
2341 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002342 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002343 length = sum([len(x) for x in packed])
2344 packed[1] = struct.pack("!H", length)
2345 return ''.join(packed)
2346
2347 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002348 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002349 obj = table_feature_prop_apply_actions()
Dan Talaycof6202252013-07-02 01:00:29 -07002350 _type = reader.read("!H")[0]
2351 assert(_type == 6)
2352 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002353 orig_reader = reader
2354 reader = orig_reader.slice(_length - (2 + 2))
2355 obj.action_ids = loxi.generic_util.unpack_list(reader, action_id.action_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002356 return obj
2357
2358 def __eq__(self, other):
2359 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002360 if self.action_ids != other.action_ids: return False
2361 return True
2362
Rich Lanec2ee4b82013-04-24 17:12:38 -07002363 def pretty_print(self, q):
2364 q.text("table_feature_prop_apply_actions {")
2365 with q.group():
2366 with q.indent(2):
2367 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002368 q.text("action_ids = ");
2369 q.pp(self.action_ids)
2370 q.breakable()
2371 q.text('}')
2372
Rich Lane7dcdf022013-12-11 14:45:27 -08002373table_feature_prop.subtypes[6] = table_feature_prop_apply_actions
2374
2375class table_feature_prop_apply_actions_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002376 type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07002377
Dan Talaycof6202252013-07-02 01:00:29 -07002378 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002379 if action_ids != None:
2380 self.action_ids = action_ids
2381 else:
2382 self.action_ids = []
2383 return
2384
2385 def pack(self):
2386 packed = []
2387 packed.append(struct.pack("!H", self.type))
2388 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002389 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002390 length = sum([len(x) for x in packed])
2391 packed[1] = struct.pack("!H", length)
2392 return ''.join(packed)
2393
2394 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002395 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002396 obj = table_feature_prop_apply_actions_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07002397 _type = reader.read("!H")[0]
2398 assert(_type == 7)
2399 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002400 orig_reader = reader
2401 reader = orig_reader.slice(_length - (2 + 2))
2402 obj.action_ids = loxi.generic_util.unpack_list(reader, action_id.action_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002403 return obj
2404
2405 def __eq__(self, other):
2406 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002407 if self.action_ids != other.action_ids: return False
2408 return True
2409
Rich Lanec2ee4b82013-04-24 17:12:38 -07002410 def pretty_print(self, q):
2411 q.text("table_feature_prop_apply_actions_miss {")
2412 with q.group():
2413 with q.indent(2):
2414 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002415 q.text("action_ids = ");
2416 q.pp(self.action_ids)
2417 q.breakable()
2418 q.text('}')
2419
Rich Lane7dcdf022013-12-11 14:45:27 -08002420table_feature_prop.subtypes[7] = table_feature_prop_apply_actions_miss
2421
2422class table_feature_prop_apply_setfield(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002423 type = 14
Rich Lanec2ee4b82013-04-24 17:12:38 -07002424
Dan Talaycof6202252013-07-02 01:00:29 -07002425 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002426 if oxm_ids != None:
2427 self.oxm_ids = oxm_ids
2428 else:
2429 self.oxm_ids = []
2430 return
2431
2432 def pack(self):
2433 packed = []
2434 packed.append(struct.pack("!H", self.type))
2435 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002436 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002437 length = sum([len(x) for x in packed])
2438 packed[1] = struct.pack("!H", length)
2439 return ''.join(packed)
2440
2441 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002442 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002443 obj = table_feature_prop_apply_setfield()
Dan Talaycof6202252013-07-02 01:00:29 -07002444 _type = reader.read("!H")[0]
2445 assert(_type == 14)
2446 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002447 orig_reader = reader
2448 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002449 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
2450 return obj
2451
2452 def __eq__(self, other):
2453 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002454 if self.oxm_ids != other.oxm_ids: return False
2455 return True
2456
Rich Lanec2ee4b82013-04-24 17:12:38 -07002457 def pretty_print(self, q):
2458 q.text("table_feature_prop_apply_setfield {")
2459 with q.group():
2460 with q.indent(2):
2461 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002462 q.text("oxm_ids = ");
2463 q.pp(self.oxm_ids)
2464 q.breakable()
2465 q.text('}')
2466
Rich Lane7dcdf022013-12-11 14:45:27 -08002467table_feature_prop.subtypes[14] = table_feature_prop_apply_setfield
2468
2469class table_feature_prop_apply_setfield_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002470 type = 15
Rich Lanec2ee4b82013-04-24 17:12:38 -07002471
Dan Talaycof6202252013-07-02 01:00:29 -07002472 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002473 if oxm_ids != None:
2474 self.oxm_ids = oxm_ids
2475 else:
2476 self.oxm_ids = []
2477 return
2478
2479 def pack(self):
2480 packed = []
2481 packed.append(struct.pack("!H", self.type))
2482 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002483 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002484 length = sum([len(x) for x in packed])
2485 packed[1] = struct.pack("!H", length)
2486 return ''.join(packed)
2487
2488 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002489 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002490 obj = table_feature_prop_apply_setfield_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07002491 _type = reader.read("!H")[0]
2492 assert(_type == 15)
2493 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002494 orig_reader = reader
2495 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002496 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
2497 return obj
2498
2499 def __eq__(self, other):
2500 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002501 if self.oxm_ids != other.oxm_ids: return False
2502 return True
2503
Rich Lanec2ee4b82013-04-24 17:12:38 -07002504 def pretty_print(self, q):
2505 q.text("table_feature_prop_apply_setfield_miss {")
2506 with q.group():
2507 with q.indent(2):
2508 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002509 q.text("oxm_ids = ");
2510 q.pp(self.oxm_ids)
2511 q.breakable()
2512 q.text('}')
2513
Rich Lane7dcdf022013-12-11 14:45:27 -08002514table_feature_prop.subtypes[15] = table_feature_prop_apply_setfield_miss
2515
2516class table_feature_prop_experimenter(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002517 type = 65535
Rich Lanec2ee4b82013-04-24 17:12:38 -07002518
Dan Talaycof6202252013-07-02 01:00:29 -07002519 def __init__(self, experimenter=None, subtype=None, experimenter_data=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002520 if experimenter != None:
2521 self.experimenter = experimenter
2522 else:
2523 self.experimenter = 0
2524 if subtype != None:
2525 self.subtype = subtype
2526 else:
2527 self.subtype = 0
2528 if experimenter_data != None:
2529 self.experimenter_data = experimenter_data
2530 else:
Dan Talaycof6202252013-07-02 01:00:29 -07002531 self.experimenter_data = ''
Rich Lanec2ee4b82013-04-24 17:12:38 -07002532 return
2533
2534 def pack(self):
2535 packed = []
2536 packed.append(struct.pack("!H", self.type))
2537 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
2538 packed.append(struct.pack("!L", self.experimenter))
2539 packed.append(struct.pack("!L", self.subtype))
2540 packed.append(self.experimenter_data)
2541 length = sum([len(x) for x in packed])
2542 packed[1] = struct.pack("!H", length)
2543 return ''.join(packed)
2544
2545 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002546 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002547 obj = table_feature_prop_experimenter()
Dan Talaycof6202252013-07-02 01:00:29 -07002548 _type = reader.read("!H")[0]
2549 assert(_type == 65535)
2550 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002551 orig_reader = reader
2552 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002553 obj.experimenter = reader.read("!L")[0]
2554 obj.subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002555 obj.experimenter_data = str(reader.read_all())
2556 return obj
2557
2558 def __eq__(self, other):
2559 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002560 if self.experimenter != other.experimenter: return False
2561 if self.subtype != other.subtype: return False
2562 if self.experimenter_data != other.experimenter_data: return False
2563 return True
2564
Rich Lanec2ee4b82013-04-24 17:12:38 -07002565 def pretty_print(self, q):
2566 q.text("table_feature_prop_experimenter {")
2567 with q.group():
2568 with q.indent(2):
2569 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002570 q.text("experimenter = ");
2571 q.text("%#x" % self.experimenter)
2572 q.text(","); q.breakable()
2573 q.text("subtype = ");
2574 q.text("%#x" % self.subtype)
2575 q.text(","); q.breakable()
2576 q.text("experimenter_data = ");
2577 q.pp(self.experimenter_data)
2578 q.breakable()
2579 q.text('}')
2580
Rich Lane7dcdf022013-12-11 14:45:27 -08002581table_feature_prop.subtypes[65535] = table_feature_prop_experimenter
2582
2583class table_feature_prop_instructions(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002584 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07002585
Dan Talaycof6202252013-07-02 01:00:29 -07002586 def __init__(self, instruction_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002587 if instruction_ids != None:
2588 self.instruction_ids = instruction_ids
2589 else:
2590 self.instruction_ids = []
2591 return
2592
2593 def pack(self):
2594 packed = []
2595 packed.append(struct.pack("!H", self.type))
2596 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002597 packed.append(loxi.generic_util.pack_list(self.instruction_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002598 length = sum([len(x) for x in packed])
2599 packed[1] = struct.pack("!H", length)
2600 return ''.join(packed)
2601
2602 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002603 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002604 obj = table_feature_prop_instructions()
Dan Talaycof6202252013-07-02 01:00:29 -07002605 _type = reader.read("!H")[0]
2606 assert(_type == 0)
2607 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002608 orig_reader = reader
2609 reader = orig_reader.slice(_length - (2 + 2))
2610 obj.instruction_ids = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002611 return obj
2612
2613 def __eq__(self, other):
2614 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002615 if self.instruction_ids != other.instruction_ids: return False
2616 return True
2617
Rich Lanec2ee4b82013-04-24 17:12:38 -07002618 def pretty_print(self, q):
2619 q.text("table_feature_prop_instructions {")
2620 with q.group():
2621 with q.indent(2):
2622 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002623 q.text("instruction_ids = ");
2624 q.pp(self.instruction_ids)
2625 q.breakable()
2626 q.text('}')
2627
Rich Lane7dcdf022013-12-11 14:45:27 -08002628table_feature_prop.subtypes[0] = table_feature_prop_instructions
2629
2630class table_feature_prop_instructions_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002631 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07002632
Dan Talaycof6202252013-07-02 01:00:29 -07002633 def __init__(self, instruction_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002634 if instruction_ids != None:
2635 self.instruction_ids = instruction_ids
2636 else:
2637 self.instruction_ids = []
2638 return
2639
2640 def pack(self):
2641 packed = []
2642 packed.append(struct.pack("!H", self.type))
2643 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002644 packed.append(loxi.generic_util.pack_list(self.instruction_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002645 length = sum([len(x) for x in packed])
2646 packed[1] = struct.pack("!H", length)
2647 return ''.join(packed)
2648
2649 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002650 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002651 obj = table_feature_prop_instructions_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07002652 _type = reader.read("!H")[0]
2653 assert(_type == 1)
2654 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002655 orig_reader = reader
2656 reader = orig_reader.slice(_length - (2 + 2))
2657 obj.instruction_ids = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002658 return obj
2659
2660 def __eq__(self, other):
2661 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002662 if self.instruction_ids != other.instruction_ids: return False
2663 return True
2664
Rich Lanec2ee4b82013-04-24 17:12:38 -07002665 def pretty_print(self, q):
2666 q.text("table_feature_prop_instructions_miss {")
2667 with q.group():
2668 with q.indent(2):
2669 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002670 q.text("instruction_ids = ");
2671 q.pp(self.instruction_ids)
2672 q.breakable()
2673 q.text('}')
2674
Rich Lane7dcdf022013-12-11 14:45:27 -08002675table_feature_prop.subtypes[1] = table_feature_prop_instructions_miss
2676
2677class table_feature_prop_match(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002678 type = 8
Rich Lanec2ee4b82013-04-24 17:12:38 -07002679
Dan Talaycof6202252013-07-02 01:00:29 -07002680 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002681 if oxm_ids != None:
2682 self.oxm_ids = oxm_ids
2683 else:
2684 self.oxm_ids = []
2685 return
2686
2687 def pack(self):
2688 packed = []
2689 packed.append(struct.pack("!H", self.type))
2690 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002691 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002692 length = sum([len(x) for x in packed])
2693 packed[1] = struct.pack("!H", length)
2694 return ''.join(packed)
2695
2696 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002697 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002698 obj = table_feature_prop_match()
Dan Talaycof6202252013-07-02 01:00:29 -07002699 _type = reader.read("!H")[0]
2700 assert(_type == 8)
2701 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002702 orig_reader = reader
2703 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002704 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
2705 return obj
2706
2707 def __eq__(self, other):
2708 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002709 if self.oxm_ids != other.oxm_ids: return False
2710 return True
2711
Rich Lanec2ee4b82013-04-24 17:12:38 -07002712 def pretty_print(self, q):
2713 q.text("table_feature_prop_match {")
2714 with q.group():
2715 with q.indent(2):
2716 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002717 q.text("oxm_ids = ");
2718 q.pp(self.oxm_ids)
2719 q.breakable()
2720 q.text('}')
2721
Rich Lane7dcdf022013-12-11 14:45:27 -08002722table_feature_prop.subtypes[8] = table_feature_prop_match
2723
2724class table_feature_prop_next_tables(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002725 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07002726
Dan Talaycof6202252013-07-02 01:00:29 -07002727 def __init__(self, next_table_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002728 if next_table_ids != None:
2729 self.next_table_ids = next_table_ids
2730 else:
2731 self.next_table_ids = []
2732 return
2733
2734 def pack(self):
2735 packed = []
2736 packed.append(struct.pack("!H", self.type))
2737 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002738 packed.append(loxi.generic_util.pack_list(self.next_table_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002739 length = sum([len(x) for x in packed])
2740 packed[1] = struct.pack("!H", length)
2741 return ''.join(packed)
2742
2743 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002744 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002745 obj = table_feature_prop_next_tables()
Dan Talaycof6202252013-07-02 01:00:29 -07002746 _type = reader.read("!H")[0]
2747 assert(_type == 2)
2748 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002749 orig_reader = reader
2750 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002751 obj.next_table_ids = loxi.generic_util.unpack_list(reader, common.uint8.unpack)
2752 return obj
2753
2754 def __eq__(self, other):
2755 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002756 if self.next_table_ids != other.next_table_ids: return False
2757 return True
2758
Rich Lanec2ee4b82013-04-24 17:12:38 -07002759 def pretty_print(self, q):
2760 q.text("table_feature_prop_next_tables {")
2761 with q.group():
2762 with q.indent(2):
2763 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002764 q.text("next_table_ids = ");
2765 q.pp(self.next_table_ids)
2766 q.breakable()
2767 q.text('}')
2768
Rich Lane7dcdf022013-12-11 14:45:27 -08002769table_feature_prop.subtypes[2] = table_feature_prop_next_tables
2770
2771class table_feature_prop_next_tables_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002772 type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07002773
Dan Talaycof6202252013-07-02 01:00:29 -07002774 def __init__(self, next_table_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002775 if next_table_ids != None:
2776 self.next_table_ids = next_table_ids
2777 else:
2778 self.next_table_ids = []
2779 return
2780
2781 def pack(self):
2782 packed = []
2783 packed.append(struct.pack("!H", self.type))
2784 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002785 packed.append(loxi.generic_util.pack_list(self.next_table_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002786 length = sum([len(x) for x in packed])
2787 packed[1] = struct.pack("!H", length)
2788 return ''.join(packed)
2789
2790 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002791 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002792 obj = table_feature_prop_next_tables_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07002793 _type = reader.read("!H")[0]
2794 assert(_type == 3)
2795 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002796 orig_reader = reader
2797 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002798 obj.next_table_ids = loxi.generic_util.unpack_list(reader, common.uint8.unpack)
2799 return obj
2800
2801 def __eq__(self, other):
2802 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002803 if self.next_table_ids != other.next_table_ids: return False
2804 return True
2805
Rich Lanec2ee4b82013-04-24 17:12:38 -07002806 def pretty_print(self, q):
2807 q.text("table_feature_prop_next_tables_miss {")
2808 with q.group():
2809 with q.indent(2):
2810 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002811 q.text("next_table_ids = ");
2812 q.pp(self.next_table_ids)
2813 q.breakable()
2814 q.text('}')
2815
Rich Lane7dcdf022013-12-11 14:45:27 -08002816table_feature_prop.subtypes[3] = table_feature_prop_next_tables_miss
2817
2818class table_feature_prop_wildcards(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002819 type = 10
Rich Lanec2ee4b82013-04-24 17:12:38 -07002820
Dan Talaycof6202252013-07-02 01:00:29 -07002821 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002822 if oxm_ids != None:
2823 self.oxm_ids = oxm_ids
2824 else:
2825 self.oxm_ids = []
2826 return
2827
2828 def pack(self):
2829 packed = []
2830 packed.append(struct.pack("!H", self.type))
2831 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002832 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002833 length = sum([len(x) for x in packed])
2834 packed[1] = struct.pack("!H", length)
2835 return ''.join(packed)
2836
2837 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002838 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002839 obj = table_feature_prop_wildcards()
Dan Talaycof6202252013-07-02 01:00:29 -07002840 _type = reader.read("!H")[0]
2841 assert(_type == 10)
2842 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002843 orig_reader = reader
2844 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002845 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
2846 return obj
2847
2848 def __eq__(self, other):
2849 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002850 if self.oxm_ids != other.oxm_ids: return False
2851 return True
2852
Rich Lanec2ee4b82013-04-24 17:12:38 -07002853 def pretty_print(self, q):
2854 q.text("table_feature_prop_wildcards {")
2855 with q.group():
2856 with q.indent(2):
2857 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002858 q.text("oxm_ids = ");
2859 q.pp(self.oxm_ids)
2860 q.breakable()
2861 q.text('}')
2862
Rich Lane7dcdf022013-12-11 14:45:27 -08002863table_feature_prop.subtypes[10] = table_feature_prop_wildcards
2864
2865class table_feature_prop_write_actions(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002866 type = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07002867
Dan Talaycof6202252013-07-02 01:00:29 -07002868 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002869 if action_ids != None:
2870 self.action_ids = action_ids
2871 else:
2872 self.action_ids = []
2873 return
2874
2875 def pack(self):
2876 packed = []
2877 packed.append(struct.pack("!H", self.type))
2878 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002879 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002880 length = sum([len(x) for x in packed])
2881 packed[1] = struct.pack("!H", length)
2882 return ''.join(packed)
2883
2884 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002885 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002886 obj = table_feature_prop_write_actions()
Dan Talaycof6202252013-07-02 01:00:29 -07002887 _type = reader.read("!H")[0]
2888 assert(_type == 4)
2889 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002890 orig_reader = reader
2891 reader = orig_reader.slice(_length - (2 + 2))
2892 obj.action_ids = loxi.generic_util.unpack_list(reader, action_id.action_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002893 return obj
2894
2895 def __eq__(self, other):
2896 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002897 if self.action_ids != other.action_ids: return False
2898 return True
2899
Rich Lanec2ee4b82013-04-24 17:12:38 -07002900 def pretty_print(self, q):
2901 q.text("table_feature_prop_write_actions {")
2902 with q.group():
2903 with q.indent(2):
2904 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002905 q.text("action_ids = ");
2906 q.pp(self.action_ids)
2907 q.breakable()
2908 q.text('}')
2909
Rich Lane7dcdf022013-12-11 14:45:27 -08002910table_feature_prop.subtypes[4] = table_feature_prop_write_actions
2911
2912class table_feature_prop_write_actions_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002913 type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07002914
Dan Talaycof6202252013-07-02 01:00:29 -07002915 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002916 if action_ids != None:
2917 self.action_ids = action_ids
2918 else:
2919 self.action_ids = []
2920 return
2921
2922 def pack(self):
2923 packed = []
2924 packed.append(struct.pack("!H", self.type))
2925 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002926 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002927 length = sum([len(x) for x in packed])
2928 packed[1] = struct.pack("!H", length)
2929 return ''.join(packed)
2930
2931 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002932 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002933 obj = table_feature_prop_write_actions_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07002934 _type = reader.read("!H")[0]
2935 assert(_type == 5)
2936 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002937 orig_reader = reader
2938 reader = orig_reader.slice(_length - (2 + 2))
2939 obj.action_ids = loxi.generic_util.unpack_list(reader, action_id.action_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002940 return obj
2941
2942 def __eq__(self, other):
2943 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002944 if self.action_ids != other.action_ids: return False
2945 return True
2946
Rich Lanec2ee4b82013-04-24 17:12:38 -07002947 def pretty_print(self, q):
2948 q.text("table_feature_prop_write_actions_miss {")
2949 with q.group():
2950 with q.indent(2):
2951 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002952 q.text("action_ids = ");
2953 q.pp(self.action_ids)
2954 q.breakable()
2955 q.text('}')
2956
Rich Lane7dcdf022013-12-11 14:45:27 -08002957table_feature_prop.subtypes[5] = table_feature_prop_write_actions_miss
2958
2959class table_feature_prop_write_setfield(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002960 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -07002961
Dan Talaycof6202252013-07-02 01:00:29 -07002962 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002963 if oxm_ids != None:
2964 self.oxm_ids = oxm_ids
2965 else:
2966 self.oxm_ids = []
2967 return
2968
2969 def pack(self):
2970 packed = []
2971 packed.append(struct.pack("!H", self.type))
2972 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002973 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002974 length = sum([len(x) for x in packed])
2975 packed[1] = struct.pack("!H", length)
2976 return ''.join(packed)
2977
2978 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002979 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002980 obj = table_feature_prop_write_setfield()
Dan Talaycof6202252013-07-02 01:00:29 -07002981 _type = reader.read("!H")[0]
2982 assert(_type == 12)
2983 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002984 orig_reader = reader
2985 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002986 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
2987 return obj
2988
2989 def __eq__(self, other):
2990 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002991 if self.oxm_ids != other.oxm_ids: return False
2992 return True
2993
Rich Lanec2ee4b82013-04-24 17:12:38 -07002994 def pretty_print(self, q):
2995 q.text("table_feature_prop_write_setfield {")
2996 with q.group():
2997 with q.indent(2):
2998 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002999 q.text("oxm_ids = ");
3000 q.pp(self.oxm_ids)
3001 q.breakable()
3002 q.text('}')
3003
Rich Lane7dcdf022013-12-11 14:45:27 -08003004table_feature_prop.subtypes[12] = table_feature_prop_write_setfield
3005
3006class table_feature_prop_write_setfield_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003007 type = 13
Rich Lanec2ee4b82013-04-24 17:12:38 -07003008
Dan Talaycof6202252013-07-02 01:00:29 -07003009 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003010 if oxm_ids != None:
3011 self.oxm_ids = oxm_ids
3012 else:
3013 self.oxm_ids = []
3014 return
3015
3016 def pack(self):
3017 packed = []
3018 packed.append(struct.pack("!H", self.type))
3019 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003020 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003021 length = sum([len(x) for x in packed])
3022 packed[1] = struct.pack("!H", length)
3023 return ''.join(packed)
3024
3025 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003026 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003027 obj = table_feature_prop_write_setfield_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07003028 _type = reader.read("!H")[0]
3029 assert(_type == 13)
3030 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003031 orig_reader = reader
3032 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003033 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
3034 return obj
3035
3036 def __eq__(self, other):
3037 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003038 if self.oxm_ids != other.oxm_ids: return False
3039 return True
3040
Rich Lanec2ee4b82013-04-24 17:12:38 -07003041 def pretty_print(self, q):
3042 q.text("table_feature_prop_write_setfield_miss {")
3043 with q.group():
3044 with q.indent(2):
3045 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003046 q.text("oxm_ids = ");
3047 q.pp(self.oxm_ids)
3048 q.breakable()
3049 q.text('}')
3050
Rich Lane7dcdf022013-12-11 14:45:27 -08003051table_feature_prop.subtypes[13] = table_feature_prop_write_setfield_miss
3052
3053class table_features(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003054
3055 def __init__(self, table_id=None, name=None, metadata_match=None, metadata_write=None, config=None, max_entries=None, properties=None):
3056 if table_id != None:
3057 self.table_id = table_id
3058 else:
3059 self.table_id = 0
3060 if name != None:
3061 self.name = name
3062 else:
3063 self.name = ""
3064 if metadata_match != None:
3065 self.metadata_match = metadata_match
3066 else:
3067 self.metadata_match = 0
3068 if metadata_write != None:
3069 self.metadata_write = metadata_write
3070 else:
3071 self.metadata_write = 0
3072 if config != None:
3073 self.config = config
3074 else:
3075 self.config = 0
3076 if max_entries != None:
3077 self.max_entries = max_entries
3078 else:
3079 self.max_entries = 0
3080 if properties != None:
3081 self.properties = properties
3082 else:
3083 self.properties = []
3084 return
3085
3086 def pack(self):
3087 packed = []
3088 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
3089 packed.append(struct.pack("!B", self.table_id))
3090 packed.append('\x00' * 5)
3091 packed.append(struct.pack("!32s", self.name))
3092 packed.append(struct.pack("!Q", self.metadata_match))
3093 packed.append(struct.pack("!Q", self.metadata_write))
3094 packed.append(struct.pack("!L", self.config))
3095 packed.append(struct.pack("!L", self.max_entries))
Rich Lane7dcdf022013-12-11 14:45:27 -08003096 packed.append(loxi.generic_util.pack_list(self.properties))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003097 length = sum([len(x) for x in packed])
3098 packed[0] = struct.pack("!H", length)
3099 return ''.join(packed)
3100
3101 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003102 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003103 obj = table_features()
Dan Talaycof6202252013-07-02 01:00:29 -07003104 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003105 orig_reader = reader
3106 reader = orig_reader.slice(_length - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07003107 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003108 reader.skip(5)
3109 obj.name = reader.read("!32s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -07003110 obj.metadata_match = reader.read("!Q")[0]
3111 obj.metadata_write = reader.read("!Q")[0]
3112 obj.config = reader.read("!L")[0]
3113 obj.max_entries = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003114 obj.properties = loxi.generic_util.unpack_list(reader, common.table_feature_prop.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003115 return obj
3116
3117 def __eq__(self, other):
3118 if type(self) != type(other): return False
3119 if self.table_id != other.table_id: return False
3120 if self.name != other.name: return False
3121 if self.metadata_match != other.metadata_match: return False
3122 if self.metadata_write != other.metadata_write: return False
3123 if self.config != other.config: return False
3124 if self.max_entries != other.max_entries: return False
3125 if self.properties != other.properties: return False
3126 return True
3127
Rich Lanec2ee4b82013-04-24 17:12:38 -07003128 def pretty_print(self, q):
3129 q.text("table_features {")
3130 with q.group():
3131 with q.indent(2):
3132 q.breakable()
3133 q.text("table_id = ");
3134 q.text("%#x" % self.table_id)
3135 q.text(","); q.breakable()
3136 q.text("name = ");
3137 q.pp(self.name)
3138 q.text(","); q.breakable()
3139 q.text("metadata_match = ");
3140 q.text("%#x" % self.metadata_match)
3141 q.text(","); q.breakable()
3142 q.text("metadata_write = ");
3143 q.text("%#x" % self.metadata_write)
3144 q.text(","); q.breakable()
3145 q.text("config = ");
3146 q.text("%#x" % self.config)
3147 q.text(","); q.breakable()
3148 q.text("max_entries = ");
3149 q.text("%#x" % self.max_entries)
3150 q.text(","); q.breakable()
3151 q.text("properties = ");
3152 q.pp(self.properties)
3153 q.breakable()
3154 q.text('}')
3155
Rich Lane7dcdf022013-12-11 14:45:27 -08003156
3157class table_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003158
3159 def __init__(self, table_id=None, active_count=None, lookup_count=None, matched_count=None):
3160 if table_id != None:
3161 self.table_id = table_id
3162 else:
3163 self.table_id = 0
3164 if active_count != None:
3165 self.active_count = active_count
3166 else:
3167 self.active_count = 0
3168 if lookup_count != None:
3169 self.lookup_count = lookup_count
3170 else:
3171 self.lookup_count = 0
3172 if matched_count != None:
3173 self.matched_count = matched_count
3174 else:
3175 self.matched_count = 0
3176 return
3177
3178 def pack(self):
3179 packed = []
3180 packed.append(struct.pack("!B", self.table_id))
3181 packed.append('\x00' * 3)
3182 packed.append(struct.pack("!L", self.active_count))
3183 packed.append(struct.pack("!Q", self.lookup_count))
3184 packed.append(struct.pack("!Q", self.matched_count))
3185 return ''.join(packed)
3186
3187 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003188 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003189 obj = table_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07003190 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003191 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07003192 obj.active_count = reader.read("!L")[0]
3193 obj.lookup_count = reader.read("!Q")[0]
3194 obj.matched_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003195 return obj
3196
3197 def __eq__(self, other):
3198 if type(self) != type(other): return False
3199 if self.table_id != other.table_id: return False
3200 if self.active_count != other.active_count: return False
3201 if self.lookup_count != other.lookup_count: return False
3202 if self.matched_count != other.matched_count: return False
3203 return True
3204
Rich Lanec2ee4b82013-04-24 17:12:38 -07003205 def pretty_print(self, q):
3206 q.text("table_stats_entry {")
3207 with q.group():
3208 with q.indent(2):
3209 q.breakable()
3210 q.text("table_id = ");
3211 q.text("%#x" % self.table_id)
3212 q.text(","); q.breakable()
3213 q.text("active_count = ");
3214 q.text("%#x" % self.active_count)
3215 q.text(","); q.breakable()
3216 q.text("lookup_count = ");
3217 q.text("%#x" % self.lookup_count)
3218 q.text(","); q.breakable()
3219 q.text("matched_count = ");
3220 q.text("%#x" % self.matched_count)
3221 q.breakable()
3222 q.text('}')
3223
Rich Lane7dcdf022013-12-11 14:45:27 -08003224
3225class uint32(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003226
3227 def __init__(self, value=None):
3228 if value != None:
3229 self.value = value
3230 else:
3231 self.value = 0
3232 return
3233
3234 def pack(self):
3235 packed = []
3236 packed.append(struct.pack("!L", self.value))
3237 return ''.join(packed)
3238
3239 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003240 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003241 obj = uint32()
Dan Talaycof6202252013-07-02 01:00:29 -07003242 obj.value = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003243 return obj
3244
3245 def __eq__(self, other):
3246 if type(self) != type(other): return False
3247 if self.value != other.value: return False
3248 return True
3249
Rich Lanec2ee4b82013-04-24 17:12:38 -07003250 def pretty_print(self, q):
3251 q.text("uint32 {")
3252 with q.group():
3253 with q.indent(2):
3254 q.breakable()
3255 q.text("value = ");
3256 q.text("%#x" % self.value)
3257 q.breakable()
3258 q.text('}')
3259
Rich Lane7dcdf022013-12-11 14:45:27 -08003260
3261class uint64(loxi.OFObject):
3262
3263 def __init__(self, value=None):
3264 if value != None:
3265 self.value = value
3266 else:
3267 self.value = 0
3268 return
3269
3270 def pack(self):
3271 packed = []
3272 packed.append(struct.pack("!Q", self.value))
3273 return ''.join(packed)
3274
3275 @staticmethod
3276 def unpack(reader):
3277 obj = uint64()
3278 obj.value = reader.read("!Q")[0]
3279 return obj
3280
3281 def __eq__(self, other):
3282 if type(self) != type(other): return False
3283 if self.value != other.value: return False
3284 return True
3285
3286 def pretty_print(self, q):
3287 q.text("uint64 {")
3288 with q.group():
3289 with q.indent(2):
3290 q.breakable()
3291 q.text("value = ");
3292 q.text("%#x" % self.value)
3293 q.breakable()
3294 q.text('}')
3295
3296
3297class uint8(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003298
3299 def __init__(self, value=None):
3300 if value != None:
3301 self.value = value
3302 else:
3303 self.value = 0
3304 return
3305
3306 def pack(self):
3307 packed = []
3308 packed.append(struct.pack("!B", self.value))
3309 return ''.join(packed)
3310
3311 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003312 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003313 obj = uint8()
Dan Talaycof6202252013-07-02 01:00:29 -07003314 obj.value = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003315 return obj
3316
3317 def __eq__(self, other):
3318 if type(self) != type(other): return False
3319 if self.value != other.value: return False
3320 return True
3321
Rich Lanec2ee4b82013-04-24 17:12:38 -07003322 def pretty_print(self, q):
3323 q.text("uint8 {")
3324 with q.group():
3325 with q.indent(2):
3326 q.breakable()
3327 q.text("value = ");
3328 q.text("%#x" % self.value)
3329 q.breakable()
3330 q.text('}')
3331
3332
Rich Lane7dcdf022013-12-11 14:45:27 -08003333
Rich Lanec2ee4b82013-04-24 17:12:38 -07003334match = match_v3