blob: f5c06a45bf9aedc79a67d0071daefafb07f1269a [file] [log] [blame]
Matteo Scandoloa229eca2017-08-08 13:05:28 -07001
2# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
Rich Lanec2ee4b82013-04-24 17:12:38 -070017# Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
18# Copyright (c) 2011, 2012 Open Networking Foundation
19# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
Dan Talaycof6202252013-07-02 01:00:29 -070020# See the file LICENSE.pyloxi which should have been included in the source distribution
Rich Lane7dcdf022013-12-11 14:45:27 -080021
22# Automatically generated by LOXI from template module.py
Rich Lanec2ee4b82013-04-24 17:12:38 -070023# Do not modify
24
Rich Lanec2ee4b82013-04-24 17:12:38 -070025import struct
Rich Lane7dcdf022013-12-11 14:45:27 -080026import loxi
Rich Lanec2ee4b82013-04-24 17:12:38 -070027import util
28import loxi.generic_util
29
Rich Lanee2567702015-01-26 15:04:35 -080030import sys
31ofp = sys.modules['loxi.of13']
32
Rich Lane5454b682014-01-14 17:07:36 -080033class bsn_controller_connection(loxi.OFObject):
34
35 def __init__(self, state=None, auxiliary_id=None, role=None, uri=None):
36 if state != None:
37 self.state = state
38 else:
39 self.state = 0
40 if auxiliary_id != None:
41 self.auxiliary_id = auxiliary_id
42 else:
43 self.auxiliary_id = 0
44 if role != None:
45 self.role = role
46 else:
47 self.role = 0
48 if uri != None:
49 self.uri = uri
50 else:
51 self.uri = ""
52 return
53
54 def pack(self):
55 packed = []
56 packed.append(struct.pack("!B", self.state))
57 packed.append(struct.pack("!B", self.auxiliary_id))
58 packed.append('\x00' * 2)
59 packed.append(struct.pack("!L", self.role))
60 packed.append(struct.pack("!256s", self.uri))
61 return ''.join(packed)
62
63 @staticmethod
64 def unpack(reader):
65 obj = bsn_controller_connection()
66 obj.state = reader.read("!B")[0]
67 obj.auxiliary_id = reader.read("!B")[0]
68 reader.skip(2)
69 obj.role = reader.read("!L")[0]
70 obj.uri = reader.read("!256s")[0].rstrip("\x00")
71 return obj
72
73 def __eq__(self, other):
74 if type(self) != type(other): return False
75 if self.state != other.state: return False
76 if self.auxiliary_id != other.auxiliary_id: return False
77 if self.role != other.role: return False
78 if self.uri != other.uri: return False
79 return True
80
81 def pretty_print(self, q):
82 q.text("bsn_controller_connection {")
83 with q.group():
84 with q.indent(2):
85 q.breakable()
86 q.text("state = ");
87 q.text("%#x" % self.state)
88 q.text(","); q.breakable()
89 q.text("auxiliary_id = ");
90 q.text("%#x" % self.auxiliary_id)
91 q.text(","); q.breakable()
92 q.text("role = ");
93 q.text("%#x" % self.role)
94 q.text(","); q.breakable()
95 q.text("uri = ");
96 q.pp(self.uri)
97 q.breakable()
98 q.text('}')
99
100
Rich Lane93b33132014-04-21 12:20:58 -0700101class bsn_debug_counter_desc_stats_entry(loxi.OFObject):
102
103 def __init__(self, counter_id=None, name=None, description=None):
104 if counter_id != None:
105 self.counter_id = counter_id
106 else:
107 self.counter_id = 0
108 if name != None:
109 self.name = name
110 else:
111 self.name = ""
112 if description != None:
113 self.description = description
114 else:
115 self.description = ""
116 return
117
118 def pack(self):
119 packed = []
120 packed.append(struct.pack("!Q", self.counter_id))
121 packed.append(struct.pack("!64s", self.name))
122 packed.append(struct.pack("!256s", self.description))
123 return ''.join(packed)
124
125 @staticmethod
126 def unpack(reader):
127 obj = bsn_debug_counter_desc_stats_entry()
128 obj.counter_id = reader.read("!Q")[0]
129 obj.name = reader.read("!64s")[0].rstrip("\x00")
130 obj.description = reader.read("!256s")[0].rstrip("\x00")
131 return obj
132
133 def __eq__(self, other):
134 if type(self) != type(other): return False
135 if self.counter_id != other.counter_id: return False
136 if self.name != other.name: return False
137 if self.description != other.description: return False
138 return True
139
140 def pretty_print(self, q):
141 q.text("bsn_debug_counter_desc_stats_entry {")
142 with q.group():
143 with q.indent(2):
144 q.breakable()
145 q.text("counter_id = ");
146 q.text("%#x" % self.counter_id)
147 q.text(","); q.breakable()
148 q.text("name = ");
149 q.pp(self.name)
150 q.text(","); q.breakable()
151 q.text("description = ");
152 q.pp(self.description)
153 q.breakable()
154 q.text('}')
155
156
157class bsn_debug_counter_stats_entry(loxi.OFObject):
158
159 def __init__(self, counter_id=None, value=None):
160 if counter_id != None:
161 self.counter_id = counter_id
162 else:
163 self.counter_id = 0
164 if value != None:
165 self.value = value
166 else:
167 self.value = 0
168 return
169
170 def pack(self):
171 packed = []
172 packed.append(struct.pack("!Q", self.counter_id))
173 packed.append(struct.pack("!Q", self.value))
174 return ''.join(packed)
175
176 @staticmethod
177 def unpack(reader):
178 obj = bsn_debug_counter_stats_entry()
179 obj.counter_id = reader.read("!Q")[0]
180 obj.value = reader.read("!Q")[0]
181 return obj
182
183 def __eq__(self, other):
184 if type(self) != type(other): return False
185 if self.counter_id != other.counter_id: return False
186 if self.value != other.value: return False
187 return True
188
189 def pretty_print(self, q):
190 q.text("bsn_debug_counter_stats_entry {")
191 with q.group():
192 with q.indent(2):
193 q.breakable()
194 q.text("counter_id = ");
195 q.text("%#x" % self.counter_id)
196 q.text(","); q.breakable()
197 q.text("value = ");
198 q.text("%#x" % self.value)
199 q.breakable()
200 q.text('}')
201
202
Rich Lane9ec3fca2014-02-26 16:22:56 -0800203class bsn_flow_checksum_bucket_stats_entry(loxi.OFObject):
204
205 def __init__(self, checksum=None):
206 if checksum != None:
207 self.checksum = checksum
208 else:
209 self.checksum = 0
210 return
211
212 def pack(self):
213 packed = []
214 packed.append(struct.pack("!Q", self.checksum))
215 return ''.join(packed)
216
217 @staticmethod
218 def unpack(reader):
219 obj = bsn_flow_checksum_bucket_stats_entry()
220 obj.checksum = reader.read("!Q")[0]
221 return obj
222
223 def __eq__(self, other):
224 if type(self) != type(other): return False
225 if self.checksum != other.checksum: return False
226 return True
227
228 def pretty_print(self, q):
229 q.text("bsn_flow_checksum_bucket_stats_entry {")
230 with q.group():
231 with q.indent(2):
232 q.breakable()
233 q.text("checksum = ");
234 q.text("%#x" % self.checksum)
235 q.breakable()
236 q.text('}')
237
238
Rich Lanecb18dbd2014-12-18 10:02:29 -0800239class bsn_generic_stats_entry(loxi.OFObject):
240
241 def __init__(self, tlvs=None):
242 if tlvs != None:
243 self.tlvs = tlvs
244 else:
245 self.tlvs = []
246 return
247
248 def pack(self):
249 packed = []
250 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
251 packed.append(loxi.generic_util.pack_list(self.tlvs))
252 length = sum([len(x) for x in packed])
253 packed[0] = struct.pack("!H", length)
254 return ''.join(packed)
255
256 @staticmethod
257 def unpack(reader):
258 obj = bsn_generic_stats_entry()
259 _length = reader.read("!H")[0]
260 orig_reader = reader
261 reader = orig_reader.slice(_length, 2)
Rich Lanee2567702015-01-26 15:04:35 -0800262 obj.tlvs = loxi.generic_util.unpack_list(reader, ofp.bsn_tlv.bsn_tlv.unpack)
Rich Lanecb18dbd2014-12-18 10:02:29 -0800263 return obj
264
265 def __eq__(self, other):
266 if type(self) != type(other): return False
267 if self.tlvs != other.tlvs: return False
268 return True
269
270 def pretty_print(self, q):
271 q.text("bsn_generic_stats_entry {")
272 with q.group():
273 with q.indent(2):
274 q.breakable()
275 q.text("tlvs = ");
276 q.pp(self.tlvs)
277 q.breakable()
278 q.text('}')
279
280
Rich Lane5454b682014-01-14 17:07:36 -0800281class bsn_gentable_bucket_stats_entry(loxi.OFObject):
282
283 def __init__(self, checksum=None):
284 if checksum != None:
285 self.checksum = checksum
286 else:
287 self.checksum = 0
288 return
289
290 def pack(self):
291 packed = []
292 packed.append(util.pack_checksum_128(self.checksum))
293 return ''.join(packed)
294
295 @staticmethod
296 def unpack(reader):
297 obj = bsn_gentable_bucket_stats_entry()
298 obj.checksum = util.unpack_checksum_128(reader)
299 return obj
300
301 def __eq__(self, other):
302 if type(self) != type(other): return False
303 if self.checksum != other.checksum: return False
304 return True
305
306 def pretty_print(self, q):
307 q.text("bsn_gentable_bucket_stats_entry {")
308 with q.group():
309 with q.indent(2):
310 q.breakable()
311 q.text("checksum = ");
312 q.pp(self.checksum)
313 q.breakable()
314 q.text('}')
315
316
317class bsn_gentable_desc_stats_entry(loxi.OFObject):
318
319 def __init__(self, table_id=None, name=None, buckets_size=None, max_entries=None):
320 if table_id != None:
321 self.table_id = table_id
322 else:
323 self.table_id = 0
324 if name != None:
325 self.name = name
326 else:
327 self.name = ""
328 if buckets_size != None:
329 self.buckets_size = buckets_size
330 else:
331 self.buckets_size = 0
332 if max_entries != None:
333 self.max_entries = max_entries
334 else:
335 self.max_entries = 0
336 return
337
338 def pack(self):
339 packed = []
340 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
341 packed.append(struct.pack("!H", self.table_id))
342 packed.append(struct.pack("!32s", self.name))
343 packed.append(struct.pack("!L", self.buckets_size))
344 packed.append(struct.pack("!L", self.max_entries))
345 packed.append('\x00' * 4)
346 length = sum([len(x) for x in packed])
347 packed[0] = struct.pack("!H", length)
348 return ''.join(packed)
349
350 @staticmethod
351 def unpack(reader):
352 obj = bsn_gentable_desc_stats_entry()
353 _length = reader.read("!H")[0]
354 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800355 reader = orig_reader.slice(_length, 2)
Rich Lane5454b682014-01-14 17:07:36 -0800356 obj.table_id = reader.read("!H")[0]
357 obj.name = reader.read("!32s")[0].rstrip("\x00")
358 obj.buckets_size = reader.read("!L")[0]
359 obj.max_entries = reader.read("!L")[0]
360 reader.skip(4)
361 return obj
362
363 def __eq__(self, other):
364 if type(self) != type(other): return False
365 if self.table_id != other.table_id: return False
366 if self.name != other.name: return False
367 if self.buckets_size != other.buckets_size: return False
368 if self.max_entries != other.max_entries: return False
369 return True
370
371 def pretty_print(self, q):
372 q.text("bsn_gentable_desc_stats_entry {")
373 with q.group():
374 with q.indent(2):
375 q.breakable()
376 q.text("table_id = ");
377 q.text("%#x" % self.table_id)
378 q.text(","); q.breakable()
379 q.text("name = ");
380 q.pp(self.name)
381 q.text(","); q.breakable()
382 q.text("buckets_size = ");
383 q.text("%#x" % self.buckets_size)
384 q.text(","); q.breakable()
385 q.text("max_entries = ");
386 q.text("%#x" % self.max_entries)
387 q.breakable()
388 q.text('}')
389
390
391class bsn_gentable_entry_desc_stats_entry(loxi.OFObject):
392
393 def __init__(self, checksum=None, key=None, value=None):
394 if checksum != None:
395 self.checksum = checksum
396 else:
397 self.checksum = 0
398 if key != None:
399 self.key = key
400 else:
401 self.key = []
402 if value != None:
403 self.value = value
404 else:
405 self.value = []
406 return
407
408 def pack(self):
409 packed = []
410 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
411 packed.append(struct.pack("!H", 0)) # placeholder for key_length at index 1
412 packed.append(util.pack_checksum_128(self.checksum))
413 packed.append(loxi.generic_util.pack_list(self.key))
414 packed[1] = struct.pack("!H", len(packed[-1]))
415 packed.append(loxi.generic_util.pack_list(self.value))
416 length = sum([len(x) for x in packed])
417 packed[0] = struct.pack("!H", length)
418 return ''.join(packed)
419
420 @staticmethod
421 def unpack(reader):
422 obj = bsn_gentable_entry_desc_stats_entry()
423 _length = reader.read("!H")[0]
424 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800425 reader = orig_reader.slice(_length, 2)
Rich Lane5454b682014-01-14 17:07:36 -0800426 _key_length = reader.read("!H")[0]
427 obj.checksum = util.unpack_checksum_128(reader)
Rich Lanee2567702015-01-26 15:04:35 -0800428 obj.key = loxi.generic_util.unpack_list(reader.slice(_key_length), ofp.bsn_tlv.bsn_tlv.unpack)
429 obj.value = loxi.generic_util.unpack_list(reader, ofp.bsn_tlv.bsn_tlv.unpack)
Rich Lane5454b682014-01-14 17:07:36 -0800430 return obj
431
432 def __eq__(self, other):
433 if type(self) != type(other): return False
434 if self.checksum != other.checksum: return False
435 if self.key != other.key: return False
436 if self.value != other.value: return False
437 return True
438
439 def pretty_print(self, q):
440 q.text("bsn_gentable_entry_desc_stats_entry {")
441 with q.group():
442 with q.indent(2):
443 q.breakable()
444 q.text("checksum = ");
445 q.pp(self.checksum)
446 q.text(","); q.breakable()
447 q.text("key = ");
448 q.pp(self.key)
449 q.text(","); q.breakable()
450 q.text("value = ");
451 q.pp(self.value)
452 q.breakable()
453 q.text('}')
454
455
456class bsn_gentable_entry_stats_entry(loxi.OFObject):
457
458 def __init__(self, key=None, stats=None):
459 if key != None:
460 self.key = key
461 else:
462 self.key = []
463 if stats != None:
464 self.stats = stats
465 else:
466 self.stats = []
467 return
468
469 def pack(self):
470 packed = []
471 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
472 packed.append(struct.pack("!H", 0)) # placeholder for key_length at index 1
473 packed.append(loxi.generic_util.pack_list(self.key))
474 packed[1] = struct.pack("!H", len(packed[-1]))
475 packed.append(loxi.generic_util.pack_list(self.stats))
476 length = sum([len(x) for x in packed])
477 packed[0] = struct.pack("!H", length)
478 return ''.join(packed)
479
480 @staticmethod
481 def unpack(reader):
482 obj = bsn_gentable_entry_stats_entry()
483 _length = reader.read("!H")[0]
484 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800485 reader = orig_reader.slice(_length, 2)
Rich Lane5454b682014-01-14 17:07:36 -0800486 _key_length = reader.read("!H")[0]
Rich Lanee2567702015-01-26 15:04:35 -0800487 obj.key = loxi.generic_util.unpack_list(reader.slice(_key_length), ofp.bsn_tlv.bsn_tlv.unpack)
488 obj.stats = loxi.generic_util.unpack_list(reader, ofp.bsn_tlv.bsn_tlv.unpack)
Rich Lane5454b682014-01-14 17:07:36 -0800489 return obj
490
491 def __eq__(self, other):
492 if type(self) != type(other): return False
493 if self.key != other.key: return False
494 if self.stats != other.stats: return False
495 return True
496
497 def pretty_print(self, q):
498 q.text("bsn_gentable_entry_stats_entry {")
499 with q.group():
500 with q.indent(2):
501 q.breakable()
502 q.text("key = ");
503 q.pp(self.key)
504 q.text(","); q.breakable()
505 q.text("stats = ");
506 q.pp(self.stats)
507 q.breakable()
508 q.text('}')
509
510
511class bsn_gentable_stats_entry(loxi.OFObject):
512
513 def __init__(self, table_id=None, entry_count=None, checksum=None):
514 if table_id != None:
515 self.table_id = table_id
516 else:
517 self.table_id = 0
518 if entry_count != None:
519 self.entry_count = entry_count
520 else:
521 self.entry_count = 0
522 if checksum != None:
523 self.checksum = checksum
524 else:
525 self.checksum = 0
526 return
527
528 def pack(self):
529 packed = []
530 packed.append(struct.pack("!H", self.table_id))
531 packed.append('\x00' * 2)
532 packed.append(struct.pack("!L", self.entry_count))
533 packed.append(util.pack_checksum_128(self.checksum))
534 return ''.join(packed)
535
536 @staticmethod
537 def unpack(reader):
538 obj = bsn_gentable_stats_entry()
539 obj.table_id = reader.read("!H")[0]
540 reader.skip(2)
541 obj.entry_count = reader.read("!L")[0]
542 obj.checksum = util.unpack_checksum_128(reader)
543 return obj
544
545 def __eq__(self, other):
546 if type(self) != type(other): return False
547 if self.table_id != other.table_id: return False
548 if self.entry_count != other.entry_count: return False
549 if self.checksum != other.checksum: return False
550 return True
551
552 def pretty_print(self, q):
553 q.text("bsn_gentable_stats_entry {")
554 with q.group():
555 with q.indent(2):
556 q.breakable()
557 q.text("table_id = ");
558 q.text("%#x" % self.table_id)
559 q.text(","); q.breakable()
560 q.text("entry_count = ");
561 q.text("%#x" % self.entry_count)
562 q.text(","); q.breakable()
563 q.text("checksum = ");
564 q.pp(self.checksum)
565 q.breakable()
566 q.text('}')
567
568
Rich Lane7dcdf022013-12-11 14:45:27 -0800569class bsn_interface(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700570
571 def __init__(self, hw_addr=None, name=None, ipv4_addr=None, ipv4_netmask=None):
572 if hw_addr != None:
573 self.hw_addr = hw_addr
574 else:
575 self.hw_addr = [0,0,0,0,0,0]
576 if name != None:
577 self.name = name
578 else:
579 self.name = ""
580 if ipv4_addr != None:
581 self.ipv4_addr = ipv4_addr
582 else:
583 self.ipv4_addr = 0
584 if ipv4_netmask != None:
585 self.ipv4_netmask = ipv4_netmask
586 else:
587 self.ipv4_netmask = 0
588 return
589
590 def pack(self):
591 packed = []
592 packed.append(struct.pack("!6B", *self.hw_addr))
593 packed.append('\x00' * 2)
594 packed.append(struct.pack("!16s", self.name))
595 packed.append(struct.pack("!L", self.ipv4_addr))
596 packed.append(struct.pack("!L", self.ipv4_netmask))
597 return ''.join(packed)
598
599 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800600 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700601 obj = bsn_interface()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700602 obj.hw_addr = list(reader.read('!6B'))
603 reader.skip(2)
604 obj.name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -0700605 obj.ipv4_addr = reader.read("!L")[0]
606 obj.ipv4_netmask = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700607 return obj
608
609 def __eq__(self, other):
610 if type(self) != type(other): return False
611 if self.hw_addr != other.hw_addr: return False
612 if self.name != other.name: return False
613 if self.ipv4_addr != other.ipv4_addr: return False
614 if self.ipv4_netmask != other.ipv4_netmask: return False
615 return True
616
Rich Lanec2ee4b82013-04-24 17:12:38 -0700617 def pretty_print(self, q):
618 q.text("bsn_interface {")
619 with q.group():
620 with q.indent(2):
621 q.breakable()
622 q.text("hw_addr = ");
623 q.text(util.pretty_mac(self.hw_addr))
624 q.text(","); q.breakable()
625 q.text("name = ");
626 q.pp(self.name)
627 q.text(","); q.breakable()
628 q.text("ipv4_addr = ");
629 q.text(util.pretty_ipv4(self.ipv4_addr))
630 q.text(","); q.breakable()
631 q.text("ipv4_netmask = ");
632 q.text(util.pretty_ipv4(self.ipv4_netmask))
633 q.breakable()
634 q.text('}')
635
Rich Lane7dcdf022013-12-11 14:45:27 -0800636
637class bsn_lacp_stats_entry(loxi.OFObject):
Rich Lane7b0f2012013-11-22 14:15:26 -0800638
639 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):
640 if port_no != None:
641 self.port_no = port_no
642 else:
643 self.port_no = 0
644 if actor_sys_priority != None:
645 self.actor_sys_priority = actor_sys_priority
646 else:
647 self.actor_sys_priority = 0
648 if actor_sys_mac != None:
649 self.actor_sys_mac = actor_sys_mac
650 else:
651 self.actor_sys_mac = [0,0,0,0,0,0]
652 if actor_port_priority != None:
653 self.actor_port_priority = actor_port_priority
654 else:
655 self.actor_port_priority = 0
656 if actor_port_num != None:
657 self.actor_port_num = actor_port_num
658 else:
659 self.actor_port_num = 0
660 if actor_key != None:
661 self.actor_key = actor_key
662 else:
663 self.actor_key = 0
664 if convergence_status != None:
665 self.convergence_status = convergence_status
666 else:
667 self.convergence_status = 0
668 if partner_sys_priority != None:
669 self.partner_sys_priority = partner_sys_priority
670 else:
671 self.partner_sys_priority = 0
672 if partner_sys_mac != None:
673 self.partner_sys_mac = partner_sys_mac
674 else:
675 self.partner_sys_mac = [0,0,0,0,0,0]
676 if partner_port_priority != None:
677 self.partner_port_priority = partner_port_priority
678 else:
679 self.partner_port_priority = 0
680 if partner_port_num != None:
681 self.partner_port_num = partner_port_num
682 else:
683 self.partner_port_num = 0
684 if partner_key != None:
685 self.partner_key = partner_key
686 else:
687 self.partner_key = 0
688 return
689
690 def pack(self):
691 packed = []
692 packed.append(util.pack_port_no(self.port_no))
693 packed.append(struct.pack("!H", self.actor_sys_priority))
694 packed.append(struct.pack("!6B", *self.actor_sys_mac))
695 packed.append(struct.pack("!H", self.actor_port_priority))
696 packed.append(struct.pack("!H", self.actor_port_num))
697 packed.append(struct.pack("!H", self.actor_key))
698 packed.append(struct.pack("!B", self.convergence_status))
699 packed.append('\x00' * 1)
700 packed.append(struct.pack("!H", self.partner_sys_priority))
701 packed.append(struct.pack("!6B", *self.partner_sys_mac))
702 packed.append(struct.pack("!H", self.partner_port_priority))
703 packed.append(struct.pack("!H", self.partner_port_num))
704 packed.append(struct.pack("!H", self.partner_key))
705 packed.append('\x00' * 2)
706 return ''.join(packed)
707
708 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800709 def unpack(reader):
Rich Lane7b0f2012013-11-22 14:15:26 -0800710 obj = bsn_lacp_stats_entry()
Rich Lane7b0f2012013-11-22 14:15:26 -0800711 obj.port_no = util.unpack_port_no(reader)
712 obj.actor_sys_priority = reader.read("!H")[0]
713 obj.actor_sys_mac = list(reader.read('!6B'))
714 obj.actor_port_priority = reader.read("!H")[0]
715 obj.actor_port_num = reader.read("!H")[0]
716 obj.actor_key = reader.read("!H")[0]
717 obj.convergence_status = reader.read("!B")[0]
718 reader.skip(1)
719 obj.partner_sys_priority = reader.read("!H")[0]
720 obj.partner_sys_mac = list(reader.read('!6B'))
721 obj.partner_port_priority = reader.read("!H")[0]
722 obj.partner_port_num = reader.read("!H")[0]
723 obj.partner_key = reader.read("!H")[0]
724 reader.skip(2)
725 return obj
726
727 def __eq__(self, other):
728 if type(self) != type(other): return False
729 if self.port_no != other.port_no: return False
730 if self.actor_sys_priority != other.actor_sys_priority: return False
731 if self.actor_sys_mac != other.actor_sys_mac: return False
732 if self.actor_port_priority != other.actor_port_priority: return False
733 if self.actor_port_num != other.actor_port_num: return False
734 if self.actor_key != other.actor_key: return False
735 if self.convergence_status != other.convergence_status: return False
736 if self.partner_sys_priority != other.partner_sys_priority: return False
737 if self.partner_sys_mac != other.partner_sys_mac: return False
738 if self.partner_port_priority != other.partner_port_priority: return False
739 if self.partner_port_num != other.partner_port_num: return False
740 if self.partner_key != other.partner_key: return False
741 return True
742
Rich Lane7b0f2012013-11-22 14:15:26 -0800743 def pretty_print(self, q):
744 q.text("bsn_lacp_stats_entry {")
745 with q.group():
746 with q.indent(2):
747 q.breakable()
748 q.text("port_no = ");
749 q.text(util.pretty_port(self.port_no))
750 q.text(","); q.breakable()
751 q.text("actor_sys_priority = ");
752 q.text("%#x" % self.actor_sys_priority)
753 q.text(","); q.breakable()
754 q.text("actor_sys_mac = ");
755 q.text(util.pretty_mac(self.actor_sys_mac))
756 q.text(","); q.breakable()
757 q.text("actor_port_priority = ");
758 q.text("%#x" % self.actor_port_priority)
759 q.text(","); q.breakable()
760 q.text("actor_port_num = ");
761 q.text("%#x" % self.actor_port_num)
762 q.text(","); q.breakable()
763 q.text("actor_key = ");
764 q.text("%#x" % self.actor_key)
765 q.text(","); q.breakable()
766 q.text("convergence_status = ");
767 q.text("%#x" % self.convergence_status)
768 q.text(","); q.breakable()
769 q.text("partner_sys_priority = ");
770 q.text("%#x" % self.partner_sys_priority)
771 q.text(","); q.breakable()
772 q.text("partner_sys_mac = ");
773 q.text(util.pretty_mac(self.partner_sys_mac))
774 q.text(","); q.breakable()
775 q.text("partner_port_priority = ");
776 q.text("%#x" % self.partner_port_priority)
777 q.text(","); q.breakable()
778 q.text("partner_port_num = ");
779 q.text("%#x" % self.partner_port_num)
780 q.text(","); q.breakable()
781 q.text("partner_key = ");
782 q.text("%#x" % self.partner_key)
783 q.breakable()
784 q.text('}')
785
Rich Lane7dcdf022013-12-11 14:45:27 -0800786
787class bsn_port_counter_stats_entry(loxi.OFObject):
788
789 def __init__(self, port_no=None, values=None):
790 if port_no != None:
791 self.port_no = port_no
792 else:
793 self.port_no = 0
794 if values != None:
795 self.values = values
796 else:
797 self.values = []
798 return
799
800 def pack(self):
801 packed = []
802 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
803 packed.append('\x00' * 2)
804 packed.append(util.pack_port_no(self.port_no))
805 packed.append(loxi.generic_util.pack_list(self.values))
806 length = sum([len(x) for x in packed])
807 packed[0] = struct.pack("!H", length)
808 return ''.join(packed)
809
810 @staticmethod
811 def unpack(reader):
812 obj = bsn_port_counter_stats_entry()
813 _length = reader.read("!H")[0]
814 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800815 reader = orig_reader.slice(_length, 2)
Rich Lane7dcdf022013-12-11 14:45:27 -0800816 reader.skip(2)
817 obj.port_no = util.unpack_port_no(reader)
Rich Lanee2567702015-01-26 15:04:35 -0800818 obj.values = loxi.generic_util.unpack_list(reader, ofp.common.uint64.unpack)
Rich Lane7dcdf022013-12-11 14:45:27 -0800819 return obj
820
821 def __eq__(self, other):
822 if type(self) != type(other): return False
823 if self.port_no != other.port_no: return False
824 if self.values != other.values: return False
825 return True
826
827 def pretty_print(self, q):
828 q.text("bsn_port_counter_stats_entry {")
829 with q.group():
830 with q.indent(2):
831 q.breakable()
832 q.text("port_no = ");
833 q.text(util.pretty_port(self.port_no))
834 q.text(","); q.breakable()
835 q.text("values = ");
836 q.pp(self.values)
837 q.breakable()
838 q.text('}')
839
840
841class bsn_switch_pipeline_stats_entry(loxi.OFObject):
842
843 def __init__(self, pipeline=None):
844 if pipeline != None:
845 self.pipeline = pipeline
846 else:
847 self.pipeline = ""
848 return
849
850 def pack(self):
851 packed = []
852 packed.append(struct.pack("!256s", self.pipeline))
853 return ''.join(packed)
854
855 @staticmethod
856 def unpack(reader):
857 obj = bsn_switch_pipeline_stats_entry()
858 obj.pipeline = reader.read("!256s")[0].rstrip("\x00")
859 return obj
860
861 def __eq__(self, other):
862 if type(self) != type(other): return False
863 if self.pipeline != other.pipeline: return False
864 return True
865
866 def pretty_print(self, q):
867 q.text("bsn_switch_pipeline_stats_entry {")
868 with q.group():
869 with q.indent(2):
870 q.breakable()
871 q.text("pipeline = ");
872 q.pp(self.pipeline)
873 q.breakable()
874 q.text('}')
875
876
Rich Lane9ec3fca2014-02-26 16:22:56 -0800877class bsn_table_checksum_stats_entry(loxi.OFObject):
878
879 def __init__(self, table_id=None, checksum=None):
880 if table_id != None:
881 self.table_id = table_id
882 else:
883 self.table_id = 0
884 if checksum != None:
885 self.checksum = checksum
886 else:
887 self.checksum = 0
888 return
889
890 def pack(self):
891 packed = []
892 packed.append(struct.pack("!B", self.table_id))
893 packed.append(struct.pack("!Q", self.checksum))
894 return ''.join(packed)
895
896 @staticmethod
897 def unpack(reader):
898 obj = bsn_table_checksum_stats_entry()
899 obj.table_id = reader.read("!B")[0]
900 obj.checksum = reader.read("!Q")[0]
901 return obj
902
903 def __eq__(self, other):
904 if type(self) != type(other): return False
905 if self.table_id != other.table_id: return False
906 if self.checksum != other.checksum: return False
907 return True
908
909 def pretty_print(self, q):
910 q.text("bsn_table_checksum_stats_entry {")
911 with q.group():
912 with q.indent(2):
913 q.breakable()
914 q.text("table_id = ");
915 q.text("%#x" % self.table_id)
916 q.text(","); q.breakable()
917 q.text("checksum = ");
918 q.text("%#x" % self.checksum)
919 q.breakable()
920 q.text('}')
921
922
Rich Lane7dcdf022013-12-11 14:45:27 -0800923class bsn_vport(loxi.OFObject):
924 subtypes = {}
925
Rich Lane95f7fc92014-01-27 17:08:16 -0800926
927 def __init__(self, type=None):
928 if type != None:
929 self.type = type
930 else:
931 self.type = 0
932 return
933
934 def pack(self):
935 packed = []
936 packed.append(struct.pack("!H", self.type))
937 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
938 length = sum([len(x) for x in packed])
939 packed[1] = struct.pack("!H", length)
940 return ''.join(packed)
941
Rich Lane7dcdf022013-12-11 14:45:27 -0800942 @staticmethod
943 def unpack(reader):
944 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -0800945 subclass = bsn_vport.subtypes.get(subtype)
946 if subclass:
947 return subclass.unpack(reader)
948
949 obj = bsn_vport()
950 obj.type = reader.read("!H")[0]
951 _length = reader.read("!H")[0]
952 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800953 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800954 return obj
955
956 def __eq__(self, other):
957 if type(self) != type(other): return False
958 if self.type != other.type: return False
959 return True
960
961 def pretty_print(self, q):
962 q.text("bsn_vport {")
963 with q.group():
964 with q.indent(2):
965 q.breakable()
966 q.breakable()
967 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800968
969
Rich Lane93b33132014-04-21 12:20:58 -0700970class bsn_vlan_counter_stats_entry(loxi.OFObject):
971
972 def __init__(self, vlan_vid=None, values=None):
973 if vlan_vid != None:
974 self.vlan_vid = vlan_vid
975 else:
976 self.vlan_vid = 0
977 if values != None:
978 self.values = values
979 else:
980 self.values = []
981 return
982
983 def pack(self):
984 packed = []
985 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
986 packed.append(struct.pack("!H", self.vlan_vid))
987 packed.append('\x00' * 4)
988 packed.append(loxi.generic_util.pack_list(self.values))
989 length = sum([len(x) for x in packed])
990 packed[0] = struct.pack("!H", length)
991 return ''.join(packed)
992
993 @staticmethod
994 def unpack(reader):
995 obj = bsn_vlan_counter_stats_entry()
996 _length = reader.read("!H")[0]
997 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800998 reader = orig_reader.slice(_length, 2)
Rich Lane93b33132014-04-21 12:20:58 -0700999 obj.vlan_vid = reader.read("!H")[0]
1000 reader.skip(4)
Rich Lanee2567702015-01-26 15:04:35 -08001001 obj.values = loxi.generic_util.unpack_list(reader, ofp.common.uint64.unpack)
Rich Lane93b33132014-04-21 12:20:58 -07001002 return obj
1003
1004 def __eq__(self, other):
1005 if type(self) != type(other): return False
1006 if self.vlan_vid != other.vlan_vid: return False
1007 if self.values != other.values: return False
1008 return True
1009
1010 def pretty_print(self, q):
1011 q.text("bsn_vlan_counter_stats_entry {")
1012 with q.group():
1013 with q.indent(2):
1014 q.breakable()
1015 q.text("vlan_vid = ");
1016 q.text("%#x" % self.vlan_vid)
1017 q.text(","); q.breakable()
1018 q.text("values = ");
1019 q.pp(self.values)
1020 q.breakable()
1021 q.text('}')
1022
1023
1024class bsn_vport_l2gre(bsn_vport):
1025 type = 1
1026
Rich Lanef9530c42014-09-15 09:59:43 -07001027 def __init__(self, flags=None, port_no=None, loopback_port_no=None, local_mac=None, nh_mac=None, src_ip=None, dst_ip=None, dscp=None, ttl=None, vpn=None, rate_limit=None, if_name=None):
Rich Lane93b33132014-04-21 12:20:58 -07001028 if flags != None:
1029 self.flags = flags
1030 else:
1031 self.flags = 0
1032 if port_no != None:
1033 self.port_no = port_no
1034 else:
1035 self.port_no = 0
Rich Lane5587ab12014-06-30 11:19:09 -07001036 if loopback_port_no != None:
1037 self.loopback_port_no = loopback_port_no
1038 else:
1039 self.loopback_port_no = 0
Rich Lane93b33132014-04-21 12:20:58 -07001040 if local_mac != None:
1041 self.local_mac = local_mac
1042 else:
1043 self.local_mac = [0,0,0,0,0,0]
1044 if nh_mac != None:
1045 self.nh_mac = nh_mac
1046 else:
1047 self.nh_mac = [0,0,0,0,0,0]
1048 if src_ip != None:
1049 self.src_ip = src_ip
1050 else:
1051 self.src_ip = 0
1052 if dst_ip != None:
1053 self.dst_ip = dst_ip
1054 else:
1055 self.dst_ip = 0
1056 if dscp != None:
1057 self.dscp = dscp
1058 else:
1059 self.dscp = 0
1060 if ttl != None:
1061 self.ttl = ttl
1062 else:
1063 self.ttl = 0
1064 if vpn != None:
1065 self.vpn = vpn
1066 else:
1067 self.vpn = 0
Rich Lanef9530c42014-09-15 09:59:43 -07001068 if rate_limit != None:
1069 self.rate_limit = rate_limit
1070 else:
1071 self.rate_limit = 0
Rich Lane93b33132014-04-21 12:20:58 -07001072 if if_name != None:
1073 self.if_name = if_name
1074 else:
1075 self.if_name = ""
1076 return
1077
1078 def pack(self):
1079 packed = []
1080 packed.append(struct.pack("!H", self.type))
1081 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
1082 packed.append(struct.pack("!L", self.flags))
1083 packed.append(util.pack_port_no(self.port_no))
Rich Lane5587ab12014-06-30 11:19:09 -07001084 packed.append(util.pack_port_no(self.loopback_port_no))
Rich Lane93b33132014-04-21 12:20:58 -07001085 packed.append(struct.pack("!6B", *self.local_mac))
1086 packed.append(struct.pack("!6B", *self.nh_mac))
1087 packed.append(struct.pack("!L", self.src_ip))
1088 packed.append(struct.pack("!L", self.dst_ip))
1089 packed.append(struct.pack("!B", self.dscp))
1090 packed.append(struct.pack("!B", self.ttl))
1091 packed.append('\x00' * 2)
1092 packed.append(struct.pack("!L", self.vpn))
Rich Lanef9530c42014-09-15 09:59:43 -07001093 packed.append(struct.pack("!L", self.rate_limit))
Rich Lane93b33132014-04-21 12:20:58 -07001094 packed.append(struct.pack("!16s", self.if_name))
1095 length = sum([len(x) for x in packed])
1096 packed[1] = struct.pack("!H", length)
1097 return ''.join(packed)
1098
1099 @staticmethod
1100 def unpack(reader):
1101 obj = bsn_vport_l2gre()
1102 _type = reader.read("!H")[0]
1103 assert(_type == 1)
1104 _length = reader.read("!H")[0]
1105 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001106 reader = orig_reader.slice(_length, 4)
Rich Lane93b33132014-04-21 12:20:58 -07001107 obj.flags = reader.read("!L")[0]
1108 obj.port_no = util.unpack_port_no(reader)
Rich Lane5587ab12014-06-30 11:19:09 -07001109 obj.loopback_port_no = util.unpack_port_no(reader)
Rich Lane93b33132014-04-21 12:20:58 -07001110 obj.local_mac = list(reader.read('!6B'))
1111 obj.nh_mac = list(reader.read('!6B'))
1112 obj.src_ip = reader.read("!L")[0]
1113 obj.dst_ip = reader.read("!L")[0]
1114 obj.dscp = reader.read("!B")[0]
1115 obj.ttl = reader.read("!B")[0]
1116 reader.skip(2)
1117 obj.vpn = reader.read("!L")[0]
Rich Lanef9530c42014-09-15 09:59:43 -07001118 obj.rate_limit = reader.read("!L")[0]
Rich Lane93b33132014-04-21 12:20:58 -07001119 obj.if_name = reader.read("!16s")[0].rstrip("\x00")
1120 return obj
1121
1122 def __eq__(self, other):
1123 if type(self) != type(other): return False
1124 if self.flags != other.flags: return False
1125 if self.port_no != other.port_no: return False
Rich Lane5587ab12014-06-30 11:19:09 -07001126 if self.loopback_port_no != other.loopback_port_no: return False
Rich Lane93b33132014-04-21 12:20:58 -07001127 if self.local_mac != other.local_mac: return False
1128 if self.nh_mac != other.nh_mac: return False
1129 if self.src_ip != other.src_ip: return False
1130 if self.dst_ip != other.dst_ip: return False
1131 if self.dscp != other.dscp: return False
1132 if self.ttl != other.ttl: return False
1133 if self.vpn != other.vpn: return False
Rich Lanef9530c42014-09-15 09:59:43 -07001134 if self.rate_limit != other.rate_limit: return False
Rich Lane93b33132014-04-21 12:20:58 -07001135 if self.if_name != other.if_name: return False
1136 return True
1137
1138 def pretty_print(self, q):
1139 q.text("bsn_vport_l2gre {")
1140 with q.group():
1141 with q.indent(2):
1142 q.breakable()
1143 q.text("flags = ");
1144 q.text("%#x" % self.flags)
1145 q.text(","); q.breakable()
1146 q.text("port_no = ");
1147 q.text(util.pretty_port(self.port_no))
1148 q.text(","); q.breakable()
Rich Lane5587ab12014-06-30 11:19:09 -07001149 q.text("loopback_port_no = ");
1150 q.text(util.pretty_port(self.loopback_port_no))
1151 q.text(","); q.breakable()
Rich Lane93b33132014-04-21 12:20:58 -07001152 q.text("local_mac = ");
1153 q.text(util.pretty_mac(self.local_mac))
1154 q.text(","); q.breakable()
1155 q.text("nh_mac = ");
1156 q.text(util.pretty_mac(self.nh_mac))
1157 q.text(","); q.breakable()
1158 q.text("src_ip = ");
1159 q.text(util.pretty_ipv4(self.src_ip))
1160 q.text(","); q.breakable()
1161 q.text("dst_ip = ");
1162 q.text(util.pretty_ipv4(self.dst_ip))
1163 q.text(","); q.breakable()
1164 q.text("dscp = ");
1165 q.text("%#x" % self.dscp)
1166 q.text(","); q.breakable()
1167 q.text("ttl = ");
1168 q.text("%#x" % self.ttl)
1169 q.text(","); q.breakable()
1170 q.text("vpn = ");
1171 q.text("%#x" % self.vpn)
1172 q.text(","); q.breakable()
Rich Lanef9530c42014-09-15 09:59:43 -07001173 q.text("rate_limit = ");
1174 q.text("%#x" % self.rate_limit)
1175 q.text(","); q.breakable()
Rich Lane93b33132014-04-21 12:20:58 -07001176 q.text("if_name = ");
1177 q.pp(self.if_name)
1178 q.breakable()
1179 q.text('}')
1180
1181bsn_vport.subtypes[1] = bsn_vport_l2gre
1182
Rich Lane7dcdf022013-12-11 14:45:27 -08001183class bsn_vport_q_in_q(bsn_vport):
Dan Talaycof6202252013-07-02 01:00:29 -07001184 type = 0
1185
Kiran Poola150d8b02013-09-20 13:30:39 -07001186 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 -07001187 if port_no != None:
1188 self.port_no = port_no
1189 else:
1190 self.port_no = 0
1191 if ingress_tpid != None:
1192 self.ingress_tpid = ingress_tpid
1193 else:
1194 self.ingress_tpid = 0
1195 if ingress_vlan_id != None:
1196 self.ingress_vlan_id = ingress_vlan_id
1197 else:
1198 self.ingress_vlan_id = 0
1199 if egress_tpid != None:
1200 self.egress_tpid = egress_tpid
1201 else:
1202 self.egress_tpid = 0
1203 if egress_vlan_id != None:
1204 self.egress_vlan_id = egress_vlan_id
1205 else:
1206 self.egress_vlan_id = 0
Kiran Poola150d8b02013-09-20 13:30:39 -07001207 if if_name != None:
1208 self.if_name = if_name
1209 else:
1210 self.if_name = ""
Dan Talaycof6202252013-07-02 01:00:29 -07001211 return
1212
1213 def pack(self):
1214 packed = []
1215 packed.append(struct.pack("!H", self.type))
Kiran Poola150d8b02013-09-20 13:30:39 -07001216 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -07001217 packed.append(struct.pack("!L", self.port_no))
1218 packed.append(struct.pack("!H", self.ingress_tpid))
1219 packed.append(struct.pack("!H", self.ingress_vlan_id))
1220 packed.append(struct.pack("!H", self.egress_tpid))
1221 packed.append(struct.pack("!H", self.egress_vlan_id))
Kiran Poola150d8b02013-09-20 13:30:39 -07001222 packed.append(struct.pack("!16s", self.if_name))
Dan Talaycof6202252013-07-02 01:00:29 -07001223 length = sum([len(x) for x in packed])
Kiran Poola150d8b02013-09-20 13:30:39 -07001224 packed[1] = struct.pack("!H", length)
Dan Talaycof6202252013-07-02 01:00:29 -07001225 return ''.join(packed)
1226
1227 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001228 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -07001229 obj = bsn_vport_q_in_q()
Dan Talaycof6202252013-07-02 01:00:29 -07001230 _type = reader.read("!H")[0]
1231 assert(_type == 0)
1232 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001233 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001234 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001235 obj.port_no = reader.read("!L")[0]
1236 obj.ingress_tpid = reader.read("!H")[0]
1237 obj.ingress_vlan_id = reader.read("!H")[0]
1238 obj.egress_tpid = reader.read("!H")[0]
1239 obj.egress_vlan_id = reader.read("!H")[0]
Kiran Poola150d8b02013-09-20 13:30:39 -07001240 obj.if_name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -07001241 return obj
1242
1243 def __eq__(self, other):
1244 if type(self) != type(other): return False
1245 if self.port_no != other.port_no: return False
1246 if self.ingress_tpid != other.ingress_tpid: return False
1247 if self.ingress_vlan_id != other.ingress_vlan_id: return False
1248 if self.egress_tpid != other.egress_tpid: return False
1249 if self.egress_vlan_id != other.egress_vlan_id: return False
Kiran Poola150d8b02013-09-20 13:30:39 -07001250 if self.if_name != other.if_name: return False
Dan Talaycof6202252013-07-02 01:00:29 -07001251 return True
1252
Dan Talaycof6202252013-07-02 01:00:29 -07001253 def pretty_print(self, q):
1254 q.text("bsn_vport_q_in_q {")
1255 with q.group():
1256 with q.indent(2):
1257 q.breakable()
1258 q.text("port_no = ");
1259 q.text("%#x" % self.port_no)
1260 q.text(","); q.breakable()
1261 q.text("ingress_tpid = ");
1262 q.text("%#x" % self.ingress_tpid)
1263 q.text(","); q.breakable()
1264 q.text("ingress_vlan_id = ");
1265 q.text("%#x" % self.ingress_vlan_id)
1266 q.text(","); q.breakable()
1267 q.text("egress_tpid = ");
1268 q.text("%#x" % self.egress_tpid)
1269 q.text(","); q.breakable()
1270 q.text("egress_vlan_id = ");
1271 q.text("%#x" % self.egress_vlan_id)
Kiran Poola150d8b02013-09-20 13:30:39 -07001272 q.text(","); q.breakable()
1273 q.text("if_name = ");
1274 q.pp(self.if_name)
Dan Talaycof6202252013-07-02 01:00:29 -07001275 q.breakable()
1276 q.text('}')
1277
Rich Lane7dcdf022013-12-11 14:45:27 -08001278bsn_vport.subtypes[0] = bsn_vport_q_in_q
1279
Rich Lane5587ab12014-06-30 11:19:09 -07001280class bsn_vrf_counter_stats_entry(loxi.OFObject):
1281
1282 def __init__(self, vrf=None, values=None):
1283 if vrf != None:
1284 self.vrf = vrf
1285 else:
1286 self.vrf = 0
1287 if values != None:
1288 self.values = values
1289 else:
1290 self.values = []
1291 return
1292
1293 def pack(self):
1294 packed = []
1295 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
1296 packed.append('\x00' * 2)
1297 packed.append(struct.pack("!L", self.vrf))
1298 packed.append(loxi.generic_util.pack_list(self.values))
1299 length = sum([len(x) for x in packed])
1300 packed[0] = struct.pack("!H", length)
1301 return ''.join(packed)
1302
1303 @staticmethod
1304 def unpack(reader):
1305 obj = bsn_vrf_counter_stats_entry()
1306 _length = reader.read("!H")[0]
1307 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001308 reader = orig_reader.slice(_length, 2)
Rich Lane5587ab12014-06-30 11:19:09 -07001309 reader.skip(2)
1310 obj.vrf = reader.read("!L")[0]
Rich Lanee2567702015-01-26 15:04:35 -08001311 obj.values = loxi.generic_util.unpack_list(reader, ofp.common.uint64.unpack)
Rich Lane5587ab12014-06-30 11:19:09 -07001312 return obj
1313
1314 def __eq__(self, other):
1315 if type(self) != type(other): return False
1316 if self.vrf != other.vrf: return False
1317 if self.values != other.values: return False
1318 return True
1319
1320 def pretty_print(self, q):
1321 q.text("bsn_vrf_counter_stats_entry {")
1322 with q.group():
1323 with q.indent(2):
1324 q.breakable()
1325 q.text("vrf = ");
1326 q.text("%#x" % self.vrf)
1327 q.text(","); q.breakable()
1328 q.text("values = ");
1329 q.pp(self.values)
1330 q.breakable()
1331 q.text('}')
1332
1333
Rich Lane7dcdf022013-12-11 14:45:27 -08001334class bucket(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001335
1336 def __init__(self, weight=None, watch_port=None, watch_group=None, actions=None):
1337 if weight != None:
1338 self.weight = weight
1339 else:
1340 self.weight = 0
1341 if watch_port != None:
1342 self.watch_port = watch_port
1343 else:
1344 self.watch_port = 0
1345 if watch_group != None:
1346 self.watch_group = watch_group
1347 else:
1348 self.watch_group = 0
1349 if actions != None:
1350 self.actions = actions
1351 else:
1352 self.actions = []
1353 return
1354
1355 def pack(self):
1356 packed = []
1357 packed.append(struct.pack("!H", 0)) # placeholder for len at index 0
1358 packed.append(struct.pack("!H", self.weight))
Dan Talaycof6202252013-07-02 01:00:29 -07001359 packed.append(util.pack_port_no(self.watch_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001360 packed.append(struct.pack("!L", self.watch_group))
1361 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08001362 packed.append(loxi.generic_util.pack_list(self.actions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001363 length = sum([len(x) for x in packed])
1364 packed[0] = struct.pack("!H", length)
1365 return ''.join(packed)
1366
1367 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001368 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001369 obj = bucket()
Dan Talaycof6202252013-07-02 01:00:29 -07001370 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001371 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001372 reader = orig_reader.slice(_len, 2)
Dan Talaycof6202252013-07-02 01:00:29 -07001373 obj.weight = reader.read("!H")[0]
1374 obj.watch_port = util.unpack_port_no(reader)
1375 obj.watch_group = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001376 reader.skip(4)
Rich Lanee2567702015-01-26 15:04:35 -08001377 obj.actions = loxi.generic_util.unpack_list(reader, ofp.action.action.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001378 return obj
1379
1380 def __eq__(self, other):
1381 if type(self) != type(other): return False
1382 if self.weight != other.weight: return False
1383 if self.watch_port != other.watch_port: return False
1384 if self.watch_group != other.watch_group: return False
1385 if self.actions != other.actions: return False
1386 return True
1387
Rich Lanec2ee4b82013-04-24 17:12:38 -07001388 def pretty_print(self, q):
1389 q.text("bucket {")
1390 with q.group():
1391 with q.indent(2):
1392 q.breakable()
1393 q.text("weight = ");
1394 q.text("%#x" % self.weight)
1395 q.text(","); q.breakable()
1396 q.text("watch_port = ");
1397 q.text(util.pretty_port(self.watch_port))
1398 q.text(","); q.breakable()
1399 q.text("watch_group = ");
1400 q.text("%#x" % self.watch_group)
1401 q.text(","); q.breakable()
1402 q.text("actions = ");
1403 q.pp(self.actions)
1404 q.breakable()
1405 q.text('}')
1406
Rich Lane7dcdf022013-12-11 14:45:27 -08001407
1408class bucket_counter(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001409
1410 def __init__(self, packet_count=None, byte_count=None):
1411 if packet_count != None:
1412 self.packet_count = packet_count
1413 else:
1414 self.packet_count = 0
1415 if byte_count != None:
1416 self.byte_count = byte_count
1417 else:
1418 self.byte_count = 0
1419 return
1420
1421 def pack(self):
1422 packed = []
1423 packed.append(struct.pack("!Q", self.packet_count))
1424 packed.append(struct.pack("!Q", self.byte_count))
1425 return ''.join(packed)
1426
1427 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001428 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001429 obj = bucket_counter()
Dan Talaycof6202252013-07-02 01:00:29 -07001430 obj.packet_count = reader.read("!Q")[0]
1431 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001432 return obj
1433
1434 def __eq__(self, other):
1435 if type(self) != type(other): return False
1436 if self.packet_count != other.packet_count: return False
1437 if self.byte_count != other.byte_count: return False
1438 return True
1439
Rich Lanec2ee4b82013-04-24 17:12:38 -07001440 def pretty_print(self, q):
1441 q.text("bucket_counter {")
1442 with q.group():
1443 with q.indent(2):
1444 q.breakable()
1445 q.text("packet_count = ");
1446 q.text("%#x" % self.packet_count)
1447 q.text(","); q.breakable()
1448 q.text("byte_count = ");
1449 q.text("%#x" % self.byte_count)
1450 q.breakable()
1451 q.text('}')
1452
Rich Lane7dcdf022013-12-11 14:45:27 -08001453
Rich Lane7dcdf022013-12-11 14:45:27 -08001454class flow_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001455
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001456 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 -07001457 if table_id != None:
1458 self.table_id = table_id
1459 else:
1460 self.table_id = 0
1461 if duration_sec != None:
1462 self.duration_sec = duration_sec
1463 else:
1464 self.duration_sec = 0
1465 if duration_nsec != None:
1466 self.duration_nsec = duration_nsec
1467 else:
1468 self.duration_nsec = 0
1469 if priority != None:
1470 self.priority = priority
1471 else:
1472 self.priority = 0
1473 if idle_timeout != None:
1474 self.idle_timeout = idle_timeout
1475 else:
1476 self.idle_timeout = 0
1477 if hard_timeout != None:
1478 self.hard_timeout = hard_timeout
1479 else:
1480 self.hard_timeout = 0
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001481 if flags != None:
1482 self.flags = flags
1483 else:
1484 self.flags = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07001485 if cookie != None:
1486 self.cookie = cookie
1487 else:
1488 self.cookie = 0
1489 if packet_count != None:
1490 self.packet_count = packet_count
1491 else:
1492 self.packet_count = 0
1493 if byte_count != None:
1494 self.byte_count = byte_count
1495 else:
1496 self.byte_count = 0
1497 if match != None:
1498 self.match = match
1499 else:
Rich Lanee2567702015-01-26 15:04:35 -08001500 self.match = ofp.match()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001501 if instructions != None:
1502 self.instructions = instructions
1503 else:
1504 self.instructions = []
1505 return
1506
1507 def pack(self):
1508 packed = []
1509 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
1510 packed.append(struct.pack("!B", self.table_id))
1511 packed.append('\x00' * 1)
1512 packed.append(struct.pack("!L", self.duration_sec))
1513 packed.append(struct.pack("!L", self.duration_nsec))
1514 packed.append(struct.pack("!H", self.priority))
1515 packed.append(struct.pack("!H", self.idle_timeout))
1516 packed.append(struct.pack("!H", self.hard_timeout))
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001517 packed.append(struct.pack("!H", self.flags))
1518 packed.append('\x00' * 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001519 packed.append(struct.pack("!Q", self.cookie))
1520 packed.append(struct.pack("!Q", self.packet_count))
1521 packed.append(struct.pack("!Q", self.byte_count))
1522 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -08001523 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001524 length = sum([len(x) for x in packed])
1525 packed[0] = struct.pack("!H", length)
1526 return ''.join(packed)
1527
1528 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001529 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001530 obj = flow_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001531 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001532 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001533 reader = orig_reader.slice(_length, 2)
Dan Talaycof6202252013-07-02 01:00:29 -07001534 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001535 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -07001536 obj.duration_sec = reader.read("!L")[0]
1537 obj.duration_nsec = reader.read("!L")[0]
1538 obj.priority = reader.read("!H")[0]
1539 obj.idle_timeout = reader.read("!H")[0]
1540 obj.hard_timeout = reader.read("!H")[0]
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001541 obj.flags = reader.read("!H")[0]
1542 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001543 obj.cookie = reader.read("!Q")[0]
1544 obj.packet_count = reader.read("!Q")[0]
1545 obj.byte_count = reader.read("!Q")[0]
Rich Lanee2567702015-01-26 15:04:35 -08001546 obj.match = ofp.match.unpack(reader)
1547 obj.instructions = loxi.generic_util.unpack_list(reader, ofp.instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001548 return obj
1549
1550 def __eq__(self, other):
1551 if type(self) != type(other): return False
1552 if self.table_id != other.table_id: return False
1553 if self.duration_sec != other.duration_sec: return False
1554 if self.duration_nsec != other.duration_nsec: return False
1555 if self.priority != other.priority: return False
1556 if self.idle_timeout != other.idle_timeout: return False
1557 if self.hard_timeout != other.hard_timeout: return False
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001558 if self.flags != other.flags: return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001559 if self.cookie != other.cookie: return False
1560 if self.packet_count != other.packet_count: return False
1561 if self.byte_count != other.byte_count: return False
1562 if self.match != other.match: return False
1563 if self.instructions != other.instructions: return False
1564 return True
1565
Rich Lanec2ee4b82013-04-24 17:12:38 -07001566 def pretty_print(self, q):
1567 q.text("flow_stats_entry {")
1568 with q.group():
1569 with q.indent(2):
1570 q.breakable()
1571 q.text("table_id = ");
1572 q.text("%#x" % self.table_id)
1573 q.text(","); q.breakable()
1574 q.text("duration_sec = ");
1575 q.text("%#x" % self.duration_sec)
1576 q.text(","); q.breakable()
1577 q.text("duration_nsec = ");
1578 q.text("%#x" % self.duration_nsec)
1579 q.text(","); q.breakable()
1580 q.text("priority = ");
1581 q.text("%#x" % self.priority)
1582 q.text(","); q.breakable()
1583 q.text("idle_timeout = ");
1584 q.text("%#x" % self.idle_timeout)
1585 q.text(","); q.breakable()
1586 q.text("hard_timeout = ");
1587 q.text("%#x" % self.hard_timeout)
1588 q.text(","); q.breakable()
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001589 q.text("flags = ");
1590 q.text("%#x" % self.flags)
1591 q.text(","); q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001592 q.text("cookie = ");
1593 q.text("%#x" % self.cookie)
1594 q.text(","); q.breakable()
1595 q.text("packet_count = ");
1596 q.text("%#x" % self.packet_count)
1597 q.text(","); q.breakable()
1598 q.text("byte_count = ");
1599 q.text("%#x" % self.byte_count)
1600 q.text(","); q.breakable()
1601 q.text("match = ");
1602 q.pp(self.match)
1603 q.text(","); q.breakable()
1604 q.text("instructions = ");
1605 q.pp(self.instructions)
1606 q.breakable()
1607 q.text('}')
1608
Rich Lane7dcdf022013-12-11 14:45:27 -08001609
1610class group_desc_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001611
Rich Lane6f4978c2013-10-20 21:33:52 -07001612 def __init__(self, group_type=None, group_id=None, buckets=None):
1613 if group_type != None:
1614 self.group_type = group_type
Rich Lanec2ee4b82013-04-24 17:12:38 -07001615 else:
Rich Lane6f4978c2013-10-20 21:33:52 -07001616 self.group_type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07001617 if group_id != None:
1618 self.group_id = group_id
1619 else:
1620 self.group_id = 0
1621 if buckets != None:
1622 self.buckets = buckets
1623 else:
1624 self.buckets = []
1625 return
1626
1627 def pack(self):
1628 packed = []
1629 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
Rich Lane6f4978c2013-10-20 21:33:52 -07001630 packed.append(struct.pack("!B", self.group_type))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001631 packed.append('\x00' * 1)
1632 packed.append(struct.pack("!L", self.group_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08001633 packed.append(loxi.generic_util.pack_list(self.buckets))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001634 length = sum([len(x) for x in packed])
1635 packed[0] = struct.pack("!H", length)
1636 return ''.join(packed)
1637
1638 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001639 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001640 obj = group_desc_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001641 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001642 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001643 reader = orig_reader.slice(_length, 2)
Rich Lane6f4978c2013-10-20 21:33:52 -07001644 obj.group_type = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001645 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -07001646 obj.group_id = reader.read("!L")[0]
Rich Lanee2567702015-01-26 15:04:35 -08001647 obj.buckets = loxi.generic_util.unpack_list(reader, ofp.common.bucket.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001648 return obj
1649
1650 def __eq__(self, other):
1651 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -07001652 if self.group_type != other.group_type: return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001653 if self.group_id != other.group_id: return False
1654 if self.buckets != other.buckets: return False
1655 return True
1656
Rich Lanec2ee4b82013-04-24 17:12:38 -07001657 def pretty_print(self, q):
1658 q.text("group_desc_stats_entry {")
1659 with q.group():
1660 with q.indent(2):
1661 q.breakable()
Rich Lane6f4978c2013-10-20 21:33:52 -07001662 q.text("group_type = ");
1663 q.text("%#x" % self.group_type)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001664 q.text(","); q.breakable()
1665 q.text("group_id = ");
1666 q.text("%#x" % self.group_id)
1667 q.text(","); q.breakable()
1668 q.text("buckets = ");
1669 q.pp(self.buckets)
1670 q.breakable()
1671 q.text('}')
1672
Rich Lane7dcdf022013-12-11 14:45:27 -08001673
1674class group_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001675
1676 def __init__(self, group_id=None, ref_count=None, packet_count=None, byte_count=None, duration_sec=None, duration_nsec=None, bucket_stats=None):
1677 if group_id != None:
1678 self.group_id = group_id
1679 else:
1680 self.group_id = 0
1681 if ref_count != None:
1682 self.ref_count = ref_count
1683 else:
1684 self.ref_count = 0
1685 if packet_count != None:
1686 self.packet_count = packet_count
1687 else:
1688 self.packet_count = 0
1689 if byte_count != None:
1690 self.byte_count = byte_count
1691 else:
1692 self.byte_count = 0
1693 if duration_sec != None:
1694 self.duration_sec = duration_sec
1695 else:
1696 self.duration_sec = 0
1697 if duration_nsec != None:
1698 self.duration_nsec = duration_nsec
1699 else:
1700 self.duration_nsec = 0
1701 if bucket_stats != None:
1702 self.bucket_stats = bucket_stats
1703 else:
1704 self.bucket_stats = []
1705 return
1706
1707 def pack(self):
1708 packed = []
1709 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
1710 packed.append('\x00' * 2)
1711 packed.append(struct.pack("!L", self.group_id))
1712 packed.append(struct.pack("!L", self.ref_count))
1713 packed.append('\x00' * 4)
1714 packed.append(struct.pack("!Q", self.packet_count))
1715 packed.append(struct.pack("!Q", self.byte_count))
1716 packed.append(struct.pack("!L", self.duration_sec))
1717 packed.append(struct.pack("!L", self.duration_nsec))
Rich Lane7dcdf022013-12-11 14:45:27 -08001718 packed.append(loxi.generic_util.pack_list(self.bucket_stats))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001719 length = sum([len(x) for x in packed])
1720 packed[0] = struct.pack("!H", length)
1721 return ''.join(packed)
1722
1723 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001724 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001725 obj = group_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001726 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001727 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001728 reader = orig_reader.slice(_length, 2)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001729 reader.skip(2)
Dan Talaycof6202252013-07-02 01:00:29 -07001730 obj.group_id = reader.read("!L")[0]
1731 obj.ref_count = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001732 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001733 obj.packet_count = reader.read("!Q")[0]
1734 obj.byte_count = reader.read("!Q")[0]
1735 obj.duration_sec = reader.read("!L")[0]
1736 obj.duration_nsec = reader.read("!L")[0]
Rich Lanee2567702015-01-26 15:04:35 -08001737 obj.bucket_stats = loxi.generic_util.unpack_list(reader, ofp.common.bucket_counter.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001738 return obj
1739
1740 def __eq__(self, other):
1741 if type(self) != type(other): return False
1742 if self.group_id != other.group_id: return False
1743 if self.ref_count != other.ref_count: return False
1744 if self.packet_count != other.packet_count: return False
1745 if self.byte_count != other.byte_count: return False
1746 if self.duration_sec != other.duration_sec: return False
1747 if self.duration_nsec != other.duration_nsec: return False
1748 if self.bucket_stats != other.bucket_stats: return False
1749 return True
1750
Rich Lanec2ee4b82013-04-24 17:12:38 -07001751 def pretty_print(self, q):
1752 q.text("group_stats_entry {")
1753 with q.group():
1754 with q.indent(2):
1755 q.breakable()
1756 q.text("group_id = ");
1757 q.text("%#x" % self.group_id)
1758 q.text(","); q.breakable()
1759 q.text("ref_count = ");
1760 q.text("%#x" % self.ref_count)
1761 q.text(","); q.breakable()
1762 q.text("packet_count = ");
1763 q.text("%#x" % self.packet_count)
1764 q.text(","); q.breakable()
1765 q.text("byte_count = ");
1766 q.text("%#x" % self.byte_count)
1767 q.text(","); q.breakable()
1768 q.text("duration_sec = ");
1769 q.text("%#x" % self.duration_sec)
1770 q.text(","); q.breakable()
1771 q.text("duration_nsec = ");
1772 q.text("%#x" % self.duration_nsec)
1773 q.text(","); q.breakable()
1774 q.text("bucket_stats = ");
1775 q.pp(self.bucket_stats)
1776 q.breakable()
1777 q.text('}')
1778
Rich Lane7dcdf022013-12-11 14:45:27 -08001779
1780class hello_elem(loxi.OFObject):
1781 subtypes = {}
1782
Rich Lane95f7fc92014-01-27 17:08:16 -08001783
1784 def __init__(self, type=None):
1785 if type != None:
1786 self.type = type
1787 else:
1788 self.type = 0
1789 return
1790
1791 def pack(self):
1792 packed = []
1793 packed.append(struct.pack("!H", self.type))
1794 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
1795 length = sum([len(x) for x in packed])
1796 packed[1] = struct.pack("!H", length)
1797 return ''.join(packed)
1798
Rich Lane7dcdf022013-12-11 14:45:27 -08001799 @staticmethod
1800 def unpack(reader):
1801 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -08001802 subclass = hello_elem.subtypes.get(subtype)
1803 if subclass:
1804 return subclass.unpack(reader)
1805
1806 obj = hello_elem()
1807 obj.type = reader.read("!H")[0]
1808 _length = reader.read("!H")[0]
1809 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001810 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -08001811 return obj
1812
1813 def __eq__(self, other):
1814 if type(self) != type(other): return False
1815 if self.type != other.type: return False
1816 return True
1817
1818 def pretty_print(self, q):
1819 q.text("hello_elem {")
1820 with q.group():
1821 with q.indent(2):
1822 q.breakable()
1823 q.breakable()
1824 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08001825
1826
1827class hello_elem_versionbitmap(hello_elem):
Dan Talaycof6202252013-07-02 01:00:29 -07001828 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07001829
1830 def __init__(self, bitmaps=None):
1831 if bitmaps != None:
1832 self.bitmaps = bitmaps
1833 else:
1834 self.bitmaps = []
1835 return
1836
1837 def pack(self):
1838 packed = []
1839 packed.append(struct.pack("!H", self.type))
1840 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08001841 packed.append(loxi.generic_util.pack_list(self.bitmaps))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001842 length = sum([len(x) for x in packed])
1843 packed[1] = struct.pack("!H", length)
1844 return ''.join(packed)
1845
1846 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001847 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001848 obj = hello_elem_versionbitmap()
Dan Talaycof6202252013-07-02 01:00:29 -07001849 _type = reader.read("!H")[0]
1850 assert(_type == 1)
1851 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001852 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001853 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08001854 obj.bitmaps = loxi.generic_util.unpack_list(reader, ofp.common.uint32.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001855 return obj
1856
1857 def __eq__(self, other):
1858 if type(self) != type(other): return False
1859 if self.bitmaps != other.bitmaps: return False
1860 return True
1861
Rich Lanec2ee4b82013-04-24 17:12:38 -07001862 def pretty_print(self, q):
1863 q.text("hello_elem_versionbitmap {")
1864 with q.group():
1865 with q.indent(2):
1866 q.breakable()
1867 q.text("bitmaps = ");
1868 q.pp(self.bitmaps)
1869 q.breakable()
1870 q.text('}')
1871
Rich Lane7dcdf022013-12-11 14:45:27 -08001872hello_elem.subtypes[1] = hello_elem_versionbitmap
1873
1874class match_v3(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001875 type = 1
1876
1877 def __init__(self, oxm_list=None):
1878 if oxm_list != None:
1879 self.oxm_list = oxm_list
1880 else:
1881 self.oxm_list = []
1882 return
1883
1884 def pack(self):
1885 packed = []
1886 packed.append(struct.pack("!H", self.type))
1887 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08001888 packed.append(loxi.generic_util.pack_list(self.oxm_list))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001889 length = sum([len(x) for x in packed])
1890 packed[1] = struct.pack("!H", length)
Rich Laned53156a2013-08-05 17:17:33 -07001891 packed.append(loxi.generic_util.pad_to(8, length))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001892 return ''.join(packed)
1893
1894 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001895 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001896 obj = match_v3()
Dan Talaycof6202252013-07-02 01:00:29 -07001897 _type = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001898 assert(_type == 1)
Dan Talaycof6202252013-07-02 01:00:29 -07001899 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001900 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001901 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08001902 obj.oxm_list = loxi.generic_util.unpack_list(reader, ofp.oxm.oxm.unpack)
Rich Lane7dcdf022013-12-11 14:45:27 -08001903 orig_reader.skip_align()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001904 return obj
1905
1906 def __eq__(self, other):
1907 if type(self) != type(other): return False
1908 if self.oxm_list != other.oxm_list: return False
1909 return True
1910
Rich Lanec2ee4b82013-04-24 17:12:38 -07001911 def pretty_print(self, q):
1912 q.text("match_v3 {")
1913 with q.group():
1914 with q.indent(2):
1915 q.breakable()
1916 q.text("oxm_list = ");
1917 q.pp(self.oxm_list)
1918 q.breakable()
1919 q.text('}')
1920
Rich Lane7dcdf022013-12-11 14:45:27 -08001921
1922class meter_band_stats(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001923
1924 def __init__(self, packet_band_count=None, byte_band_count=None):
1925 if packet_band_count != None:
1926 self.packet_band_count = packet_band_count
1927 else:
1928 self.packet_band_count = 0
1929 if byte_band_count != None:
1930 self.byte_band_count = byte_band_count
1931 else:
1932 self.byte_band_count = 0
1933 return
1934
1935 def pack(self):
1936 packed = []
1937 packed.append(struct.pack("!Q", self.packet_band_count))
1938 packed.append(struct.pack("!Q", self.byte_band_count))
1939 return ''.join(packed)
1940
1941 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001942 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001943 obj = meter_band_stats()
Dan Talaycof6202252013-07-02 01:00:29 -07001944 obj.packet_band_count = reader.read("!Q")[0]
1945 obj.byte_band_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001946 return obj
1947
1948 def __eq__(self, other):
1949 if type(self) != type(other): return False
1950 if self.packet_band_count != other.packet_band_count: return False
1951 if self.byte_band_count != other.byte_band_count: return False
1952 return True
1953
Rich Lanec2ee4b82013-04-24 17:12:38 -07001954 def pretty_print(self, q):
1955 q.text("meter_band_stats {")
1956 with q.group():
1957 with q.indent(2):
1958 q.breakable()
1959 q.text("packet_band_count = ");
1960 q.text("%#x" % self.packet_band_count)
1961 q.text(","); q.breakable()
1962 q.text("byte_band_count = ");
1963 q.text("%#x" % self.byte_band_count)
1964 q.breakable()
1965 q.text('}')
1966
Rich Lane7dcdf022013-12-11 14:45:27 -08001967
1968class meter_config(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001969
1970 def __init__(self, flags=None, meter_id=None, entries=None):
1971 if flags != None:
1972 self.flags = flags
1973 else:
1974 self.flags = 0
1975 if meter_id != None:
1976 self.meter_id = meter_id
1977 else:
1978 self.meter_id = 0
1979 if entries != None:
1980 self.entries = entries
1981 else:
1982 self.entries = []
1983 return
1984
1985 def pack(self):
1986 packed = []
1987 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
1988 packed.append(struct.pack("!H", self.flags))
1989 packed.append(struct.pack("!L", self.meter_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08001990 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001991 length = sum([len(x) for x in packed])
1992 packed[0] = struct.pack("!H", length)
1993 return ''.join(packed)
1994
1995 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001996 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001997 obj = meter_config()
Dan Talaycof6202252013-07-02 01:00:29 -07001998 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001999 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002000 reader = orig_reader.slice(_length, 2)
Dan Talaycof6202252013-07-02 01:00:29 -07002001 obj.flags = reader.read("!H")[0]
2002 obj.meter_id = reader.read("!L")[0]
Rich Lanee2567702015-01-26 15:04:35 -08002003 obj.entries = loxi.generic_util.unpack_list(reader, ofp.meter_band.meter_band.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002004 return obj
2005
2006 def __eq__(self, other):
2007 if type(self) != type(other): return False
2008 if self.flags != other.flags: return False
2009 if self.meter_id != other.meter_id: return False
2010 if self.entries != other.entries: return False
2011 return True
2012
Rich Lanec2ee4b82013-04-24 17:12:38 -07002013 def pretty_print(self, q):
2014 q.text("meter_config {")
2015 with q.group():
2016 with q.indent(2):
2017 q.breakable()
2018 q.text("flags = ");
2019 q.text("%#x" % self.flags)
2020 q.text(","); q.breakable()
2021 q.text("meter_id = ");
2022 q.text("%#x" % self.meter_id)
2023 q.text(","); q.breakable()
2024 q.text("entries = ");
2025 q.pp(self.entries)
2026 q.breakable()
2027 q.text('}')
2028
Rich Lane7dcdf022013-12-11 14:45:27 -08002029
2030class meter_features(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002031
2032 def __init__(self, max_meter=None, band_types=None, capabilities=None, max_bands=None, max_color=None):
2033 if max_meter != None:
2034 self.max_meter = max_meter
2035 else:
2036 self.max_meter = 0
2037 if band_types != None:
2038 self.band_types = band_types
2039 else:
2040 self.band_types = 0
2041 if capabilities != None:
2042 self.capabilities = capabilities
2043 else:
2044 self.capabilities = 0
2045 if max_bands != None:
2046 self.max_bands = max_bands
2047 else:
2048 self.max_bands = 0
2049 if max_color != None:
2050 self.max_color = max_color
2051 else:
2052 self.max_color = 0
2053 return
2054
2055 def pack(self):
2056 packed = []
2057 packed.append(struct.pack("!L", self.max_meter))
2058 packed.append(struct.pack("!L", self.band_types))
2059 packed.append(struct.pack("!L", self.capabilities))
2060 packed.append(struct.pack("!B", self.max_bands))
2061 packed.append(struct.pack("!B", self.max_color))
2062 packed.append('\x00' * 2)
2063 return ''.join(packed)
2064
2065 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002066 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002067 obj = meter_features()
Dan Talaycof6202252013-07-02 01:00:29 -07002068 obj.max_meter = reader.read("!L")[0]
2069 obj.band_types = reader.read("!L")[0]
2070 obj.capabilities = reader.read("!L")[0]
2071 obj.max_bands = reader.read("!B")[0]
2072 obj.max_color = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002073 reader.skip(2)
2074 return obj
2075
2076 def __eq__(self, other):
2077 if type(self) != type(other): return False
2078 if self.max_meter != other.max_meter: return False
2079 if self.band_types != other.band_types: return False
2080 if self.capabilities != other.capabilities: return False
2081 if self.max_bands != other.max_bands: return False
2082 if self.max_color != other.max_color: return False
2083 return True
2084
Rich Lanec2ee4b82013-04-24 17:12:38 -07002085 def pretty_print(self, q):
2086 q.text("meter_features {")
2087 with q.group():
2088 with q.indent(2):
2089 q.breakable()
2090 q.text("max_meter = ");
2091 q.text("%#x" % self.max_meter)
2092 q.text(","); q.breakable()
2093 q.text("band_types = ");
2094 q.text("%#x" % self.band_types)
2095 q.text(","); q.breakable()
2096 q.text("capabilities = ");
2097 q.text("%#x" % self.capabilities)
2098 q.text(","); q.breakable()
2099 q.text("max_bands = ");
2100 q.text("%#x" % self.max_bands)
2101 q.text(","); q.breakable()
2102 q.text("max_color = ");
2103 q.text("%#x" % self.max_color)
2104 q.breakable()
2105 q.text('}')
2106
Rich Lane7dcdf022013-12-11 14:45:27 -08002107
2108class meter_stats(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002109
2110 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):
2111 if meter_id != None:
2112 self.meter_id = meter_id
2113 else:
2114 self.meter_id = 0
2115 if flow_count != None:
2116 self.flow_count = flow_count
2117 else:
2118 self.flow_count = 0
2119 if packet_in_count != None:
2120 self.packet_in_count = packet_in_count
2121 else:
2122 self.packet_in_count = 0
2123 if byte_in_count != None:
2124 self.byte_in_count = byte_in_count
2125 else:
2126 self.byte_in_count = 0
2127 if duration_sec != None:
2128 self.duration_sec = duration_sec
2129 else:
2130 self.duration_sec = 0
2131 if duration_nsec != None:
2132 self.duration_nsec = duration_nsec
2133 else:
2134 self.duration_nsec = 0
2135 if band_stats != None:
2136 self.band_stats = band_stats
2137 else:
2138 self.band_stats = []
2139 return
2140
2141 def pack(self):
2142 packed = []
2143 packed.append(struct.pack("!L", self.meter_id))
2144 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2145 packed.append('\x00' * 6)
2146 packed.append(struct.pack("!L", self.flow_count))
2147 packed.append(struct.pack("!Q", self.packet_in_count))
2148 packed.append(struct.pack("!Q", self.byte_in_count))
2149 packed.append(struct.pack("!L", self.duration_sec))
2150 packed.append(struct.pack("!L", self.duration_nsec))
Rich Lane7dcdf022013-12-11 14:45:27 -08002151 packed.append(loxi.generic_util.pack_list(self.band_stats))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002152 length = sum([len(x) for x in packed])
2153 packed[1] = struct.pack("!H", length)
2154 return ''.join(packed)
2155
2156 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002157 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002158 obj = meter_stats()
Dan Talaycof6202252013-07-02 01:00:29 -07002159 obj.meter_id = reader.read("!L")[0]
2160 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002161 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002162 reader = orig_reader.slice(_len, 6)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002163 reader.skip(6)
Dan Talaycof6202252013-07-02 01:00:29 -07002164 obj.flow_count = reader.read("!L")[0]
2165 obj.packet_in_count = reader.read("!Q")[0]
2166 obj.byte_in_count = reader.read("!Q")[0]
2167 obj.duration_sec = reader.read("!L")[0]
2168 obj.duration_nsec = reader.read("!L")[0]
Rich Lanee2567702015-01-26 15:04:35 -08002169 obj.band_stats = loxi.generic_util.unpack_list(reader, ofp.common.meter_band_stats.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002170 return obj
2171
2172 def __eq__(self, other):
2173 if type(self) != type(other): return False
2174 if self.meter_id != other.meter_id: return False
2175 if self.flow_count != other.flow_count: return False
2176 if self.packet_in_count != other.packet_in_count: return False
2177 if self.byte_in_count != other.byte_in_count: return False
2178 if self.duration_sec != other.duration_sec: return False
2179 if self.duration_nsec != other.duration_nsec: return False
2180 if self.band_stats != other.band_stats: return False
2181 return True
2182
Rich Lanec2ee4b82013-04-24 17:12:38 -07002183 def pretty_print(self, q):
2184 q.text("meter_stats {")
2185 with q.group():
2186 with q.indent(2):
2187 q.breakable()
2188 q.text("meter_id = ");
2189 q.text("%#x" % self.meter_id)
2190 q.text(","); q.breakable()
2191 q.text("flow_count = ");
2192 q.text("%#x" % self.flow_count)
2193 q.text(","); q.breakable()
2194 q.text("packet_in_count = ");
2195 q.text("%#x" % self.packet_in_count)
2196 q.text(","); q.breakable()
2197 q.text("byte_in_count = ");
2198 q.text("%#x" % self.byte_in_count)
2199 q.text(","); q.breakable()
2200 q.text("duration_sec = ");
2201 q.text("%#x" % self.duration_sec)
2202 q.text(","); q.breakable()
2203 q.text("duration_nsec = ");
2204 q.text("%#x" % self.duration_nsec)
2205 q.text(","); q.breakable()
2206 q.text("band_stats = ");
2207 q.pp(self.band_stats)
2208 q.breakable()
2209 q.text('}')
2210
Rich Lane7dcdf022013-12-11 14:45:27 -08002211
2212class packet_queue(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002213
2214 def __init__(self, queue_id=None, port=None, properties=None):
2215 if queue_id != None:
2216 self.queue_id = queue_id
2217 else:
2218 self.queue_id = 0
2219 if port != None:
2220 self.port = port
2221 else:
2222 self.port = 0
2223 if properties != None:
2224 self.properties = properties
2225 else:
2226 self.properties = []
2227 return
2228
2229 def pack(self):
2230 packed = []
2231 packed.append(struct.pack("!L", self.queue_id))
Dan Talaycof6202252013-07-02 01:00:29 -07002232 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002233 packed.append(struct.pack("!H", 0)) # placeholder for len at index 2
2234 packed.append('\x00' * 6)
Rich Lane7dcdf022013-12-11 14:45:27 -08002235 packed.append(loxi.generic_util.pack_list(self.properties))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002236 length = sum([len(x) for x in packed])
2237 packed[2] = struct.pack("!H", length)
2238 return ''.join(packed)
2239
2240 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002241 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002242 obj = packet_queue()
Dan Talaycof6202252013-07-02 01:00:29 -07002243 obj.queue_id = reader.read("!L")[0]
2244 obj.port = util.unpack_port_no(reader)
2245 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002246 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002247 reader = orig_reader.slice(_len, 10)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002248 reader.skip(6)
Rich Lanee2567702015-01-26 15:04:35 -08002249 obj.properties = loxi.generic_util.unpack_list(reader, ofp.common.queue_prop.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002250 return obj
2251
2252 def __eq__(self, other):
2253 if type(self) != type(other): return False
2254 if self.queue_id != other.queue_id: return False
2255 if self.port != other.port: return False
2256 if self.properties != other.properties: return False
2257 return True
2258
Rich Lanec2ee4b82013-04-24 17:12:38 -07002259 def pretty_print(self, q):
2260 q.text("packet_queue {")
2261 with q.group():
2262 with q.indent(2):
2263 q.breakable()
2264 q.text("queue_id = ");
2265 q.text("%#x" % self.queue_id)
2266 q.text(","); q.breakable()
2267 q.text("port = ");
2268 q.text(util.pretty_port(self.port))
2269 q.text(","); q.breakable()
2270 q.text("properties = ");
2271 q.pp(self.properties)
2272 q.breakable()
2273 q.text('}')
2274
Rich Lane7dcdf022013-12-11 14:45:27 -08002275
2276class port_desc(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002277
2278 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):
2279 if port_no != None:
2280 self.port_no = port_no
2281 else:
2282 self.port_no = 0
2283 if hw_addr != None:
2284 self.hw_addr = hw_addr
2285 else:
2286 self.hw_addr = [0,0,0,0,0,0]
2287 if name != None:
2288 self.name = name
2289 else:
2290 self.name = ""
2291 if config != None:
2292 self.config = config
2293 else:
2294 self.config = 0
2295 if state != None:
2296 self.state = state
2297 else:
2298 self.state = 0
2299 if curr != None:
2300 self.curr = curr
2301 else:
2302 self.curr = 0
2303 if advertised != None:
2304 self.advertised = advertised
2305 else:
2306 self.advertised = 0
2307 if supported != None:
2308 self.supported = supported
2309 else:
2310 self.supported = 0
2311 if peer != None:
2312 self.peer = peer
2313 else:
2314 self.peer = 0
2315 if curr_speed != None:
2316 self.curr_speed = curr_speed
2317 else:
2318 self.curr_speed = 0
2319 if max_speed != None:
2320 self.max_speed = max_speed
2321 else:
2322 self.max_speed = 0
2323 return
2324
2325 def pack(self):
2326 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07002327 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002328 packed.append('\x00' * 4)
2329 packed.append(struct.pack("!6B", *self.hw_addr))
2330 packed.append('\x00' * 2)
2331 packed.append(struct.pack("!16s", self.name))
2332 packed.append(struct.pack("!L", self.config))
2333 packed.append(struct.pack("!L", self.state))
2334 packed.append(struct.pack("!L", self.curr))
2335 packed.append(struct.pack("!L", self.advertised))
2336 packed.append(struct.pack("!L", self.supported))
2337 packed.append(struct.pack("!L", self.peer))
2338 packed.append(struct.pack("!L", self.curr_speed))
2339 packed.append(struct.pack("!L", self.max_speed))
2340 return ''.join(packed)
2341
2342 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002343 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002344 obj = port_desc()
Dan Talaycof6202252013-07-02 01:00:29 -07002345 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002346 reader.skip(4)
2347 obj.hw_addr = list(reader.read('!6B'))
2348 reader.skip(2)
2349 obj.name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -07002350 obj.config = reader.read("!L")[0]
2351 obj.state = reader.read("!L")[0]
2352 obj.curr = reader.read("!L")[0]
2353 obj.advertised = reader.read("!L")[0]
2354 obj.supported = reader.read("!L")[0]
2355 obj.peer = reader.read("!L")[0]
2356 obj.curr_speed = reader.read("!L")[0]
2357 obj.max_speed = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002358 return obj
2359
2360 def __eq__(self, other):
2361 if type(self) != type(other): return False
2362 if self.port_no != other.port_no: return False
2363 if self.hw_addr != other.hw_addr: return False
2364 if self.name != other.name: return False
2365 if self.config != other.config: return False
2366 if self.state != other.state: return False
2367 if self.curr != other.curr: return False
2368 if self.advertised != other.advertised: return False
2369 if self.supported != other.supported: return False
2370 if self.peer != other.peer: return False
2371 if self.curr_speed != other.curr_speed: return False
2372 if self.max_speed != other.max_speed: return False
2373 return True
2374
Rich Lanec2ee4b82013-04-24 17:12:38 -07002375 def pretty_print(self, q):
2376 q.text("port_desc {")
2377 with q.group():
2378 with q.indent(2):
2379 q.breakable()
2380 q.text("port_no = ");
2381 q.text(util.pretty_port(self.port_no))
2382 q.text(","); q.breakable()
2383 q.text("hw_addr = ");
2384 q.text(util.pretty_mac(self.hw_addr))
2385 q.text(","); q.breakable()
2386 q.text("name = ");
2387 q.pp(self.name)
2388 q.text(","); q.breakable()
2389 q.text("config = ");
2390 q.text("%#x" % self.config)
2391 q.text(","); q.breakable()
2392 q.text("state = ");
2393 q.text("%#x" % self.state)
2394 q.text(","); q.breakable()
2395 q.text("curr = ");
2396 q.text("%#x" % self.curr)
2397 q.text(","); q.breakable()
2398 q.text("advertised = ");
2399 q.text("%#x" % self.advertised)
2400 q.text(","); q.breakable()
2401 q.text("supported = ");
2402 q.text("%#x" % self.supported)
2403 q.text(","); q.breakable()
2404 q.text("peer = ");
2405 q.text("%#x" % self.peer)
2406 q.text(","); q.breakable()
2407 q.text("curr_speed = ");
2408 q.text("%#x" % self.curr_speed)
2409 q.text(","); q.breakable()
2410 q.text("max_speed = ");
2411 q.text("%#x" % self.max_speed)
2412 q.breakable()
2413 q.text('}')
2414
Rich Lane7dcdf022013-12-11 14:45:27 -08002415
2416class port_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002417
2418 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):
2419 if port_no != None:
2420 self.port_no = port_no
2421 else:
2422 self.port_no = 0
2423 if rx_packets != None:
2424 self.rx_packets = rx_packets
2425 else:
2426 self.rx_packets = 0
2427 if tx_packets != None:
2428 self.tx_packets = tx_packets
2429 else:
2430 self.tx_packets = 0
2431 if rx_bytes != None:
2432 self.rx_bytes = rx_bytes
2433 else:
2434 self.rx_bytes = 0
2435 if tx_bytes != None:
2436 self.tx_bytes = tx_bytes
2437 else:
2438 self.tx_bytes = 0
2439 if rx_dropped != None:
2440 self.rx_dropped = rx_dropped
2441 else:
2442 self.rx_dropped = 0
2443 if tx_dropped != None:
2444 self.tx_dropped = tx_dropped
2445 else:
2446 self.tx_dropped = 0
2447 if rx_errors != None:
2448 self.rx_errors = rx_errors
2449 else:
2450 self.rx_errors = 0
2451 if tx_errors != None:
2452 self.tx_errors = tx_errors
2453 else:
2454 self.tx_errors = 0
2455 if rx_frame_err != None:
2456 self.rx_frame_err = rx_frame_err
2457 else:
2458 self.rx_frame_err = 0
2459 if rx_over_err != None:
2460 self.rx_over_err = rx_over_err
2461 else:
2462 self.rx_over_err = 0
2463 if rx_crc_err != None:
2464 self.rx_crc_err = rx_crc_err
2465 else:
2466 self.rx_crc_err = 0
2467 if collisions != None:
2468 self.collisions = collisions
2469 else:
2470 self.collisions = 0
2471 if duration_sec != None:
2472 self.duration_sec = duration_sec
2473 else:
2474 self.duration_sec = 0
2475 if duration_nsec != None:
2476 self.duration_nsec = duration_nsec
2477 else:
2478 self.duration_nsec = 0
2479 return
2480
2481 def pack(self):
2482 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07002483 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002484 packed.append('\x00' * 4)
2485 packed.append(struct.pack("!Q", self.rx_packets))
2486 packed.append(struct.pack("!Q", self.tx_packets))
2487 packed.append(struct.pack("!Q", self.rx_bytes))
2488 packed.append(struct.pack("!Q", self.tx_bytes))
2489 packed.append(struct.pack("!Q", self.rx_dropped))
2490 packed.append(struct.pack("!Q", self.tx_dropped))
2491 packed.append(struct.pack("!Q", self.rx_errors))
2492 packed.append(struct.pack("!Q", self.tx_errors))
2493 packed.append(struct.pack("!Q", self.rx_frame_err))
2494 packed.append(struct.pack("!Q", self.rx_over_err))
2495 packed.append(struct.pack("!Q", self.rx_crc_err))
2496 packed.append(struct.pack("!Q", self.collisions))
2497 packed.append(struct.pack("!L", self.duration_sec))
2498 packed.append(struct.pack("!L", self.duration_nsec))
2499 return ''.join(packed)
2500
2501 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002502 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002503 obj = port_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07002504 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002505 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07002506 obj.rx_packets = reader.read("!Q")[0]
2507 obj.tx_packets = reader.read("!Q")[0]
2508 obj.rx_bytes = reader.read("!Q")[0]
2509 obj.tx_bytes = reader.read("!Q")[0]
2510 obj.rx_dropped = reader.read("!Q")[0]
2511 obj.tx_dropped = reader.read("!Q")[0]
2512 obj.rx_errors = reader.read("!Q")[0]
2513 obj.tx_errors = reader.read("!Q")[0]
2514 obj.rx_frame_err = reader.read("!Q")[0]
2515 obj.rx_over_err = reader.read("!Q")[0]
2516 obj.rx_crc_err = reader.read("!Q")[0]
2517 obj.collisions = reader.read("!Q")[0]
2518 obj.duration_sec = reader.read("!L")[0]
2519 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002520 return obj
2521
2522 def __eq__(self, other):
2523 if type(self) != type(other): return False
2524 if self.port_no != other.port_no: return False
2525 if self.rx_packets != other.rx_packets: return False
2526 if self.tx_packets != other.tx_packets: return False
2527 if self.rx_bytes != other.rx_bytes: return False
2528 if self.tx_bytes != other.tx_bytes: return False
2529 if self.rx_dropped != other.rx_dropped: return False
2530 if self.tx_dropped != other.tx_dropped: return False
2531 if self.rx_errors != other.rx_errors: return False
2532 if self.tx_errors != other.tx_errors: return False
2533 if self.rx_frame_err != other.rx_frame_err: return False
2534 if self.rx_over_err != other.rx_over_err: return False
2535 if self.rx_crc_err != other.rx_crc_err: return False
2536 if self.collisions != other.collisions: return False
2537 if self.duration_sec != other.duration_sec: return False
2538 if self.duration_nsec != other.duration_nsec: return False
2539 return True
2540
Rich Lanec2ee4b82013-04-24 17:12:38 -07002541 def pretty_print(self, q):
2542 q.text("port_stats_entry {")
2543 with q.group():
2544 with q.indent(2):
2545 q.breakable()
2546 q.text("port_no = ");
2547 q.text(util.pretty_port(self.port_no))
2548 q.text(","); q.breakable()
2549 q.text("rx_packets = ");
2550 q.text("%#x" % self.rx_packets)
2551 q.text(","); q.breakable()
2552 q.text("tx_packets = ");
2553 q.text("%#x" % self.tx_packets)
2554 q.text(","); q.breakable()
2555 q.text("rx_bytes = ");
2556 q.text("%#x" % self.rx_bytes)
2557 q.text(","); q.breakable()
2558 q.text("tx_bytes = ");
2559 q.text("%#x" % self.tx_bytes)
2560 q.text(","); q.breakable()
2561 q.text("rx_dropped = ");
2562 q.text("%#x" % self.rx_dropped)
2563 q.text(","); q.breakable()
2564 q.text("tx_dropped = ");
2565 q.text("%#x" % self.tx_dropped)
2566 q.text(","); q.breakable()
2567 q.text("rx_errors = ");
2568 q.text("%#x" % self.rx_errors)
2569 q.text(","); q.breakable()
2570 q.text("tx_errors = ");
2571 q.text("%#x" % self.tx_errors)
2572 q.text(","); q.breakable()
2573 q.text("rx_frame_err = ");
2574 q.text("%#x" % self.rx_frame_err)
2575 q.text(","); q.breakable()
2576 q.text("rx_over_err = ");
2577 q.text("%#x" % self.rx_over_err)
2578 q.text(","); q.breakable()
2579 q.text("rx_crc_err = ");
2580 q.text("%#x" % self.rx_crc_err)
2581 q.text(","); q.breakable()
2582 q.text("collisions = ");
2583 q.text("%#x" % self.collisions)
2584 q.text(","); q.breakable()
2585 q.text("duration_sec = ");
2586 q.text("%#x" % self.duration_sec)
2587 q.text(","); q.breakable()
2588 q.text("duration_nsec = ");
2589 q.text("%#x" % self.duration_nsec)
2590 q.breakable()
2591 q.text('}')
2592
Rich Lane7dcdf022013-12-11 14:45:27 -08002593
2594class queue_prop(loxi.OFObject):
2595 subtypes = {}
2596
Rich Lane95f7fc92014-01-27 17:08:16 -08002597
2598 def __init__(self, type=None):
2599 if type != None:
2600 self.type = type
2601 else:
2602 self.type = 0
2603 return
2604
2605 def pack(self):
2606 packed = []
2607 packed.append(struct.pack("!H", self.type))
2608 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2609 packed.append('\x00' * 4)
2610 length = sum([len(x) for x in packed])
2611 packed[1] = struct.pack("!H", length)
2612 return ''.join(packed)
2613
Rich Lane7dcdf022013-12-11 14:45:27 -08002614 @staticmethod
2615 def unpack(reader):
2616 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -08002617 subclass = queue_prop.subtypes.get(subtype)
2618 if subclass:
2619 return subclass.unpack(reader)
2620
2621 obj = queue_prop()
2622 obj.type = reader.read("!H")[0]
2623 _len = reader.read("!H")[0]
2624 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002625 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -08002626 reader.skip(4)
2627 return obj
2628
2629 def __eq__(self, other):
2630 if type(self) != type(other): return False
2631 if self.type != other.type: return False
2632 return True
2633
2634 def pretty_print(self, q):
2635 q.text("queue_prop {")
2636 with q.group():
2637 with q.indent(2):
2638 q.breakable()
2639 q.breakable()
2640 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002641
2642
2643class queue_prop_experimenter(queue_prop):
2644 subtypes = {}
2645
Rich Lane95f7fc92014-01-27 17:08:16 -08002646 type = 65535
2647
2648 def __init__(self, experimenter=None, data=None):
2649 if experimenter != None:
2650 self.experimenter = experimenter
2651 else:
2652 self.experimenter = 0
2653 if data != None:
2654 self.data = data
2655 else:
2656 self.data = ''
2657 return
2658
2659 def pack(self):
2660 packed = []
2661 packed.append(struct.pack("!H", self.type))
2662 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2663 packed.append('\x00' * 4)
2664 packed.append(struct.pack("!L", self.experimenter))
2665 packed.append('\x00' * 4)
2666 packed.append(self.data)
2667 length = sum([len(x) for x in packed])
2668 packed[1] = struct.pack("!H", length)
2669 return ''.join(packed)
2670
Rich Lane7dcdf022013-12-11 14:45:27 -08002671 @staticmethod
2672 def unpack(reader):
2673 subtype, = reader.peek('!L', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -08002674 subclass = queue_prop_experimenter.subtypes.get(subtype)
2675 if subclass:
2676 return subclass.unpack(reader)
2677
2678 obj = queue_prop_experimenter()
2679 _type = reader.read("!H")[0]
2680 assert(_type == 65535)
2681 _len = reader.read("!H")[0]
2682 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002683 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -08002684 reader.skip(4)
2685 obj.experimenter = reader.read("!L")[0]
2686 reader.skip(4)
2687 obj.data = str(reader.read_all())
2688 return obj
2689
2690 def __eq__(self, other):
2691 if type(self) != type(other): return False
2692 if self.experimenter != other.experimenter: return False
2693 if self.data != other.data: return False
2694 return True
2695
2696 def pretty_print(self, q):
2697 q.text("queue_prop_experimenter {")
2698 with q.group():
2699 with q.indent(2):
2700 q.breakable()
2701 q.text("data = ");
2702 q.pp(self.data)
2703 q.breakable()
2704 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002705
2706queue_prop.subtypes[65535] = queue_prop_experimenter
2707
2708class queue_prop_max_rate(queue_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002709 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07002710
2711 def __init__(self, rate=None):
2712 if rate != None:
2713 self.rate = rate
2714 else:
2715 self.rate = 0
2716 return
2717
2718 def pack(self):
2719 packed = []
2720 packed.append(struct.pack("!H", self.type))
2721 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2722 packed.append('\x00' * 4)
2723 packed.append(struct.pack("!H", self.rate))
2724 packed.append('\x00' * 6)
2725 length = sum([len(x) for x in packed])
2726 packed[1] = struct.pack("!H", length)
2727 return ''.join(packed)
2728
2729 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002730 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002731 obj = queue_prop_max_rate()
Dan Talaycof6202252013-07-02 01:00:29 -07002732 _type = reader.read("!H")[0]
2733 assert(_type == 2)
2734 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002735 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002736 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002737 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07002738 obj.rate = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002739 reader.skip(6)
2740 return obj
2741
2742 def __eq__(self, other):
2743 if type(self) != type(other): return False
2744 if self.rate != other.rate: return False
2745 return True
2746
Rich Lanec2ee4b82013-04-24 17:12:38 -07002747 def pretty_print(self, q):
2748 q.text("queue_prop_max_rate {")
2749 with q.group():
2750 with q.indent(2):
2751 q.breakable()
2752 q.text("rate = ");
2753 q.text("%#x" % self.rate)
2754 q.breakable()
2755 q.text('}')
2756
Rich Lane7dcdf022013-12-11 14:45:27 -08002757queue_prop.subtypes[2] = queue_prop_max_rate
2758
2759class queue_prop_min_rate(queue_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002760 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07002761
2762 def __init__(self, rate=None):
2763 if rate != None:
2764 self.rate = rate
2765 else:
2766 self.rate = 0
2767 return
2768
2769 def pack(self):
2770 packed = []
2771 packed.append(struct.pack("!H", self.type))
2772 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2773 packed.append('\x00' * 4)
2774 packed.append(struct.pack("!H", self.rate))
2775 packed.append('\x00' * 6)
2776 length = sum([len(x) for x in packed])
2777 packed[1] = struct.pack("!H", length)
2778 return ''.join(packed)
2779
2780 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002781 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002782 obj = queue_prop_min_rate()
Dan Talaycof6202252013-07-02 01:00:29 -07002783 _type = reader.read("!H")[0]
2784 assert(_type == 1)
2785 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002786 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002787 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002788 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07002789 obj.rate = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002790 reader.skip(6)
2791 return obj
2792
2793 def __eq__(self, other):
2794 if type(self) != type(other): return False
2795 if self.rate != other.rate: return False
2796 return True
2797
Rich Lanec2ee4b82013-04-24 17:12:38 -07002798 def pretty_print(self, q):
2799 q.text("queue_prop_min_rate {")
2800 with q.group():
2801 with q.indent(2):
2802 q.breakable()
2803 q.text("rate = ");
2804 q.text("%#x" % self.rate)
2805 q.breakable()
2806 q.text('}')
2807
Rich Lane7dcdf022013-12-11 14:45:27 -08002808queue_prop.subtypes[1] = queue_prop_min_rate
2809
2810class queue_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002811
2812 def __init__(self, port_no=None, queue_id=None, tx_bytes=None, tx_packets=None, tx_errors=None, duration_sec=None, duration_nsec=None):
2813 if port_no != None:
2814 self.port_no = port_no
2815 else:
2816 self.port_no = 0
2817 if queue_id != None:
2818 self.queue_id = queue_id
2819 else:
2820 self.queue_id = 0
2821 if tx_bytes != None:
2822 self.tx_bytes = tx_bytes
2823 else:
2824 self.tx_bytes = 0
2825 if tx_packets != None:
2826 self.tx_packets = tx_packets
2827 else:
2828 self.tx_packets = 0
2829 if tx_errors != None:
2830 self.tx_errors = tx_errors
2831 else:
2832 self.tx_errors = 0
2833 if duration_sec != None:
2834 self.duration_sec = duration_sec
2835 else:
2836 self.duration_sec = 0
2837 if duration_nsec != None:
2838 self.duration_nsec = duration_nsec
2839 else:
2840 self.duration_nsec = 0
2841 return
2842
2843 def pack(self):
2844 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07002845 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002846 packed.append(struct.pack("!L", self.queue_id))
2847 packed.append(struct.pack("!Q", self.tx_bytes))
2848 packed.append(struct.pack("!Q", self.tx_packets))
2849 packed.append(struct.pack("!Q", self.tx_errors))
2850 packed.append(struct.pack("!L", self.duration_sec))
2851 packed.append(struct.pack("!L", self.duration_nsec))
2852 return ''.join(packed)
2853
2854 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002855 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002856 obj = queue_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07002857 obj.port_no = util.unpack_port_no(reader)
2858 obj.queue_id = reader.read("!L")[0]
2859 obj.tx_bytes = reader.read("!Q")[0]
2860 obj.tx_packets = reader.read("!Q")[0]
2861 obj.tx_errors = reader.read("!Q")[0]
2862 obj.duration_sec = reader.read("!L")[0]
2863 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002864 return obj
2865
2866 def __eq__(self, other):
2867 if type(self) != type(other): return False
2868 if self.port_no != other.port_no: return False
2869 if self.queue_id != other.queue_id: return False
2870 if self.tx_bytes != other.tx_bytes: return False
2871 if self.tx_packets != other.tx_packets: return False
2872 if self.tx_errors != other.tx_errors: return False
2873 if self.duration_sec != other.duration_sec: return False
2874 if self.duration_nsec != other.duration_nsec: return False
2875 return True
2876
Rich Lanec2ee4b82013-04-24 17:12:38 -07002877 def pretty_print(self, q):
2878 q.text("queue_stats_entry {")
2879 with q.group():
2880 with q.indent(2):
2881 q.breakable()
2882 q.text("port_no = ");
2883 q.text(util.pretty_port(self.port_no))
2884 q.text(","); q.breakable()
2885 q.text("queue_id = ");
2886 q.text("%#x" % self.queue_id)
2887 q.text(","); q.breakable()
2888 q.text("tx_bytes = ");
2889 q.text("%#x" % self.tx_bytes)
2890 q.text(","); q.breakable()
2891 q.text("tx_packets = ");
2892 q.text("%#x" % self.tx_packets)
2893 q.text(","); q.breakable()
2894 q.text("tx_errors = ");
2895 q.text("%#x" % self.tx_errors)
2896 q.text(","); q.breakable()
2897 q.text("duration_sec = ");
2898 q.text("%#x" % self.duration_sec)
2899 q.text(","); q.breakable()
2900 q.text("duration_nsec = ");
2901 q.text("%#x" % self.duration_nsec)
2902 q.breakable()
2903 q.text('}')
2904
Rich Lane7dcdf022013-12-11 14:45:27 -08002905
2906class table_feature_prop(loxi.OFObject):
2907 subtypes = {}
2908
Rich Lane95f7fc92014-01-27 17:08:16 -08002909
2910 def __init__(self, type=None):
2911 if type != None:
2912 self.type = type
2913 else:
2914 self.type = 0
2915 return
2916
2917 def pack(self):
2918 packed = []
2919 packed.append(struct.pack("!H", self.type))
2920 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
2921 length = sum([len(x) for x in packed])
2922 packed[1] = struct.pack("!H", length)
2923 return ''.join(packed)
2924
Rich Lane7dcdf022013-12-11 14:45:27 -08002925 @staticmethod
2926 def unpack(reader):
2927 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -08002928 subclass = table_feature_prop.subtypes.get(subtype)
2929 if subclass:
2930 return subclass.unpack(reader)
2931
2932 obj = table_feature_prop()
2933 obj.type = reader.read("!H")[0]
2934 _length = reader.read("!H")[0]
2935 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002936 reader = orig_reader.slice(_length, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -08002937 return obj
2938
2939 def __eq__(self, other):
2940 if type(self) != type(other): return False
2941 if self.type != other.type: return False
2942 return True
2943
2944 def pretty_print(self, q):
2945 q.text("table_feature_prop {")
2946 with q.group():
2947 with q.indent(2):
2948 q.breakable()
2949 q.breakable()
2950 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08002951
2952
2953class table_feature_prop_apply_actions(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002954 type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07002955
Dan Talaycof6202252013-07-02 01:00:29 -07002956 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002957 if action_ids != None:
2958 self.action_ids = action_ids
2959 else:
2960 self.action_ids = []
2961 return
2962
2963 def pack(self):
2964 packed = []
2965 packed.append(struct.pack("!H", self.type))
2966 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002967 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002968 length = sum([len(x) for x in packed])
2969 packed[1] = struct.pack("!H", length)
Rich Lane51168312015-06-25 13:13:54 -07002970 packed.append(loxi.generic_util.pad_to(8, length))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002971 return ''.join(packed)
2972
2973 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002974 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002975 obj = table_feature_prop_apply_actions()
Dan Talaycof6202252013-07-02 01:00:29 -07002976 _type = reader.read("!H")[0]
2977 assert(_type == 6)
2978 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002979 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08002980 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08002981 obj.action_ids = loxi.generic_util.unpack_list(reader, ofp.action_id.action_id.unpack)
Rich Lane51168312015-06-25 13:13:54 -07002982 orig_reader.skip_align()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002983 return obj
2984
2985 def __eq__(self, other):
2986 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002987 if self.action_ids != other.action_ids: return False
2988 return True
2989
Rich Lanec2ee4b82013-04-24 17:12:38 -07002990 def pretty_print(self, q):
2991 q.text("table_feature_prop_apply_actions {")
2992 with q.group():
2993 with q.indent(2):
2994 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002995 q.text("action_ids = ");
2996 q.pp(self.action_ids)
2997 q.breakable()
2998 q.text('}')
2999
Rich Lane7dcdf022013-12-11 14:45:27 -08003000table_feature_prop.subtypes[6] = table_feature_prop_apply_actions
3001
3002class table_feature_prop_apply_actions_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003003 type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07003004
Dan Talaycof6202252013-07-02 01:00:29 -07003005 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003006 if action_ids != None:
3007 self.action_ids = action_ids
3008 else:
3009 self.action_ids = []
3010 return
3011
3012 def pack(self):
3013 packed = []
3014 packed.append(struct.pack("!H", self.type))
3015 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003016 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003017 length = sum([len(x) for x in packed])
3018 packed[1] = struct.pack("!H", length)
Rich Lane51168312015-06-25 13:13:54 -07003019 packed.append(loxi.generic_util.pad_to(8, length))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003020 return ''.join(packed)
3021
3022 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003023 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003024 obj = table_feature_prop_apply_actions_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07003025 _type = reader.read("!H")[0]
3026 assert(_type == 7)
3027 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003028 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003029 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08003030 obj.action_ids = loxi.generic_util.unpack_list(reader, ofp.action_id.action_id.unpack)
Rich Lane51168312015-06-25 13:13:54 -07003031 orig_reader.skip_align()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003032 return obj
3033
3034 def __eq__(self, other):
3035 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003036 if self.action_ids != other.action_ids: return False
3037 return True
3038
Rich Lanec2ee4b82013-04-24 17:12:38 -07003039 def pretty_print(self, q):
3040 q.text("table_feature_prop_apply_actions_miss {")
3041 with q.group():
3042 with q.indent(2):
3043 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003044 q.text("action_ids = ");
3045 q.pp(self.action_ids)
3046 q.breakable()
3047 q.text('}')
3048
Rich Lane7dcdf022013-12-11 14:45:27 -08003049table_feature_prop.subtypes[7] = table_feature_prop_apply_actions_miss
3050
3051class table_feature_prop_apply_setfield(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003052 type = 14
Rich Lanec2ee4b82013-04-24 17:12:38 -07003053
Dan Talaycof6202252013-07-02 01:00:29 -07003054 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003055 if oxm_ids != None:
3056 self.oxm_ids = oxm_ids
3057 else:
3058 self.oxm_ids = []
3059 return
3060
3061 def pack(self):
3062 packed = []
3063 packed.append(struct.pack("!H", self.type))
3064 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003065 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003066 length = sum([len(x) for x in packed])
3067 packed[1] = struct.pack("!H", length)
Rich Lane51168312015-06-25 13:13:54 -07003068 packed.append(loxi.generic_util.pad_to(8, length))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003069 return ''.join(packed)
3070
3071 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003072 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003073 obj = table_feature_prop_apply_setfield()
Dan Talaycof6202252013-07-02 01:00:29 -07003074 _type = reader.read("!H")[0]
3075 assert(_type == 14)
3076 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003077 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003078 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08003079 obj.oxm_ids = loxi.generic_util.unpack_list(reader, ofp.common.uint32.unpack)
Rich Lane51168312015-06-25 13:13:54 -07003080 orig_reader.skip_align()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003081 return obj
3082
3083 def __eq__(self, other):
3084 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003085 if self.oxm_ids != other.oxm_ids: return False
3086 return True
3087
Rich Lanec2ee4b82013-04-24 17:12:38 -07003088 def pretty_print(self, q):
3089 q.text("table_feature_prop_apply_setfield {")
3090 with q.group():
3091 with q.indent(2):
3092 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003093 q.text("oxm_ids = ");
3094 q.pp(self.oxm_ids)
3095 q.breakable()
3096 q.text('}')
3097
Rich Lane7dcdf022013-12-11 14:45:27 -08003098table_feature_prop.subtypes[14] = table_feature_prop_apply_setfield
3099
3100class table_feature_prop_apply_setfield_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003101 type = 15
Rich Lanec2ee4b82013-04-24 17:12:38 -07003102
Dan Talaycof6202252013-07-02 01:00:29 -07003103 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003104 if oxm_ids != None:
3105 self.oxm_ids = oxm_ids
3106 else:
3107 self.oxm_ids = []
3108 return
3109
3110 def pack(self):
3111 packed = []
3112 packed.append(struct.pack("!H", self.type))
3113 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003114 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003115 length = sum([len(x) for x in packed])
3116 packed[1] = struct.pack("!H", length)
Rich Lane51168312015-06-25 13:13:54 -07003117 packed.append(loxi.generic_util.pad_to(8, length))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003118 return ''.join(packed)
3119
3120 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003121 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003122 obj = table_feature_prop_apply_setfield_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07003123 _type = reader.read("!H")[0]
3124 assert(_type == 15)
3125 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003126 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003127 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08003128 obj.oxm_ids = loxi.generic_util.unpack_list(reader, ofp.common.uint32.unpack)
Rich Lane51168312015-06-25 13:13:54 -07003129 orig_reader.skip_align()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003130 return obj
3131
3132 def __eq__(self, other):
3133 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003134 if self.oxm_ids != other.oxm_ids: return False
3135 return True
3136
Rich Lanec2ee4b82013-04-24 17:12:38 -07003137 def pretty_print(self, q):
3138 q.text("table_feature_prop_apply_setfield_miss {")
3139 with q.group():
3140 with q.indent(2):
3141 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003142 q.text("oxm_ids = ");
3143 q.pp(self.oxm_ids)
3144 q.breakable()
3145 q.text('}')
3146
Rich Lane7dcdf022013-12-11 14:45:27 -08003147table_feature_prop.subtypes[15] = table_feature_prop_apply_setfield_miss
3148
3149class table_feature_prop_experimenter(table_feature_prop):
Rich Lane2e079da2014-10-29 15:30:24 -07003150 subtypes = {}
3151
Rich Lane9ec3fca2014-02-26 16:22:56 -08003152 type = 65534
Rich Lanec2ee4b82013-04-24 17:12:38 -07003153
Dan Talaycof6202252013-07-02 01:00:29 -07003154 def __init__(self, experimenter=None, subtype=None, experimenter_data=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003155 if experimenter != None:
3156 self.experimenter = experimenter
3157 else:
3158 self.experimenter = 0
3159 if subtype != None:
3160 self.subtype = subtype
3161 else:
3162 self.subtype = 0
3163 if experimenter_data != None:
3164 self.experimenter_data = experimenter_data
3165 else:
Dan Talaycof6202252013-07-02 01:00:29 -07003166 self.experimenter_data = ''
Rich Lanec2ee4b82013-04-24 17:12:38 -07003167 return
3168
3169 def pack(self):
3170 packed = []
3171 packed.append(struct.pack("!H", self.type))
3172 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
3173 packed.append(struct.pack("!L", self.experimenter))
3174 packed.append(struct.pack("!L", self.subtype))
3175 packed.append(self.experimenter_data)
3176 length = sum([len(x) for x in packed])
3177 packed[1] = struct.pack("!H", length)
Rich Lane51168312015-06-25 13:13:54 -07003178 packed.append(loxi.generic_util.pad_to(8, length))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003179 return ''.join(packed)
3180
3181 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003182 def unpack(reader):
Rich Lane2e079da2014-10-29 15:30:24 -07003183 subtype, = reader.peek('!L', 4)
3184 subclass = table_feature_prop_experimenter.subtypes.get(subtype)
3185 if subclass:
3186 return subclass.unpack(reader)
3187
Rich Lanec2ee4b82013-04-24 17:12:38 -07003188 obj = table_feature_prop_experimenter()
Dan Talaycof6202252013-07-02 01:00:29 -07003189 _type = reader.read("!H")[0]
Rich Lane9ec3fca2014-02-26 16:22:56 -08003190 assert(_type == 65534)
Dan Talaycof6202252013-07-02 01:00:29 -07003191 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003192 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003193 reader = orig_reader.slice(_length, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07003194 obj.experimenter = reader.read("!L")[0]
3195 obj.subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003196 obj.experimenter_data = str(reader.read_all())
Rich Lane51168312015-06-25 13:13:54 -07003197 orig_reader.skip_align()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003198 return obj
3199
3200 def __eq__(self, other):
3201 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003202 if self.experimenter != other.experimenter: return False
3203 if self.subtype != other.subtype: return False
3204 if self.experimenter_data != other.experimenter_data: return False
3205 return True
3206
Rich Lanec2ee4b82013-04-24 17:12:38 -07003207 def pretty_print(self, q):
3208 q.text("table_feature_prop_experimenter {")
3209 with q.group():
3210 with q.indent(2):
3211 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003212 q.text("subtype = ");
3213 q.text("%#x" % self.subtype)
3214 q.text(","); q.breakable()
3215 q.text("experimenter_data = ");
3216 q.pp(self.experimenter_data)
3217 q.breakable()
3218 q.text('}')
3219
Rich Lane9ec3fca2014-02-26 16:22:56 -08003220table_feature_prop.subtypes[65534] = table_feature_prop_experimenter
3221
3222class table_feature_prop_experimenter_miss(table_feature_prop):
Rich Lane2e079da2014-10-29 15:30:24 -07003223 subtypes = {}
3224
Rich Lane9ec3fca2014-02-26 16:22:56 -08003225 type = 65535
3226
3227 def __init__(self, experimenter=None, subtype=None, experimenter_data=None):
3228 if experimenter != None:
3229 self.experimenter = experimenter
3230 else:
3231 self.experimenter = 0
3232 if subtype != None:
3233 self.subtype = subtype
3234 else:
3235 self.subtype = 0
3236 if experimenter_data != None:
3237 self.experimenter_data = experimenter_data
3238 else:
3239 self.experimenter_data = ''
3240 return
3241
3242 def pack(self):
3243 packed = []
3244 packed.append(struct.pack("!H", self.type))
3245 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
3246 packed.append(struct.pack("!L", self.experimenter))
3247 packed.append(struct.pack("!L", self.subtype))
3248 packed.append(self.experimenter_data)
3249 length = sum([len(x) for x in packed])
3250 packed[1] = struct.pack("!H", length)
Rich Lane51168312015-06-25 13:13:54 -07003251 packed.append(loxi.generic_util.pad_to(8, length))
Rich Lane9ec3fca2014-02-26 16:22:56 -08003252 return ''.join(packed)
3253
3254 @staticmethod
3255 def unpack(reader):
Rich Lane2e079da2014-10-29 15:30:24 -07003256 subtype, = reader.peek('!L', 4)
3257 subclass = table_feature_prop_experimenter_miss.subtypes.get(subtype)
3258 if subclass:
3259 return subclass.unpack(reader)
3260
Rich Lane9ec3fca2014-02-26 16:22:56 -08003261 obj = table_feature_prop_experimenter_miss()
3262 _type = reader.read("!H")[0]
3263 assert(_type == 65535)
3264 _length = reader.read("!H")[0]
3265 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003266 reader = orig_reader.slice(_length, 4)
Rich Lane9ec3fca2014-02-26 16:22:56 -08003267 obj.experimenter = reader.read("!L")[0]
3268 obj.subtype = reader.read("!L")[0]
3269 obj.experimenter_data = str(reader.read_all())
Rich Lane51168312015-06-25 13:13:54 -07003270 orig_reader.skip_align()
Rich Lane9ec3fca2014-02-26 16:22:56 -08003271 return obj
3272
3273 def __eq__(self, other):
3274 if type(self) != type(other): return False
3275 if self.experimenter != other.experimenter: return False
3276 if self.subtype != other.subtype: return False
3277 if self.experimenter_data != other.experimenter_data: return False
3278 return True
3279
3280 def pretty_print(self, q):
3281 q.text("table_feature_prop_experimenter_miss {")
3282 with q.group():
3283 with q.indent(2):
3284 q.breakable()
Rich Lane9ec3fca2014-02-26 16:22:56 -08003285 q.text("subtype = ");
3286 q.text("%#x" % self.subtype)
3287 q.text(","); q.breakable()
3288 q.text("experimenter_data = ");
3289 q.pp(self.experimenter_data)
3290 q.breakable()
3291 q.text('}')
3292
3293table_feature_prop.subtypes[65535] = table_feature_prop_experimenter_miss
Rich Lane7dcdf022013-12-11 14:45:27 -08003294
3295class table_feature_prop_instructions(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003296 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07003297
Dan Talaycof6202252013-07-02 01:00:29 -07003298 def __init__(self, instruction_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003299 if instruction_ids != None:
3300 self.instruction_ids = instruction_ids
3301 else:
3302 self.instruction_ids = []
3303 return
3304
3305 def pack(self):
3306 packed = []
3307 packed.append(struct.pack("!H", self.type))
3308 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003309 packed.append(loxi.generic_util.pack_list(self.instruction_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003310 length = sum([len(x) for x in packed])
3311 packed[1] = struct.pack("!H", length)
Rich Lane51168312015-06-25 13:13:54 -07003312 packed.append(loxi.generic_util.pad_to(8, length))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003313 return ''.join(packed)
3314
3315 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003316 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003317 obj = table_feature_prop_instructions()
Dan Talaycof6202252013-07-02 01:00:29 -07003318 _type = reader.read("!H")[0]
3319 assert(_type == 0)
3320 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003321 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003322 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08003323 obj.instruction_ids = loxi.generic_util.unpack_list(reader, ofp.instruction_id.instruction_id.unpack)
Rich Lane51168312015-06-25 13:13:54 -07003324 orig_reader.skip_align()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003325 return obj
3326
3327 def __eq__(self, other):
3328 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003329 if self.instruction_ids != other.instruction_ids: return False
3330 return True
3331
Rich Lanec2ee4b82013-04-24 17:12:38 -07003332 def pretty_print(self, q):
3333 q.text("table_feature_prop_instructions {")
3334 with q.group():
3335 with q.indent(2):
3336 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003337 q.text("instruction_ids = ");
3338 q.pp(self.instruction_ids)
3339 q.breakable()
3340 q.text('}')
3341
Rich Lane7dcdf022013-12-11 14:45:27 -08003342table_feature_prop.subtypes[0] = table_feature_prop_instructions
3343
3344class table_feature_prop_instructions_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003345 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07003346
Dan Talaycof6202252013-07-02 01:00:29 -07003347 def __init__(self, instruction_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003348 if instruction_ids != None:
3349 self.instruction_ids = instruction_ids
3350 else:
3351 self.instruction_ids = []
3352 return
3353
3354 def pack(self):
3355 packed = []
3356 packed.append(struct.pack("!H", self.type))
3357 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003358 packed.append(loxi.generic_util.pack_list(self.instruction_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003359 length = sum([len(x) for x in packed])
3360 packed[1] = struct.pack("!H", length)
Rich Lane51168312015-06-25 13:13:54 -07003361 packed.append(loxi.generic_util.pad_to(8, length))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003362 return ''.join(packed)
3363
3364 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003365 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003366 obj = table_feature_prop_instructions_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07003367 _type = reader.read("!H")[0]
3368 assert(_type == 1)
3369 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003370 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003371 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08003372 obj.instruction_ids = loxi.generic_util.unpack_list(reader, ofp.instruction_id.instruction_id.unpack)
Rich Lane51168312015-06-25 13:13:54 -07003373 orig_reader.skip_align()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003374 return obj
3375
3376 def __eq__(self, other):
3377 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003378 if self.instruction_ids != other.instruction_ids: return False
3379 return True
3380
Rich Lanec2ee4b82013-04-24 17:12:38 -07003381 def pretty_print(self, q):
3382 q.text("table_feature_prop_instructions_miss {")
3383 with q.group():
3384 with q.indent(2):
3385 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003386 q.text("instruction_ids = ");
3387 q.pp(self.instruction_ids)
3388 q.breakable()
3389 q.text('}')
3390
Rich Lane7dcdf022013-12-11 14:45:27 -08003391table_feature_prop.subtypes[1] = table_feature_prop_instructions_miss
3392
3393class table_feature_prop_match(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003394 type = 8
Rich Lanec2ee4b82013-04-24 17:12:38 -07003395
Dan Talaycof6202252013-07-02 01:00:29 -07003396 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003397 if oxm_ids != None:
3398 self.oxm_ids = oxm_ids
3399 else:
3400 self.oxm_ids = []
3401 return
3402
3403 def pack(self):
3404 packed = []
3405 packed.append(struct.pack("!H", self.type))
3406 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003407 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003408 length = sum([len(x) for x in packed])
3409 packed[1] = struct.pack("!H", length)
Rich Lane51168312015-06-25 13:13:54 -07003410 packed.append(loxi.generic_util.pad_to(8, length))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003411 return ''.join(packed)
3412
3413 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003414 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003415 obj = table_feature_prop_match()
Dan Talaycof6202252013-07-02 01:00:29 -07003416 _type = reader.read("!H")[0]
3417 assert(_type == 8)
3418 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003419 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003420 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08003421 obj.oxm_ids = loxi.generic_util.unpack_list(reader, ofp.common.uint32.unpack)
Rich Lane51168312015-06-25 13:13:54 -07003422 orig_reader.skip_align()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003423 return obj
3424
3425 def __eq__(self, other):
3426 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003427 if self.oxm_ids != other.oxm_ids: return False
3428 return True
3429
Rich Lanec2ee4b82013-04-24 17:12:38 -07003430 def pretty_print(self, q):
3431 q.text("table_feature_prop_match {")
3432 with q.group():
3433 with q.indent(2):
3434 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003435 q.text("oxm_ids = ");
3436 q.pp(self.oxm_ids)
3437 q.breakable()
3438 q.text('}')
3439
Rich Lane7dcdf022013-12-11 14:45:27 -08003440table_feature_prop.subtypes[8] = table_feature_prop_match
3441
3442class table_feature_prop_next_tables(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003443 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07003444
Dan Talaycof6202252013-07-02 01:00:29 -07003445 def __init__(self, next_table_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003446 if next_table_ids != None:
3447 self.next_table_ids = next_table_ids
3448 else:
3449 self.next_table_ids = []
3450 return
3451
3452 def pack(self):
3453 packed = []
3454 packed.append(struct.pack("!H", self.type))
3455 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003456 packed.append(loxi.generic_util.pack_list(self.next_table_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003457 length = sum([len(x) for x in packed])
3458 packed[1] = struct.pack("!H", length)
Rich Lane51168312015-06-25 13:13:54 -07003459 packed.append(loxi.generic_util.pad_to(8, length))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003460 return ''.join(packed)
3461
3462 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003463 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003464 obj = table_feature_prop_next_tables()
Dan Talaycof6202252013-07-02 01:00:29 -07003465 _type = reader.read("!H")[0]
3466 assert(_type == 2)
3467 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003468 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003469 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08003470 obj.next_table_ids = loxi.generic_util.unpack_list(reader, ofp.common.uint8.unpack)
Rich Lane51168312015-06-25 13:13:54 -07003471 orig_reader.skip_align()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003472 return obj
3473
3474 def __eq__(self, other):
3475 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003476 if self.next_table_ids != other.next_table_ids: return False
3477 return True
3478
Rich Lanec2ee4b82013-04-24 17:12:38 -07003479 def pretty_print(self, q):
3480 q.text("table_feature_prop_next_tables {")
3481 with q.group():
3482 with q.indent(2):
3483 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003484 q.text("next_table_ids = ");
3485 q.pp(self.next_table_ids)
3486 q.breakable()
3487 q.text('}')
3488
Rich Lane7dcdf022013-12-11 14:45:27 -08003489table_feature_prop.subtypes[2] = table_feature_prop_next_tables
3490
3491class table_feature_prop_next_tables_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003492 type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07003493
Dan Talaycof6202252013-07-02 01:00:29 -07003494 def __init__(self, next_table_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003495 if next_table_ids != None:
3496 self.next_table_ids = next_table_ids
3497 else:
3498 self.next_table_ids = []
3499 return
3500
3501 def pack(self):
3502 packed = []
3503 packed.append(struct.pack("!H", self.type))
3504 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003505 packed.append(loxi.generic_util.pack_list(self.next_table_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003506 length = sum([len(x) for x in packed])
3507 packed[1] = struct.pack("!H", length)
Rich Lane51168312015-06-25 13:13:54 -07003508 packed.append(loxi.generic_util.pad_to(8, length))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003509 return ''.join(packed)
3510
3511 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003512 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003513 obj = table_feature_prop_next_tables_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07003514 _type = reader.read("!H")[0]
3515 assert(_type == 3)
3516 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003517 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003518 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08003519 obj.next_table_ids = loxi.generic_util.unpack_list(reader, ofp.common.uint8.unpack)
Rich Lane51168312015-06-25 13:13:54 -07003520 orig_reader.skip_align()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003521 return obj
3522
3523 def __eq__(self, other):
3524 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003525 if self.next_table_ids != other.next_table_ids: return False
3526 return True
3527
Rich Lanec2ee4b82013-04-24 17:12:38 -07003528 def pretty_print(self, q):
3529 q.text("table_feature_prop_next_tables_miss {")
3530 with q.group():
3531 with q.indent(2):
3532 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003533 q.text("next_table_ids = ");
3534 q.pp(self.next_table_ids)
3535 q.breakable()
3536 q.text('}')
3537
Rich Lane7dcdf022013-12-11 14:45:27 -08003538table_feature_prop.subtypes[3] = table_feature_prop_next_tables_miss
3539
3540class table_feature_prop_wildcards(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003541 type = 10
Rich Lanec2ee4b82013-04-24 17:12:38 -07003542
Dan Talaycof6202252013-07-02 01:00:29 -07003543 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003544 if oxm_ids != None:
3545 self.oxm_ids = oxm_ids
3546 else:
3547 self.oxm_ids = []
3548 return
3549
3550 def pack(self):
3551 packed = []
3552 packed.append(struct.pack("!H", self.type))
3553 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003554 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003555 length = sum([len(x) for x in packed])
3556 packed[1] = struct.pack("!H", length)
Rich Lane51168312015-06-25 13:13:54 -07003557 packed.append(loxi.generic_util.pad_to(8, length))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003558 return ''.join(packed)
3559
3560 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003561 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003562 obj = table_feature_prop_wildcards()
Dan Talaycof6202252013-07-02 01:00:29 -07003563 _type = reader.read("!H")[0]
3564 assert(_type == 10)
3565 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003566 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003567 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08003568 obj.oxm_ids = loxi.generic_util.unpack_list(reader, ofp.common.uint32.unpack)
Rich Lane51168312015-06-25 13:13:54 -07003569 orig_reader.skip_align()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003570 return obj
3571
3572 def __eq__(self, other):
3573 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003574 if self.oxm_ids != other.oxm_ids: return False
3575 return True
3576
Rich Lanec2ee4b82013-04-24 17:12:38 -07003577 def pretty_print(self, q):
3578 q.text("table_feature_prop_wildcards {")
3579 with q.group():
3580 with q.indent(2):
3581 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003582 q.text("oxm_ids = ");
3583 q.pp(self.oxm_ids)
3584 q.breakable()
3585 q.text('}')
3586
Rich Lane7dcdf022013-12-11 14:45:27 -08003587table_feature_prop.subtypes[10] = table_feature_prop_wildcards
3588
3589class table_feature_prop_write_actions(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003590 type = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07003591
Dan Talaycof6202252013-07-02 01:00:29 -07003592 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003593 if action_ids != None:
3594 self.action_ids = action_ids
3595 else:
3596 self.action_ids = []
3597 return
3598
3599 def pack(self):
3600 packed = []
3601 packed.append(struct.pack("!H", self.type))
3602 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003603 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003604 length = sum([len(x) for x in packed])
3605 packed[1] = struct.pack("!H", length)
Rich Lane51168312015-06-25 13:13:54 -07003606 packed.append(loxi.generic_util.pad_to(8, length))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003607 return ''.join(packed)
3608
3609 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003610 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003611 obj = table_feature_prop_write_actions()
Dan Talaycof6202252013-07-02 01:00:29 -07003612 _type = reader.read("!H")[0]
3613 assert(_type == 4)
3614 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003615 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003616 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08003617 obj.action_ids = loxi.generic_util.unpack_list(reader, ofp.action_id.action_id.unpack)
Rich Lane51168312015-06-25 13:13:54 -07003618 orig_reader.skip_align()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003619 return obj
3620
3621 def __eq__(self, other):
3622 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003623 if self.action_ids != other.action_ids: return False
3624 return True
3625
Rich Lanec2ee4b82013-04-24 17:12:38 -07003626 def pretty_print(self, q):
3627 q.text("table_feature_prop_write_actions {")
3628 with q.group():
3629 with q.indent(2):
3630 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003631 q.text("action_ids = ");
3632 q.pp(self.action_ids)
3633 q.breakable()
3634 q.text('}')
3635
Rich Lane7dcdf022013-12-11 14:45:27 -08003636table_feature_prop.subtypes[4] = table_feature_prop_write_actions
3637
3638class table_feature_prop_write_actions_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003639 type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07003640
Dan Talaycof6202252013-07-02 01:00:29 -07003641 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003642 if action_ids != None:
3643 self.action_ids = action_ids
3644 else:
3645 self.action_ids = []
3646 return
3647
3648 def pack(self):
3649 packed = []
3650 packed.append(struct.pack("!H", self.type))
3651 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003652 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003653 length = sum([len(x) for x in packed])
3654 packed[1] = struct.pack("!H", length)
Rich Lane51168312015-06-25 13:13:54 -07003655 packed.append(loxi.generic_util.pad_to(8, length))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003656 return ''.join(packed)
3657
3658 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003659 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003660 obj = table_feature_prop_write_actions_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07003661 _type = reader.read("!H")[0]
3662 assert(_type == 5)
3663 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003664 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003665 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08003666 obj.action_ids = loxi.generic_util.unpack_list(reader, ofp.action_id.action_id.unpack)
Rich Lane51168312015-06-25 13:13:54 -07003667 orig_reader.skip_align()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003668 return obj
3669
3670 def __eq__(self, other):
3671 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003672 if self.action_ids != other.action_ids: return False
3673 return True
3674
Rich Lanec2ee4b82013-04-24 17:12:38 -07003675 def pretty_print(self, q):
3676 q.text("table_feature_prop_write_actions_miss {")
3677 with q.group():
3678 with q.indent(2):
3679 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003680 q.text("action_ids = ");
3681 q.pp(self.action_ids)
3682 q.breakable()
3683 q.text('}')
3684
Rich Lane7dcdf022013-12-11 14:45:27 -08003685table_feature_prop.subtypes[5] = table_feature_prop_write_actions_miss
3686
3687class table_feature_prop_write_setfield(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003688 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -07003689
Dan Talaycof6202252013-07-02 01:00:29 -07003690 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003691 if oxm_ids != None:
3692 self.oxm_ids = oxm_ids
3693 else:
3694 self.oxm_ids = []
3695 return
3696
3697 def pack(self):
3698 packed = []
3699 packed.append(struct.pack("!H", self.type))
3700 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003701 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003702 length = sum([len(x) for x in packed])
3703 packed[1] = struct.pack("!H", length)
Rich Lane51168312015-06-25 13:13:54 -07003704 packed.append(loxi.generic_util.pad_to(8, length))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003705 return ''.join(packed)
3706
3707 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003708 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003709 obj = table_feature_prop_write_setfield()
Dan Talaycof6202252013-07-02 01:00:29 -07003710 _type = reader.read("!H")[0]
3711 assert(_type == 12)
3712 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003713 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003714 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08003715 obj.oxm_ids = loxi.generic_util.unpack_list(reader, ofp.common.uint32.unpack)
Rich Lane51168312015-06-25 13:13:54 -07003716 orig_reader.skip_align()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003717 return obj
3718
3719 def __eq__(self, other):
3720 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003721 if self.oxm_ids != other.oxm_ids: return False
3722 return True
3723
Rich Lanec2ee4b82013-04-24 17:12:38 -07003724 def pretty_print(self, q):
3725 q.text("table_feature_prop_write_setfield {")
3726 with q.group():
3727 with q.indent(2):
3728 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003729 q.text("oxm_ids = ");
3730 q.pp(self.oxm_ids)
3731 q.breakable()
3732 q.text('}')
3733
Rich Lane7dcdf022013-12-11 14:45:27 -08003734table_feature_prop.subtypes[12] = table_feature_prop_write_setfield
3735
3736class table_feature_prop_write_setfield_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07003737 type = 13
Rich Lanec2ee4b82013-04-24 17:12:38 -07003738
Dan Talaycof6202252013-07-02 01:00:29 -07003739 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003740 if oxm_ids != None:
3741 self.oxm_ids = oxm_ids
3742 else:
3743 self.oxm_ids = []
3744 return
3745
3746 def pack(self):
3747 packed = []
3748 packed.append(struct.pack("!H", self.type))
3749 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08003750 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003751 length = sum([len(x) for x in packed])
3752 packed[1] = struct.pack("!H", length)
Rich Lane51168312015-06-25 13:13:54 -07003753 packed.append(loxi.generic_util.pad_to(8, length))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003754 return ''.join(packed)
3755
3756 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003757 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003758 obj = table_feature_prop_write_setfield_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07003759 _type = reader.read("!H")[0]
3760 assert(_type == 13)
3761 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003762 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003763 reader = orig_reader.slice(_length, 4)
Rich Lanee2567702015-01-26 15:04:35 -08003764 obj.oxm_ids = loxi.generic_util.unpack_list(reader, ofp.common.uint32.unpack)
Rich Lane51168312015-06-25 13:13:54 -07003765 orig_reader.skip_align()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003766 return obj
3767
3768 def __eq__(self, other):
3769 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07003770 if self.oxm_ids != other.oxm_ids: return False
3771 return True
3772
Rich Lanec2ee4b82013-04-24 17:12:38 -07003773 def pretty_print(self, q):
3774 q.text("table_feature_prop_write_setfield_miss {")
3775 with q.group():
3776 with q.indent(2):
3777 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07003778 q.text("oxm_ids = ");
3779 q.pp(self.oxm_ids)
3780 q.breakable()
3781 q.text('}')
3782
Rich Lane7dcdf022013-12-11 14:45:27 -08003783table_feature_prop.subtypes[13] = table_feature_prop_write_setfield_miss
3784
3785class table_features(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003786
3787 def __init__(self, table_id=None, name=None, metadata_match=None, metadata_write=None, config=None, max_entries=None, properties=None):
3788 if table_id != None:
3789 self.table_id = table_id
3790 else:
3791 self.table_id = 0
3792 if name != None:
3793 self.name = name
3794 else:
3795 self.name = ""
3796 if metadata_match != None:
3797 self.metadata_match = metadata_match
3798 else:
3799 self.metadata_match = 0
3800 if metadata_write != None:
3801 self.metadata_write = metadata_write
3802 else:
3803 self.metadata_write = 0
3804 if config != None:
3805 self.config = config
3806 else:
3807 self.config = 0
3808 if max_entries != None:
3809 self.max_entries = max_entries
3810 else:
3811 self.max_entries = 0
3812 if properties != None:
3813 self.properties = properties
3814 else:
3815 self.properties = []
3816 return
3817
3818 def pack(self):
3819 packed = []
3820 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
3821 packed.append(struct.pack("!B", self.table_id))
3822 packed.append('\x00' * 5)
3823 packed.append(struct.pack("!32s", self.name))
3824 packed.append(struct.pack("!Q", self.metadata_match))
3825 packed.append(struct.pack("!Q", self.metadata_write))
3826 packed.append(struct.pack("!L", self.config))
3827 packed.append(struct.pack("!L", self.max_entries))
Rich Lane7dcdf022013-12-11 14:45:27 -08003828 packed.append(loxi.generic_util.pack_list(self.properties))
Rich Lanec2ee4b82013-04-24 17:12:38 -07003829 length = sum([len(x) for x in packed])
3830 packed[0] = struct.pack("!H", length)
3831 return ''.join(packed)
3832
3833 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003834 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003835 obj = table_features()
Dan Talaycof6202252013-07-02 01:00:29 -07003836 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08003837 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08003838 reader = orig_reader.slice(_length, 2)
Dan Talaycof6202252013-07-02 01:00:29 -07003839 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003840 reader.skip(5)
3841 obj.name = reader.read("!32s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -07003842 obj.metadata_match = reader.read("!Q")[0]
3843 obj.metadata_write = reader.read("!Q")[0]
3844 obj.config = reader.read("!L")[0]
3845 obj.max_entries = reader.read("!L")[0]
Rich Lanee2567702015-01-26 15:04:35 -08003846 obj.properties = loxi.generic_util.unpack_list(reader, ofp.common.table_feature_prop.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07003847 return obj
3848
3849 def __eq__(self, other):
3850 if type(self) != type(other): return False
3851 if self.table_id != other.table_id: return False
3852 if self.name != other.name: return False
3853 if self.metadata_match != other.metadata_match: return False
3854 if self.metadata_write != other.metadata_write: return False
3855 if self.config != other.config: return False
3856 if self.max_entries != other.max_entries: return False
3857 if self.properties != other.properties: return False
3858 return True
3859
Rich Lanec2ee4b82013-04-24 17:12:38 -07003860 def pretty_print(self, q):
3861 q.text("table_features {")
3862 with q.group():
3863 with q.indent(2):
3864 q.breakable()
3865 q.text("table_id = ");
3866 q.text("%#x" % self.table_id)
3867 q.text(","); q.breakable()
3868 q.text("name = ");
3869 q.pp(self.name)
3870 q.text(","); q.breakable()
3871 q.text("metadata_match = ");
3872 q.text("%#x" % self.metadata_match)
3873 q.text(","); q.breakable()
3874 q.text("metadata_write = ");
3875 q.text("%#x" % self.metadata_write)
3876 q.text(","); q.breakable()
3877 q.text("config = ");
3878 q.text("%#x" % self.config)
3879 q.text(","); q.breakable()
3880 q.text("max_entries = ");
3881 q.text("%#x" % self.max_entries)
3882 q.text(","); q.breakable()
3883 q.text("properties = ");
3884 q.pp(self.properties)
3885 q.breakable()
3886 q.text('}')
3887
Rich Lane7dcdf022013-12-11 14:45:27 -08003888
3889class table_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003890
3891 def __init__(self, table_id=None, active_count=None, lookup_count=None, matched_count=None):
3892 if table_id != None:
3893 self.table_id = table_id
3894 else:
3895 self.table_id = 0
3896 if active_count != None:
3897 self.active_count = active_count
3898 else:
3899 self.active_count = 0
3900 if lookup_count != None:
3901 self.lookup_count = lookup_count
3902 else:
3903 self.lookup_count = 0
3904 if matched_count != None:
3905 self.matched_count = matched_count
3906 else:
3907 self.matched_count = 0
3908 return
3909
3910 def pack(self):
3911 packed = []
3912 packed.append(struct.pack("!B", self.table_id))
3913 packed.append('\x00' * 3)
3914 packed.append(struct.pack("!L", self.active_count))
3915 packed.append(struct.pack("!Q", self.lookup_count))
3916 packed.append(struct.pack("!Q", self.matched_count))
3917 return ''.join(packed)
3918
3919 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003920 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003921 obj = table_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07003922 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003923 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07003924 obj.active_count = reader.read("!L")[0]
3925 obj.lookup_count = reader.read("!Q")[0]
3926 obj.matched_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003927 return obj
3928
3929 def __eq__(self, other):
3930 if type(self) != type(other): return False
3931 if self.table_id != other.table_id: return False
3932 if self.active_count != other.active_count: return False
3933 if self.lookup_count != other.lookup_count: return False
3934 if self.matched_count != other.matched_count: return False
3935 return True
3936
Rich Lanec2ee4b82013-04-24 17:12:38 -07003937 def pretty_print(self, q):
3938 q.text("table_stats_entry {")
3939 with q.group():
3940 with q.indent(2):
3941 q.breakable()
3942 q.text("table_id = ");
3943 q.text("%#x" % self.table_id)
3944 q.text(","); q.breakable()
3945 q.text("active_count = ");
3946 q.text("%#x" % self.active_count)
3947 q.text(","); q.breakable()
3948 q.text("lookup_count = ");
3949 q.text("%#x" % self.lookup_count)
3950 q.text(","); q.breakable()
3951 q.text("matched_count = ");
3952 q.text("%#x" % self.matched_count)
3953 q.breakable()
3954 q.text('}')
3955
Rich Lane7dcdf022013-12-11 14:45:27 -08003956
3957class uint32(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003958
3959 def __init__(self, value=None):
3960 if value != None:
3961 self.value = value
3962 else:
3963 self.value = 0
3964 return
3965
3966 def pack(self):
3967 packed = []
3968 packed.append(struct.pack("!L", self.value))
3969 return ''.join(packed)
3970
3971 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08003972 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07003973 obj = uint32()
Dan Talaycof6202252013-07-02 01:00:29 -07003974 obj.value = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07003975 return obj
3976
3977 def __eq__(self, other):
3978 if type(self) != type(other): return False
3979 if self.value != other.value: return False
3980 return True
3981
Rich Lanec2ee4b82013-04-24 17:12:38 -07003982 def pretty_print(self, q):
3983 q.text("uint32 {")
3984 with q.group():
3985 with q.indent(2):
3986 q.breakable()
3987 q.text("value = ");
3988 q.text("%#x" % self.value)
3989 q.breakable()
3990 q.text('}')
3991
Rich Lane7dcdf022013-12-11 14:45:27 -08003992
3993class uint64(loxi.OFObject):
3994
3995 def __init__(self, value=None):
3996 if value != None:
3997 self.value = value
3998 else:
3999 self.value = 0
4000 return
4001
4002 def pack(self):
4003 packed = []
4004 packed.append(struct.pack("!Q", self.value))
4005 return ''.join(packed)
4006
4007 @staticmethod
4008 def unpack(reader):
4009 obj = uint64()
4010 obj.value = reader.read("!Q")[0]
4011 return obj
4012
4013 def __eq__(self, other):
4014 if type(self) != type(other): return False
4015 if self.value != other.value: return False
4016 return True
4017
4018 def pretty_print(self, q):
4019 q.text("uint64 {")
4020 with q.group():
4021 with q.indent(2):
4022 q.breakable()
4023 q.text("value = ");
4024 q.text("%#x" % self.value)
4025 q.breakable()
4026 q.text('}')
4027
4028
4029class uint8(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004030
4031 def __init__(self, value=None):
4032 if value != None:
4033 self.value = value
4034 else:
4035 self.value = 0
4036 return
4037
4038 def pack(self):
4039 packed = []
4040 packed.append(struct.pack("!B", self.value))
4041 return ''.join(packed)
4042
4043 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08004044 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07004045 obj = uint8()
Dan Talaycof6202252013-07-02 01:00:29 -07004046 obj.value = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07004047 return obj
4048
4049 def __eq__(self, other):
4050 if type(self) != type(other): return False
4051 if self.value != other.value: return False
4052 return True
4053
Rich Lanec2ee4b82013-04-24 17:12:38 -07004054 def pretty_print(self, q):
4055 q.text("uint8 {")
4056 with q.group():
4057 with q.indent(2):
4058 q.breakable()
4059 q.text("value = ");
4060 q.text("%#x" % self.value)
4061 q.breakable()
4062 q.text('}')
4063
4064
Rich Lane7dcdf022013-12-11 14:45:27 -08004065
Rich Lanec2ee4b82013-04-24 17:12:38 -07004066match = match_v3