blob: 2ce4918e390426f8143bbde9f6cf2a523e753526 [file] [log] [blame]
Stephane Barbarie6e1bd502018-11-05 22:44:45 -05001# Copyright 2017-present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14# Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
15# Copyright (c) 2011, 2012 Open Networking Foundation
16# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
17# See the file LICENSE.pyloxi which should have been included in the source distribution
18
19# Automatically generated by LOXI from template module.py
20# Do not modify
21
22import struct
23import loxi
24import util
25import loxi.generic_util
26
27import sys
28ofp = sys.modules['loxi.of12']
29
30class bsn_interface(loxi.OFObject):
31
32 def __init__(self, hw_addr=None, name=None, ipv4_addr=None, ipv4_netmask=None):
33 if hw_addr != None:
34 self.hw_addr = hw_addr
35 else:
36 self.hw_addr = [0,0,0,0,0,0]
37 if name != None:
38 self.name = name
39 else:
40 self.name = ""
41 if ipv4_addr != None:
42 self.ipv4_addr = ipv4_addr
43 else:
44 self.ipv4_addr = 0
45 if ipv4_netmask != None:
46 self.ipv4_netmask = ipv4_netmask
47 else:
48 self.ipv4_netmask = 0
49 return
50
51 def pack(self):
52 packed = []
53 packed.append(struct.pack("!6B", *self.hw_addr))
54 packed.append('\x00' * 2)
55 packed.append(struct.pack("!16s", self.name))
56 packed.append(struct.pack("!L", self.ipv4_addr))
57 packed.append(struct.pack("!L", self.ipv4_netmask))
58 return ''.join(packed)
59
60 @staticmethod
61 def unpack(reader):
62 obj = bsn_interface()
63 obj.hw_addr = list(reader.read('!6B'))
64 reader.skip(2)
65 obj.name = reader.read("!16s")[0].rstrip("\x00")
66 obj.ipv4_addr = reader.read("!L")[0]
67 obj.ipv4_netmask = reader.read("!L")[0]
68 return obj
69
70 def __eq__(self, other):
71 if type(self) != type(other): return False
72 if self.hw_addr != other.hw_addr: return False
73 if self.name != other.name: return False
74 if self.ipv4_addr != other.ipv4_addr: return False
75 if self.ipv4_netmask != other.ipv4_netmask: return False
76 return True
77
78 def pretty_print(self, q):
79 q.text("bsn_interface {")
80 with q.group():
81 with q.indent(2):
82 q.breakable()
83 q.text("hw_addr = ");
84 q.text(util.pretty_mac(self.hw_addr))
85 q.text(","); q.breakable()
86 q.text("name = ");
87 q.pp(self.name)
88 q.text(","); q.breakable()
89 q.text("ipv4_addr = ");
90 q.text(util.pretty_ipv4(self.ipv4_addr))
91 q.text(","); q.breakable()
92 q.text("ipv4_netmask = ");
93 q.text(util.pretty_ipv4(self.ipv4_netmask))
94 q.breakable()
95 q.text('}')
96
97
98class bsn_vport(loxi.OFObject):
99 subtypes = {}
100
101
102 def __init__(self, type=None):
103 if type != None:
104 self.type = type
105 else:
106 self.type = 0
107 return
108
109 def pack(self):
110 packed = []
111 packed.append(struct.pack("!H", self.type))
112 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
113 length = sum([len(x) for x in packed])
114 packed[1] = struct.pack("!H", length)
115 return ''.join(packed)
116
117 @staticmethod
118 def unpack(reader):
119 subtype, = reader.peek('!H', 0)
120 subclass = bsn_vport.subtypes.get(subtype)
121 if subclass:
122 return subclass.unpack(reader)
123
124 obj = bsn_vport()
125 obj.type = reader.read("!H")[0]
126 _length = reader.read("!H")[0]
127 orig_reader = reader
128 reader = orig_reader.slice(_length, 4)
129 return obj
130
131 def __eq__(self, other):
132 if type(self) != type(other): return False
133 if self.type != other.type: return False
134 return True
135
136 def pretty_print(self, q):
137 q.text("bsn_vport {")
138 with q.group():
139 with q.indent(2):
140 q.breakable()
141 q.breakable()
142 q.text('}')
143
144
145class bsn_vport_l2gre(bsn_vport):
146 type = 1
147
148 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):
149 if flags != None:
150 self.flags = flags
151 else:
152 self.flags = 0
153 if port_no != None:
154 self.port_no = port_no
155 else:
156 self.port_no = 0
157 if loopback_port_no != None:
158 self.loopback_port_no = loopback_port_no
159 else:
160 self.loopback_port_no = 0
161 if local_mac != None:
162 self.local_mac = local_mac
163 else:
164 self.local_mac = [0,0,0,0,0,0]
165 if nh_mac != None:
166 self.nh_mac = nh_mac
167 else:
168 self.nh_mac = [0,0,0,0,0,0]
169 if src_ip != None:
170 self.src_ip = src_ip
171 else:
172 self.src_ip = 0
173 if dst_ip != None:
174 self.dst_ip = dst_ip
175 else:
176 self.dst_ip = 0
177 if dscp != None:
178 self.dscp = dscp
179 else:
180 self.dscp = 0
181 if ttl != None:
182 self.ttl = ttl
183 else:
184 self.ttl = 0
185 if vpn != None:
186 self.vpn = vpn
187 else:
188 self.vpn = 0
189 if rate_limit != None:
190 self.rate_limit = rate_limit
191 else:
192 self.rate_limit = 0
193 if if_name != None:
194 self.if_name = if_name
195 else:
196 self.if_name = ""
197 return
198
199 def pack(self):
200 packed = []
201 packed.append(struct.pack("!H", self.type))
202 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
203 packed.append(struct.pack("!L", self.flags))
204 packed.append(util.pack_port_no(self.port_no))
205 packed.append(util.pack_port_no(self.loopback_port_no))
206 packed.append(struct.pack("!6B", *self.local_mac))
207 packed.append(struct.pack("!6B", *self.nh_mac))
208 packed.append(struct.pack("!L", self.src_ip))
209 packed.append(struct.pack("!L", self.dst_ip))
210 packed.append(struct.pack("!B", self.dscp))
211 packed.append(struct.pack("!B", self.ttl))
212 packed.append('\x00' * 2)
213 packed.append(struct.pack("!L", self.vpn))
214 packed.append(struct.pack("!L", self.rate_limit))
215 packed.append(struct.pack("!16s", self.if_name))
216 length = sum([len(x) for x in packed])
217 packed[1] = struct.pack("!H", length)
218 return ''.join(packed)
219
220 @staticmethod
221 def unpack(reader):
222 obj = bsn_vport_l2gre()
223 _type = reader.read("!H")[0]
224 assert(_type == 1)
225 _length = reader.read("!H")[0]
226 orig_reader = reader
227 reader = orig_reader.slice(_length, 4)
228 obj.flags = reader.read("!L")[0]
229 obj.port_no = util.unpack_port_no(reader)
230 obj.loopback_port_no = util.unpack_port_no(reader)
231 obj.local_mac = list(reader.read('!6B'))
232 obj.nh_mac = list(reader.read('!6B'))
233 obj.src_ip = reader.read("!L")[0]
234 obj.dst_ip = reader.read("!L")[0]
235 obj.dscp = reader.read("!B")[0]
236 obj.ttl = reader.read("!B")[0]
237 reader.skip(2)
238 obj.vpn = reader.read("!L")[0]
239 obj.rate_limit = reader.read("!L")[0]
240 obj.if_name = reader.read("!16s")[0].rstrip("\x00")
241 return obj
242
243 def __eq__(self, other):
244 if type(self) != type(other): return False
245 if self.flags != other.flags: return False
246 if self.port_no != other.port_no: return False
247 if self.loopback_port_no != other.loopback_port_no: return False
248 if self.local_mac != other.local_mac: return False
249 if self.nh_mac != other.nh_mac: return False
250 if self.src_ip != other.src_ip: return False
251 if self.dst_ip != other.dst_ip: return False
252 if self.dscp != other.dscp: return False
253 if self.ttl != other.ttl: return False
254 if self.vpn != other.vpn: return False
255 if self.rate_limit != other.rate_limit: return False
256 if self.if_name != other.if_name: return False
257 return True
258
259 def pretty_print(self, q):
260 q.text("bsn_vport_l2gre {")
261 with q.group():
262 with q.indent(2):
263 q.breakable()
264 q.text("flags = ");
265 q.text("%#x" % self.flags)
266 q.text(","); q.breakable()
267 q.text("port_no = ");
268 q.text(util.pretty_port(self.port_no))
269 q.text(","); q.breakable()
270 q.text("loopback_port_no = ");
271 q.text(util.pretty_port(self.loopback_port_no))
272 q.text(","); q.breakable()
273 q.text("local_mac = ");
274 q.text(util.pretty_mac(self.local_mac))
275 q.text(","); q.breakable()
276 q.text("nh_mac = ");
277 q.text(util.pretty_mac(self.nh_mac))
278 q.text(","); q.breakable()
279 q.text("src_ip = ");
280 q.text(util.pretty_ipv4(self.src_ip))
281 q.text(","); q.breakable()
282 q.text("dst_ip = ");
283 q.text(util.pretty_ipv4(self.dst_ip))
284 q.text(","); q.breakable()
285 q.text("dscp = ");
286 q.text("%#x" % self.dscp)
287 q.text(","); q.breakable()
288 q.text("ttl = ");
289 q.text("%#x" % self.ttl)
290 q.text(","); q.breakable()
291 q.text("vpn = ");
292 q.text("%#x" % self.vpn)
293 q.text(","); q.breakable()
294 q.text("rate_limit = ");
295 q.text("%#x" % self.rate_limit)
296 q.text(","); q.breakable()
297 q.text("if_name = ");
298 q.pp(self.if_name)
299 q.breakable()
300 q.text('}')
301
302bsn_vport.subtypes[1] = bsn_vport_l2gre
303
304class bsn_vport_q_in_q(bsn_vport):
305 type = 0
306
307 def __init__(self, port_no=None, ingress_tpid=None, ingress_vlan_id=None, egress_tpid=None, egress_vlan_id=None, if_name=None):
308 if port_no != None:
309 self.port_no = port_no
310 else:
311 self.port_no = 0
312 if ingress_tpid != None:
313 self.ingress_tpid = ingress_tpid
314 else:
315 self.ingress_tpid = 0
316 if ingress_vlan_id != None:
317 self.ingress_vlan_id = ingress_vlan_id
318 else:
319 self.ingress_vlan_id = 0
320 if egress_tpid != None:
321 self.egress_tpid = egress_tpid
322 else:
323 self.egress_tpid = 0
324 if egress_vlan_id != None:
325 self.egress_vlan_id = egress_vlan_id
326 else:
327 self.egress_vlan_id = 0
328 if if_name != None:
329 self.if_name = if_name
330 else:
331 self.if_name = ""
332 return
333
334 def pack(self):
335 packed = []
336 packed.append(struct.pack("!H", self.type))
337 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
338 packed.append(struct.pack("!L", self.port_no))
339 packed.append(struct.pack("!H", self.ingress_tpid))
340 packed.append(struct.pack("!H", self.ingress_vlan_id))
341 packed.append(struct.pack("!H", self.egress_tpid))
342 packed.append(struct.pack("!H", self.egress_vlan_id))
343 packed.append(struct.pack("!16s", self.if_name))
344 length = sum([len(x) for x in packed])
345 packed[1] = struct.pack("!H", length)
346 return ''.join(packed)
347
348 @staticmethod
349 def unpack(reader):
350 obj = bsn_vport_q_in_q()
351 _type = reader.read("!H")[0]
352 assert(_type == 0)
353 _length = reader.read("!H")[0]
354 orig_reader = reader
355 reader = orig_reader.slice(_length, 4)
356 obj.port_no = reader.read("!L")[0]
357 obj.ingress_tpid = reader.read("!H")[0]
358 obj.ingress_vlan_id = reader.read("!H")[0]
359 obj.egress_tpid = reader.read("!H")[0]
360 obj.egress_vlan_id = reader.read("!H")[0]
361 obj.if_name = reader.read("!16s")[0].rstrip("\x00")
362 return obj
363
364 def __eq__(self, other):
365 if type(self) != type(other): return False
366 if self.port_no != other.port_no: return False
367 if self.ingress_tpid != other.ingress_tpid: return False
368 if self.ingress_vlan_id != other.ingress_vlan_id: return False
369 if self.egress_tpid != other.egress_tpid: return False
370 if self.egress_vlan_id != other.egress_vlan_id: return False
371 if self.if_name != other.if_name: return False
372 return True
373
374 def pretty_print(self, q):
375 q.text("bsn_vport_q_in_q {")
376 with q.group():
377 with q.indent(2):
378 q.breakable()
379 q.text("port_no = ");
380 q.text("%#x" % self.port_no)
381 q.text(","); q.breakable()
382 q.text("ingress_tpid = ");
383 q.text("%#x" % self.ingress_tpid)
384 q.text(","); q.breakable()
385 q.text("ingress_vlan_id = ");
386 q.text("%#x" % self.ingress_vlan_id)
387 q.text(","); q.breakable()
388 q.text("egress_tpid = ");
389 q.text("%#x" % self.egress_tpid)
390 q.text(","); q.breakable()
391 q.text("egress_vlan_id = ");
392 q.text("%#x" % self.egress_vlan_id)
393 q.text(","); q.breakable()
394 q.text("if_name = ");
395 q.pp(self.if_name)
396 q.breakable()
397 q.text('}')
398
399bsn_vport.subtypes[0] = bsn_vport_q_in_q
400
401class bucket(loxi.OFObject):
402
403 def __init__(self, weight=None, watch_port=None, watch_group=None, actions=None):
404 if weight != None:
405 self.weight = weight
406 else:
407 self.weight = 0
408 if watch_port != None:
409 self.watch_port = watch_port
410 else:
411 self.watch_port = 0
412 if watch_group != None:
413 self.watch_group = watch_group
414 else:
415 self.watch_group = 0
416 if actions != None:
417 self.actions = actions
418 else:
419 self.actions = []
420 return
421
422 def pack(self):
423 packed = []
424 packed.append(struct.pack("!H", 0)) # placeholder for len at index 0
425 packed.append(struct.pack("!H", self.weight))
426 packed.append(util.pack_port_no(self.watch_port))
427 packed.append(struct.pack("!L", self.watch_group))
428 packed.append('\x00' * 4)
429 packed.append(loxi.generic_util.pack_list(self.actions))
430 length = sum([len(x) for x in packed])
431 packed[0] = struct.pack("!H", length)
432 return ''.join(packed)
433
434 @staticmethod
435 def unpack(reader):
436 obj = bucket()
437 _len = reader.read("!H")[0]
438 orig_reader = reader
439 reader = orig_reader.slice(_len, 2)
440 obj.weight = reader.read("!H")[0]
441 obj.watch_port = util.unpack_port_no(reader)
442 obj.watch_group = reader.read("!L")[0]
443 reader.skip(4)
444 obj.actions = loxi.generic_util.unpack_list(reader, ofp.action.action.unpack)
445 return obj
446
447 def __eq__(self, other):
448 if type(self) != type(other): return False
449 if self.weight != other.weight: return False
450 if self.watch_port != other.watch_port: return False
451 if self.watch_group != other.watch_group: return False
452 if self.actions != other.actions: return False
453 return True
454
455 def pretty_print(self, q):
456 q.text("bucket {")
457 with q.group():
458 with q.indent(2):
459 q.breakable()
460 q.text("weight = ");
461 q.text("%#x" % self.weight)
462 q.text(","); q.breakable()
463 q.text("watch_port = ");
464 q.text(util.pretty_port(self.watch_port))
465 q.text(","); q.breakable()
466 q.text("watch_group = ");
467 q.text("%#x" % self.watch_group)
468 q.text(","); q.breakable()
469 q.text("actions = ");
470 q.pp(self.actions)
471 q.breakable()
472 q.text('}')
473
474
475class bucket_counter(loxi.OFObject):
476
477 def __init__(self, packet_count=None, byte_count=None):
478 if packet_count != None:
479 self.packet_count = packet_count
480 else:
481 self.packet_count = 0
482 if byte_count != None:
483 self.byte_count = byte_count
484 else:
485 self.byte_count = 0
486 return
487
488 def pack(self):
489 packed = []
490 packed.append(struct.pack("!Q", self.packet_count))
491 packed.append(struct.pack("!Q", self.byte_count))
492 return ''.join(packed)
493
494 @staticmethod
495 def unpack(reader):
496 obj = bucket_counter()
497 obj.packet_count = reader.read("!Q")[0]
498 obj.byte_count = reader.read("!Q")[0]
499 return obj
500
501 def __eq__(self, other):
502 if type(self) != type(other): return False
503 if self.packet_count != other.packet_count: return False
504 if self.byte_count != other.byte_count: return False
505 return True
506
507 def pretty_print(self, q):
508 q.text("bucket_counter {")
509 with q.group():
510 with q.indent(2):
511 q.breakable()
512 q.text("packet_count = ");
513 q.text("%#x" % self.packet_count)
514 q.text(","); q.breakable()
515 q.text("byte_count = ");
516 q.text("%#x" % self.byte_count)
517 q.breakable()
518 q.text('}')
519
520
521class flow_stats_entry(loxi.OFObject):
522
523 def __init__(self, table_id=None, duration_sec=None, duration_nsec=None, priority=None, idle_timeout=None, hard_timeout=None, cookie=None, packet_count=None, byte_count=None, match=None, instructions=None):
524 if table_id != None:
525 self.table_id = table_id
526 else:
527 self.table_id = 0
528 if duration_sec != None:
529 self.duration_sec = duration_sec
530 else:
531 self.duration_sec = 0
532 if duration_nsec != None:
533 self.duration_nsec = duration_nsec
534 else:
535 self.duration_nsec = 0
536 if priority != None:
537 self.priority = priority
538 else:
539 self.priority = 0
540 if idle_timeout != None:
541 self.idle_timeout = idle_timeout
542 else:
543 self.idle_timeout = 0
544 if hard_timeout != None:
545 self.hard_timeout = hard_timeout
546 else:
547 self.hard_timeout = 0
548 if cookie != None:
549 self.cookie = cookie
550 else:
551 self.cookie = 0
552 if packet_count != None:
553 self.packet_count = packet_count
554 else:
555 self.packet_count = 0
556 if byte_count != None:
557 self.byte_count = byte_count
558 else:
559 self.byte_count = 0
560 if match != None:
561 self.match = match
562 else:
563 self.match = ofp.match()
564 if instructions != None:
565 self.instructions = instructions
566 else:
567 self.instructions = []
568 return
569
570 def pack(self):
571 packed = []
572 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
573 packed.append(struct.pack("!B", self.table_id))
574 packed.append('\x00' * 1)
575 packed.append(struct.pack("!L", self.duration_sec))
576 packed.append(struct.pack("!L", self.duration_nsec))
577 packed.append(struct.pack("!H", self.priority))
578 packed.append(struct.pack("!H", self.idle_timeout))
579 packed.append(struct.pack("!H", self.hard_timeout))
580 packed.append('\x00' * 6)
581 packed.append(struct.pack("!Q", self.cookie))
582 packed.append(struct.pack("!Q", self.packet_count))
583 packed.append(struct.pack("!Q", self.byte_count))
584 packed.append(self.match.pack())
585 packed.append(loxi.generic_util.pack_list(self.instructions))
586 length = sum([len(x) for x in packed])
587 packed[0] = struct.pack("!H", length)
588 return ''.join(packed)
589
590 @staticmethod
591 def unpack(reader):
592 obj = flow_stats_entry()
593 _length = reader.read("!H")[0]
594 orig_reader = reader
595 reader = orig_reader.slice(_length, 2)
596 obj.table_id = reader.read("!B")[0]
597 reader.skip(1)
598 obj.duration_sec = reader.read("!L")[0]
599 obj.duration_nsec = reader.read("!L")[0]
600 obj.priority = reader.read("!H")[0]
601 obj.idle_timeout = reader.read("!H")[0]
602 obj.hard_timeout = reader.read("!H")[0]
603 reader.skip(6)
604 obj.cookie = reader.read("!Q")[0]
605 obj.packet_count = reader.read("!Q")[0]
606 obj.byte_count = reader.read("!Q")[0]
607 obj.match = ofp.match.unpack(reader)
608 obj.instructions = loxi.generic_util.unpack_list(reader, ofp.instruction.instruction.unpack)
609 return obj
610
611 def __eq__(self, other):
612 if type(self) != type(other): return False
613 if self.table_id != other.table_id: return False
614 if self.duration_sec != other.duration_sec: return False
615 if self.duration_nsec != other.duration_nsec: return False
616 if self.priority != other.priority: return False
617 if self.idle_timeout != other.idle_timeout: return False
618 if self.hard_timeout != other.hard_timeout: return False
619 if self.cookie != other.cookie: return False
620 if self.packet_count != other.packet_count: return False
621 if self.byte_count != other.byte_count: return False
622 if self.match != other.match: return False
623 if self.instructions != other.instructions: return False
624 return True
625
626 def pretty_print(self, q):
627 q.text("flow_stats_entry {")
628 with q.group():
629 with q.indent(2):
630 q.breakable()
631 q.text("table_id = ");
632 q.text("%#x" % self.table_id)
633 q.text(","); q.breakable()
634 q.text("duration_sec = ");
635 q.text("%#x" % self.duration_sec)
636 q.text(","); q.breakable()
637 q.text("duration_nsec = ");
638 q.text("%#x" % self.duration_nsec)
639 q.text(","); q.breakable()
640 q.text("priority = ");
641 q.text("%#x" % self.priority)
642 q.text(","); q.breakable()
643 q.text("idle_timeout = ");
644 q.text("%#x" % self.idle_timeout)
645 q.text(","); q.breakable()
646 q.text("hard_timeout = ");
647 q.text("%#x" % self.hard_timeout)
648 q.text(","); q.breakable()
649 q.text("cookie = ");
650 q.text("%#x" % self.cookie)
651 q.text(","); q.breakable()
652 q.text("packet_count = ");
653 q.text("%#x" % self.packet_count)
654 q.text(","); q.breakable()
655 q.text("byte_count = ");
656 q.text("%#x" % self.byte_count)
657 q.text(","); q.breakable()
658 q.text("match = ");
659 q.pp(self.match)
660 q.text(","); q.breakable()
661 q.text("instructions = ");
662 q.pp(self.instructions)
663 q.breakable()
664 q.text('}')
665
666
667class group_desc_stats_entry(loxi.OFObject):
668
669 def __init__(self, group_type=None, group_id=None, buckets=None):
670 if group_type != None:
671 self.group_type = group_type
672 else:
673 self.group_type = 0
674 if group_id != None:
675 self.group_id = group_id
676 else:
677 self.group_id = 0
678 if buckets != None:
679 self.buckets = buckets
680 else:
681 self.buckets = []
682 return
683
684 def pack(self):
685 packed = []
686 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
687 packed.append(struct.pack("!B", self.group_type))
688 packed.append('\x00' * 1)
689 packed.append(struct.pack("!L", self.group_id))
690 packed.append(loxi.generic_util.pack_list(self.buckets))
691 length = sum([len(x) for x in packed])
692 packed[0] = struct.pack("!H", length)
693 return ''.join(packed)
694
695 @staticmethod
696 def unpack(reader):
697 obj = group_desc_stats_entry()
698 _length = reader.read("!H")[0]
699 orig_reader = reader
700 reader = orig_reader.slice(_length, 2)
701 obj.group_type = reader.read("!B")[0]
702 reader.skip(1)
703 obj.group_id = reader.read("!L")[0]
704 obj.buckets = loxi.generic_util.unpack_list(reader, ofp.common.bucket.unpack)
705 return obj
706
707 def __eq__(self, other):
708 if type(self) != type(other): return False
709 if self.group_type != other.group_type: return False
710 if self.group_id != other.group_id: return False
711 if self.buckets != other.buckets: return False
712 return True
713
714 def pretty_print(self, q):
715 q.text("group_desc_stats_entry {")
716 with q.group():
717 with q.indent(2):
718 q.breakable()
719 q.text("group_type = ");
720 q.text("%#x" % self.group_type)
721 q.text(","); q.breakable()
722 q.text("group_id = ");
723 q.text("%#x" % self.group_id)
724 q.text(","); q.breakable()
725 q.text("buckets = ");
726 q.pp(self.buckets)
727 q.breakable()
728 q.text('}')
729
730
731class group_stats_entry(loxi.OFObject):
732
733 def __init__(self, group_id=None, ref_count=None, packet_count=None, byte_count=None, bucket_stats=None):
734 if group_id != None:
735 self.group_id = group_id
736 else:
737 self.group_id = 0
738 if ref_count != None:
739 self.ref_count = ref_count
740 else:
741 self.ref_count = 0
742 if packet_count != None:
743 self.packet_count = packet_count
744 else:
745 self.packet_count = 0
746 if byte_count != None:
747 self.byte_count = byte_count
748 else:
749 self.byte_count = 0
750 if bucket_stats != None:
751 self.bucket_stats = bucket_stats
752 else:
753 self.bucket_stats = []
754 return
755
756 def pack(self):
757 packed = []
758 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
759 packed.append('\x00' * 2)
760 packed.append(struct.pack("!L", self.group_id))
761 packed.append(struct.pack("!L", self.ref_count))
762 packed.append('\x00' * 4)
763 packed.append(struct.pack("!Q", self.packet_count))
764 packed.append(struct.pack("!Q", self.byte_count))
765 packed.append(loxi.generic_util.pack_list(self.bucket_stats))
766 length = sum([len(x) for x in packed])
767 packed[0] = struct.pack("!H", length)
768 return ''.join(packed)
769
770 @staticmethod
771 def unpack(reader):
772 obj = group_stats_entry()
773 _length = reader.read("!H")[0]
774 orig_reader = reader
775 reader = orig_reader.slice(_length, 2)
776 reader.skip(2)
777 obj.group_id = reader.read("!L")[0]
778 obj.ref_count = reader.read("!L")[0]
779 reader.skip(4)
780 obj.packet_count = reader.read("!Q")[0]
781 obj.byte_count = reader.read("!Q")[0]
782 obj.bucket_stats = loxi.generic_util.unpack_list(reader, ofp.common.bucket_counter.unpack)
783 return obj
784
785 def __eq__(self, other):
786 if type(self) != type(other): return False
787 if self.group_id != other.group_id: return False
788 if self.ref_count != other.ref_count: return False
789 if self.packet_count != other.packet_count: return False
790 if self.byte_count != other.byte_count: return False
791 if self.bucket_stats != other.bucket_stats: return False
792 return True
793
794 def pretty_print(self, q):
795 q.text("group_stats_entry {")
796 with q.group():
797 with q.indent(2):
798 q.breakable()
799 q.text("group_id = ");
800 q.text("%#x" % self.group_id)
801 q.text(","); q.breakable()
802 q.text("ref_count = ");
803 q.text("%#x" % self.ref_count)
804 q.text(","); q.breakable()
805 q.text("packet_count = ");
806 q.text("%#x" % self.packet_count)
807 q.text(","); q.breakable()
808 q.text("byte_count = ");
809 q.text("%#x" % self.byte_count)
810 q.text(","); q.breakable()
811 q.text("bucket_stats = ");
812 q.pp(self.bucket_stats)
813 q.breakable()
814 q.text('}')
815
816
817class match_v3(loxi.OFObject):
818 type = 1
819
820 def __init__(self, oxm_list=None):
821 if oxm_list != None:
822 self.oxm_list = oxm_list
823 else:
824 self.oxm_list = []
825 return
826
827 def pack(self):
828 packed = []
829 packed.append(struct.pack("!H", self.type))
830 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
831 packed.append(loxi.generic_util.pack_list(self.oxm_list))
832 length = sum([len(x) for x in packed])
833 packed[1] = struct.pack("!H", length)
834 packed.append(loxi.generic_util.pad_to(8, length))
835 return ''.join(packed)
836
837 @staticmethod
838 def unpack(reader):
839 obj = match_v3()
840 _type = reader.read("!H")[0]
841 assert(_type == 1)
842 _length = reader.read("!H")[0]
843 orig_reader = reader
844 reader = orig_reader.slice(_length, 4)
845 obj.oxm_list = loxi.generic_util.unpack_list(reader, ofp.oxm.oxm.unpack)
846 orig_reader.skip_align()
847 return obj
848
849 def __eq__(self, other):
850 if type(self) != type(other): return False
851 if self.oxm_list != other.oxm_list: return False
852 return True
853
854 def pretty_print(self, q):
855 q.text("match_v3 {")
856 with q.group():
857 with q.indent(2):
858 q.breakable()
859 q.text("oxm_list = ");
860 q.pp(self.oxm_list)
861 q.breakable()
862 q.text('}')
863
864
865class packet_queue(loxi.OFObject):
866
867 def __init__(self, queue_id=None, port=None, properties=None):
868 if queue_id != None:
869 self.queue_id = queue_id
870 else:
871 self.queue_id = 0
872 if port != None:
873 self.port = port
874 else:
875 self.port = 0
876 if properties != None:
877 self.properties = properties
878 else:
879 self.properties = []
880 return
881
882 def pack(self):
883 packed = []
884 packed.append(struct.pack("!L", self.queue_id))
885 packed.append(util.pack_port_no(self.port))
886 packed.append(struct.pack("!H", 0)) # placeholder for len at index 2
887 packed.append('\x00' * 6)
888 packed.append(loxi.generic_util.pack_list(self.properties))
889 length = sum([len(x) for x in packed])
890 packed[2] = struct.pack("!H", length)
891 return ''.join(packed)
892
893 @staticmethod
894 def unpack(reader):
895 obj = packet_queue()
896 obj.queue_id = reader.read("!L")[0]
897 obj.port = util.unpack_port_no(reader)
898 _len = reader.read("!H")[0]
899 orig_reader = reader
900 reader = orig_reader.slice(_len, 10)
901 reader.skip(6)
902 obj.properties = loxi.generic_util.unpack_list(reader, ofp.common.queue_prop.unpack)
903 return obj
904
905 def __eq__(self, other):
906 if type(self) != type(other): return False
907 if self.queue_id != other.queue_id: return False
908 if self.port != other.port: return False
909 if self.properties != other.properties: return False
910 return True
911
912 def pretty_print(self, q):
913 q.text("packet_queue {")
914 with q.group():
915 with q.indent(2):
916 q.breakable()
917 q.text("queue_id = ");
918 q.text("%#x" % self.queue_id)
919 q.text(","); q.breakable()
920 q.text("port = ");
921 q.text(util.pretty_port(self.port))
922 q.text(","); q.breakable()
923 q.text("properties = ");
924 q.pp(self.properties)
925 q.breakable()
926 q.text('}')
927
928
929class port_desc(loxi.OFObject):
930
931 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):
932 if port_no != None:
933 self.port_no = port_no
934 else:
935 self.port_no = 0
936 if hw_addr != None:
937 self.hw_addr = hw_addr
938 else:
939 self.hw_addr = [0,0,0,0,0,0]
940 if name != None:
941 self.name = name
942 else:
943 self.name = ""
944 if config != None:
945 self.config = config
946 else:
947 self.config = 0
948 if state != None:
949 self.state = state
950 else:
951 self.state = 0
952 if curr != None:
953 self.curr = curr
954 else:
955 self.curr = 0
956 if advertised != None:
957 self.advertised = advertised
958 else:
959 self.advertised = 0
960 if supported != None:
961 self.supported = supported
962 else:
963 self.supported = 0
964 if peer != None:
965 self.peer = peer
966 else:
967 self.peer = 0
968 if curr_speed != None:
969 self.curr_speed = curr_speed
970 else:
971 self.curr_speed = 0
972 if max_speed != None:
973 self.max_speed = max_speed
974 else:
975 self.max_speed = 0
976 return
977
978 def pack(self):
979 packed = []
980 packed.append(util.pack_port_no(self.port_no))
981 packed.append('\x00' * 4)
982 packed.append(struct.pack("!6B", *self.hw_addr))
983 packed.append('\x00' * 2)
984 packed.append(struct.pack("!16s", self.name))
985 packed.append(struct.pack("!L", self.config))
986 packed.append(struct.pack("!L", self.state))
987 packed.append(struct.pack("!L", self.curr))
988 packed.append(struct.pack("!L", self.advertised))
989 packed.append(struct.pack("!L", self.supported))
990 packed.append(struct.pack("!L", self.peer))
991 packed.append(struct.pack("!L", self.curr_speed))
992 packed.append(struct.pack("!L", self.max_speed))
993 return ''.join(packed)
994
995 @staticmethod
996 def unpack(reader):
997 obj = port_desc()
998 obj.port_no = util.unpack_port_no(reader)
999 reader.skip(4)
1000 obj.hw_addr = list(reader.read('!6B'))
1001 reader.skip(2)
1002 obj.name = reader.read("!16s")[0].rstrip("\x00")
1003 obj.config = reader.read("!L")[0]
1004 obj.state = reader.read("!L")[0]
1005 obj.curr = reader.read("!L")[0]
1006 obj.advertised = reader.read("!L")[0]
1007 obj.supported = reader.read("!L")[0]
1008 obj.peer = reader.read("!L")[0]
1009 obj.curr_speed = reader.read("!L")[0]
1010 obj.max_speed = reader.read("!L")[0]
1011 return obj
1012
1013 def __eq__(self, other):
1014 if type(self) != type(other): return False
1015 if self.port_no != other.port_no: return False
1016 if self.hw_addr != other.hw_addr: return False
1017 if self.name != other.name: return False
1018 if self.config != other.config: return False
1019 if self.state != other.state: return False
1020 if self.curr != other.curr: return False
1021 if self.advertised != other.advertised: return False
1022 if self.supported != other.supported: return False
1023 if self.peer != other.peer: return False
1024 if self.curr_speed != other.curr_speed: return False
1025 if self.max_speed != other.max_speed: return False
1026 return True
1027
1028 def pretty_print(self, q):
1029 q.text("port_desc {")
1030 with q.group():
1031 with q.indent(2):
1032 q.breakable()
1033 q.text("port_no = ");
1034 q.text(util.pretty_port(self.port_no))
1035 q.text(","); q.breakable()
1036 q.text("hw_addr = ");
1037 q.text(util.pretty_mac(self.hw_addr))
1038 q.text(","); q.breakable()
1039 q.text("name = ");
1040 q.pp(self.name)
1041 q.text(","); q.breakable()
1042 q.text("config = ");
1043 q.text("%#x" % self.config)
1044 q.text(","); q.breakable()
1045 q.text("state = ");
1046 q.text("%#x" % self.state)
1047 q.text(","); q.breakable()
1048 q.text("curr = ");
1049 q.text("%#x" % self.curr)
1050 q.text(","); q.breakable()
1051 q.text("advertised = ");
1052 q.text("%#x" % self.advertised)
1053 q.text(","); q.breakable()
1054 q.text("supported = ");
1055 q.text("%#x" % self.supported)
1056 q.text(","); q.breakable()
1057 q.text("peer = ");
1058 q.text("%#x" % self.peer)
1059 q.text(","); q.breakable()
1060 q.text("curr_speed = ");
1061 q.text("%#x" % self.curr_speed)
1062 q.text(","); q.breakable()
1063 q.text("max_speed = ");
1064 q.text("%#x" % self.max_speed)
1065 q.breakable()
1066 q.text('}')
1067
1068
1069class port_stats_entry(loxi.OFObject):
1070
1071 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):
1072 if port_no != None:
1073 self.port_no = port_no
1074 else:
1075 self.port_no = 0
1076 if rx_packets != None:
1077 self.rx_packets = rx_packets
1078 else:
1079 self.rx_packets = 0
1080 if tx_packets != None:
1081 self.tx_packets = tx_packets
1082 else:
1083 self.tx_packets = 0
1084 if rx_bytes != None:
1085 self.rx_bytes = rx_bytes
1086 else:
1087 self.rx_bytes = 0
1088 if tx_bytes != None:
1089 self.tx_bytes = tx_bytes
1090 else:
1091 self.tx_bytes = 0
1092 if rx_dropped != None:
1093 self.rx_dropped = rx_dropped
1094 else:
1095 self.rx_dropped = 0
1096 if tx_dropped != None:
1097 self.tx_dropped = tx_dropped
1098 else:
1099 self.tx_dropped = 0
1100 if rx_errors != None:
1101 self.rx_errors = rx_errors
1102 else:
1103 self.rx_errors = 0
1104 if tx_errors != None:
1105 self.tx_errors = tx_errors
1106 else:
1107 self.tx_errors = 0
1108 if rx_frame_err != None:
1109 self.rx_frame_err = rx_frame_err
1110 else:
1111 self.rx_frame_err = 0
1112 if rx_over_err != None:
1113 self.rx_over_err = rx_over_err
1114 else:
1115 self.rx_over_err = 0
1116 if rx_crc_err != None:
1117 self.rx_crc_err = rx_crc_err
1118 else:
1119 self.rx_crc_err = 0
1120 if collisions != None:
1121 self.collisions = collisions
1122 else:
1123 self.collisions = 0
1124 return
1125
1126 def pack(self):
1127 packed = []
1128 packed.append(util.pack_port_no(self.port_no))
1129 packed.append('\x00' * 4)
1130 packed.append(struct.pack("!Q", self.rx_packets))
1131 packed.append(struct.pack("!Q", self.tx_packets))
1132 packed.append(struct.pack("!Q", self.rx_bytes))
1133 packed.append(struct.pack("!Q", self.tx_bytes))
1134 packed.append(struct.pack("!Q", self.rx_dropped))
1135 packed.append(struct.pack("!Q", self.tx_dropped))
1136 packed.append(struct.pack("!Q", self.rx_errors))
1137 packed.append(struct.pack("!Q", self.tx_errors))
1138 packed.append(struct.pack("!Q", self.rx_frame_err))
1139 packed.append(struct.pack("!Q", self.rx_over_err))
1140 packed.append(struct.pack("!Q", self.rx_crc_err))
1141 packed.append(struct.pack("!Q", self.collisions))
1142 return ''.join(packed)
1143
1144 @staticmethod
1145 def unpack(reader):
1146 obj = port_stats_entry()
1147 obj.port_no = util.unpack_port_no(reader)
1148 reader.skip(4)
1149 obj.rx_packets = reader.read("!Q")[0]
1150 obj.tx_packets = reader.read("!Q")[0]
1151 obj.rx_bytes = reader.read("!Q")[0]
1152 obj.tx_bytes = reader.read("!Q")[0]
1153 obj.rx_dropped = reader.read("!Q")[0]
1154 obj.tx_dropped = reader.read("!Q")[0]
1155 obj.rx_errors = reader.read("!Q")[0]
1156 obj.tx_errors = reader.read("!Q")[0]
1157 obj.rx_frame_err = reader.read("!Q")[0]
1158 obj.rx_over_err = reader.read("!Q")[0]
1159 obj.rx_crc_err = reader.read("!Q")[0]
1160 obj.collisions = reader.read("!Q")[0]
1161 return obj
1162
1163 def __eq__(self, other):
1164 if type(self) != type(other): return False
1165 if self.port_no != other.port_no: return False
1166 if self.rx_packets != other.rx_packets: return False
1167 if self.tx_packets != other.tx_packets: return False
1168 if self.rx_bytes != other.rx_bytes: return False
1169 if self.tx_bytes != other.tx_bytes: return False
1170 if self.rx_dropped != other.rx_dropped: return False
1171 if self.tx_dropped != other.tx_dropped: return False
1172 if self.rx_errors != other.rx_errors: return False
1173 if self.tx_errors != other.tx_errors: return False
1174 if self.rx_frame_err != other.rx_frame_err: return False
1175 if self.rx_over_err != other.rx_over_err: return False
1176 if self.rx_crc_err != other.rx_crc_err: return False
1177 if self.collisions != other.collisions: return False
1178 return True
1179
1180 def pretty_print(self, q):
1181 q.text("port_stats_entry {")
1182 with q.group():
1183 with q.indent(2):
1184 q.breakable()
1185 q.text("port_no = ");
1186 q.text(util.pretty_port(self.port_no))
1187 q.text(","); q.breakable()
1188 q.text("rx_packets = ");
1189 q.text("%#x" % self.rx_packets)
1190 q.text(","); q.breakable()
1191 q.text("tx_packets = ");
1192 q.text("%#x" % self.tx_packets)
1193 q.text(","); q.breakable()
1194 q.text("rx_bytes = ");
1195 q.text("%#x" % self.rx_bytes)
1196 q.text(","); q.breakable()
1197 q.text("tx_bytes = ");
1198 q.text("%#x" % self.tx_bytes)
1199 q.text(","); q.breakable()
1200 q.text("rx_dropped = ");
1201 q.text("%#x" % self.rx_dropped)
1202 q.text(","); q.breakable()
1203 q.text("tx_dropped = ");
1204 q.text("%#x" % self.tx_dropped)
1205 q.text(","); q.breakable()
1206 q.text("rx_errors = ");
1207 q.text("%#x" % self.rx_errors)
1208 q.text(","); q.breakable()
1209 q.text("tx_errors = ");
1210 q.text("%#x" % self.tx_errors)
1211 q.text(","); q.breakable()
1212 q.text("rx_frame_err = ");
1213 q.text("%#x" % self.rx_frame_err)
1214 q.text(","); q.breakable()
1215 q.text("rx_over_err = ");
1216 q.text("%#x" % self.rx_over_err)
1217 q.text(","); q.breakable()
1218 q.text("rx_crc_err = ");
1219 q.text("%#x" % self.rx_crc_err)
1220 q.text(","); q.breakable()
1221 q.text("collisions = ");
1222 q.text("%#x" % self.collisions)
1223 q.breakable()
1224 q.text('}')
1225
1226
1227class queue_prop(loxi.OFObject):
1228 subtypes = {}
1229
1230
1231 def __init__(self, type=None):
1232 if type != None:
1233 self.type = type
1234 else:
1235 self.type = 0
1236 return
1237
1238 def pack(self):
1239 packed = []
1240 packed.append(struct.pack("!H", self.type))
1241 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1242 packed.append('\x00' * 4)
1243 length = sum([len(x) for x in packed])
1244 packed[1] = struct.pack("!H", length)
1245 return ''.join(packed)
1246
1247 @staticmethod
1248 def unpack(reader):
1249 subtype, = reader.peek('!H', 0)
1250 subclass = queue_prop.subtypes.get(subtype)
1251 if subclass:
1252 return subclass.unpack(reader)
1253
1254 obj = queue_prop()
1255 obj.type = reader.read("!H")[0]
1256 _len = reader.read("!H")[0]
1257 orig_reader = reader
1258 reader = orig_reader.slice(_len, 4)
1259 reader.skip(4)
1260 return obj
1261
1262 def __eq__(self, other):
1263 if type(self) != type(other): return False
1264 if self.type != other.type: return False
1265 return True
1266
1267 def pretty_print(self, q):
1268 q.text("queue_prop {")
1269 with q.group():
1270 with q.indent(2):
1271 q.breakable()
1272 q.breakable()
1273 q.text('}')
1274
1275
1276class queue_prop_experimenter(queue_prop):
1277 subtypes = {}
1278
1279 type = 65535
1280
1281 def __init__(self, experimenter=None, data=None):
1282 if experimenter != None:
1283 self.experimenter = experimenter
1284 else:
1285 self.experimenter = 0
1286 if data != None:
1287 self.data = data
1288 else:
1289 self.data = ''
1290 return
1291
1292 def pack(self):
1293 packed = []
1294 packed.append(struct.pack("!H", self.type))
1295 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1296 packed.append('\x00' * 4)
1297 packed.append(struct.pack("!L", self.experimenter))
1298 packed.append('\x00' * 4)
1299 packed.append(self.data)
1300 length = sum([len(x) for x in packed])
1301 packed[1] = struct.pack("!H", length)
1302 return ''.join(packed)
1303
1304 @staticmethod
1305 def unpack(reader):
1306 subtype, = reader.peek('!L', 8)
1307 subclass = queue_prop_experimenter.subtypes.get(subtype)
1308 if subclass:
1309 return subclass.unpack(reader)
1310
1311 obj = queue_prop_experimenter()
1312 _type = reader.read("!H")[0]
1313 assert(_type == 65535)
1314 _len = reader.read("!H")[0]
1315 orig_reader = reader
1316 reader = orig_reader.slice(_len, 4)
1317 reader.skip(4)
1318 obj.experimenter = reader.read("!L")[0]
1319 reader.skip(4)
1320 obj.data = str(reader.read_all())
1321 return obj
1322
1323 def __eq__(self, other):
1324 if type(self) != type(other): return False
1325 if self.experimenter != other.experimenter: return False
1326 if self.data != other.data: return False
1327 return True
1328
1329 def pretty_print(self, q):
1330 q.text("queue_prop_experimenter {")
1331 with q.group():
1332 with q.indent(2):
1333 q.breakable()
1334 q.text("data = ");
1335 q.pp(self.data)
1336 q.breakable()
1337 q.text('}')
1338
1339queue_prop.subtypes[65535] = queue_prop_experimenter
1340
1341class queue_prop_max_rate(queue_prop):
1342 type = 2
1343
1344 def __init__(self, rate=None):
1345 if rate != None:
1346 self.rate = rate
1347 else:
1348 self.rate = 0
1349 return
1350
1351 def pack(self):
1352 packed = []
1353 packed.append(struct.pack("!H", self.type))
1354 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1355 packed.append('\x00' * 4)
1356 packed.append(struct.pack("!H", self.rate))
1357 packed.append('\x00' * 6)
1358 length = sum([len(x) for x in packed])
1359 packed[1] = struct.pack("!H", length)
1360 return ''.join(packed)
1361
1362 @staticmethod
1363 def unpack(reader):
1364 obj = queue_prop_max_rate()
1365 _type = reader.read("!H")[0]
1366 assert(_type == 2)
1367 _len = reader.read("!H")[0]
1368 orig_reader = reader
1369 reader = orig_reader.slice(_len, 4)
1370 reader.skip(4)
1371 obj.rate = reader.read("!H")[0]
1372 reader.skip(6)
1373 return obj
1374
1375 def __eq__(self, other):
1376 if type(self) != type(other): return False
1377 if self.rate != other.rate: return False
1378 return True
1379
1380 def pretty_print(self, q):
1381 q.text("queue_prop_max_rate {")
1382 with q.group():
1383 with q.indent(2):
1384 q.breakable()
1385 q.text("rate = ");
1386 q.text("%#x" % self.rate)
1387 q.breakable()
1388 q.text('}')
1389
1390queue_prop.subtypes[2] = queue_prop_max_rate
1391
1392class queue_prop_min_rate(queue_prop):
1393 type = 1
1394
1395 def __init__(self, rate=None):
1396 if rate != None:
1397 self.rate = rate
1398 else:
1399 self.rate = 0
1400 return
1401
1402 def pack(self):
1403 packed = []
1404 packed.append(struct.pack("!H", self.type))
1405 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1406 packed.append('\x00' * 4)
1407 packed.append(struct.pack("!H", self.rate))
1408 packed.append('\x00' * 6)
1409 length = sum([len(x) for x in packed])
1410 packed[1] = struct.pack("!H", length)
1411 return ''.join(packed)
1412
1413 @staticmethod
1414 def unpack(reader):
1415 obj = queue_prop_min_rate()
1416 _type = reader.read("!H")[0]
1417 assert(_type == 1)
1418 _len = reader.read("!H")[0]
1419 orig_reader = reader
1420 reader = orig_reader.slice(_len, 4)
1421 reader.skip(4)
1422 obj.rate = reader.read("!H")[0]
1423 reader.skip(6)
1424 return obj
1425
1426 def __eq__(self, other):
1427 if type(self) != type(other): return False
1428 if self.rate != other.rate: return False
1429 return True
1430
1431 def pretty_print(self, q):
1432 q.text("queue_prop_min_rate {")
1433 with q.group():
1434 with q.indent(2):
1435 q.breakable()
1436 q.text("rate = ");
1437 q.text("%#x" % self.rate)
1438 q.breakable()
1439 q.text('}')
1440
1441queue_prop.subtypes[1] = queue_prop_min_rate
1442
1443class queue_stats_entry(loxi.OFObject):
1444
1445 def __init__(self, port_no=None, queue_id=None, tx_bytes=None, tx_packets=None, tx_errors=None):
1446 if port_no != None:
1447 self.port_no = port_no
1448 else:
1449 self.port_no = 0
1450 if queue_id != None:
1451 self.queue_id = queue_id
1452 else:
1453 self.queue_id = 0
1454 if tx_bytes != None:
1455 self.tx_bytes = tx_bytes
1456 else:
1457 self.tx_bytes = 0
1458 if tx_packets != None:
1459 self.tx_packets = tx_packets
1460 else:
1461 self.tx_packets = 0
1462 if tx_errors != None:
1463 self.tx_errors = tx_errors
1464 else:
1465 self.tx_errors = 0
1466 return
1467
1468 def pack(self):
1469 packed = []
1470 packed.append(util.pack_port_no(self.port_no))
1471 packed.append(struct.pack("!L", self.queue_id))
1472 packed.append(struct.pack("!Q", self.tx_bytes))
1473 packed.append(struct.pack("!Q", self.tx_packets))
1474 packed.append(struct.pack("!Q", self.tx_errors))
1475 return ''.join(packed)
1476
1477 @staticmethod
1478 def unpack(reader):
1479 obj = queue_stats_entry()
1480 obj.port_no = util.unpack_port_no(reader)
1481 obj.queue_id = reader.read("!L")[0]
1482 obj.tx_bytes = reader.read("!Q")[0]
1483 obj.tx_packets = reader.read("!Q")[0]
1484 obj.tx_errors = reader.read("!Q")[0]
1485 return obj
1486
1487 def __eq__(self, other):
1488 if type(self) != type(other): return False
1489 if self.port_no != other.port_no: return False
1490 if self.queue_id != other.queue_id: return False
1491 if self.tx_bytes != other.tx_bytes: return False
1492 if self.tx_packets != other.tx_packets: return False
1493 if self.tx_errors != other.tx_errors: return False
1494 return True
1495
1496 def pretty_print(self, q):
1497 q.text("queue_stats_entry {")
1498 with q.group():
1499 with q.indent(2):
1500 q.breakable()
1501 q.text("port_no = ");
1502 q.text(util.pretty_port(self.port_no))
1503 q.text(","); q.breakable()
1504 q.text("queue_id = ");
1505 q.text("%#x" % self.queue_id)
1506 q.text(","); q.breakable()
1507 q.text("tx_bytes = ");
1508 q.text("%#x" % self.tx_bytes)
1509 q.text(","); q.breakable()
1510 q.text("tx_packets = ");
1511 q.text("%#x" % self.tx_packets)
1512 q.text(","); q.breakable()
1513 q.text("tx_errors = ");
1514 q.text("%#x" % self.tx_errors)
1515 q.breakable()
1516 q.text('}')
1517
1518
1519class table_stats_entry(loxi.OFObject):
1520
1521 def __init__(self, table_id=None, name=None, match=None, wildcards=None, write_actions=None, apply_actions=None, write_setfields=None, apply_setfields=None, metadata_match=None, metadata_write=None, instructions=None, config=None, max_entries=None, active_count=None, lookup_count=None, matched_count=None):
1522 if table_id != None:
1523 self.table_id = table_id
1524 else:
1525 self.table_id = 0
1526 if name != None:
1527 self.name = name
1528 else:
1529 self.name = ""
1530 if match != None:
1531 self.match = match
1532 else:
1533 self.match = util.init_match_bmap()
1534 if wildcards != None:
1535 self.wildcards = wildcards
1536 else:
1537 self.wildcards = util.init_wc_bmap()
1538 if write_actions != None:
1539 self.write_actions = write_actions
1540 else:
1541 self.write_actions = 0
1542 if apply_actions != None:
1543 self.apply_actions = apply_actions
1544 else:
1545 self.apply_actions = 0
1546 if write_setfields != None:
1547 self.write_setfields = write_setfields
1548 else:
1549 self.write_setfields = 0
1550 if apply_setfields != None:
1551 self.apply_setfields = apply_setfields
1552 else:
1553 self.apply_setfields = 0
1554 if metadata_match != None:
1555 self.metadata_match = metadata_match
1556 else:
1557 self.metadata_match = 0
1558 if metadata_write != None:
1559 self.metadata_write = metadata_write
1560 else:
1561 self.metadata_write = 0
1562 if instructions != None:
1563 self.instructions = instructions
1564 else:
1565 self.instructions = 0
1566 if config != None:
1567 self.config = config
1568 else:
1569 self.config = 0
1570 if max_entries != None:
1571 self.max_entries = max_entries
1572 else:
1573 self.max_entries = 0
1574 if active_count != None:
1575 self.active_count = active_count
1576 else:
1577 self.active_count = 0
1578 if lookup_count != None:
1579 self.lookup_count = lookup_count
1580 else:
1581 self.lookup_count = 0
1582 if matched_count != None:
1583 self.matched_count = matched_count
1584 else:
1585 self.matched_count = 0
1586 return
1587
1588 def pack(self):
1589 packed = []
1590 packed.append(struct.pack("!B", self.table_id))
1591 packed.append('\x00' * 7)
1592 packed.append(struct.pack("!32s", self.name))
1593 packed.append(util.pack_match_bmap(self.match))
1594 packed.append(util.pack_wc_bmap(self.wildcards))
1595 packed.append(struct.pack("!L", self.write_actions))
1596 packed.append(struct.pack("!L", self.apply_actions))
1597 packed.append(struct.pack("!Q", self.write_setfields))
1598 packed.append(struct.pack("!Q", self.apply_setfields))
1599 packed.append(struct.pack("!Q", self.metadata_match))
1600 packed.append(struct.pack("!Q", self.metadata_write))
1601 packed.append(struct.pack("!L", self.instructions))
1602 packed.append(struct.pack("!L", self.config))
1603 packed.append(struct.pack("!L", self.max_entries))
1604 packed.append(struct.pack("!L", self.active_count))
1605 packed.append(struct.pack("!Q", self.lookup_count))
1606 packed.append(struct.pack("!Q", self.matched_count))
1607 return ''.join(packed)
1608
1609 @staticmethod
1610 def unpack(reader):
1611 obj = table_stats_entry()
1612 obj.table_id = reader.read("!B")[0]
1613 reader.skip(7)
1614 obj.name = reader.read("!32s")[0].rstrip("\x00")
1615 obj.match = util.unpack_match_bmap(reader)
1616 obj.wildcards = util.unpack_wc_bmap(reader)
1617 obj.write_actions = reader.read("!L")[0]
1618 obj.apply_actions = reader.read("!L")[0]
1619 obj.write_setfields = reader.read("!Q")[0]
1620 obj.apply_setfields = reader.read("!Q")[0]
1621 obj.metadata_match = reader.read("!Q")[0]
1622 obj.metadata_write = reader.read("!Q")[0]
1623 obj.instructions = reader.read("!L")[0]
1624 obj.config = reader.read("!L")[0]
1625 obj.max_entries = reader.read("!L")[0]
1626 obj.active_count = reader.read("!L")[0]
1627 obj.lookup_count = reader.read("!Q")[0]
1628 obj.matched_count = reader.read("!Q")[0]
1629 return obj
1630
1631 def __eq__(self, other):
1632 if type(self) != type(other): return False
1633 if self.table_id != other.table_id: return False
1634 if self.name != other.name: return False
1635 if self.match != other.match: return False
1636 if self.wildcards != other.wildcards: return False
1637 if self.write_actions != other.write_actions: return False
1638 if self.apply_actions != other.apply_actions: return False
1639 if self.write_setfields != other.write_setfields: return False
1640 if self.apply_setfields != other.apply_setfields: return False
1641 if self.metadata_match != other.metadata_match: return False
1642 if self.metadata_write != other.metadata_write: return False
1643 if self.instructions != other.instructions: return False
1644 if self.config != other.config: return False
1645 if self.max_entries != other.max_entries: return False
1646 if self.active_count != other.active_count: return False
1647 if self.lookup_count != other.lookup_count: return False
1648 if self.matched_count != other.matched_count: return False
1649 return True
1650
1651 def pretty_print(self, q):
1652 q.text("table_stats_entry {")
1653 with q.group():
1654 with q.indent(2):
1655 q.breakable()
1656 q.text("table_id = ");
1657 q.text("%#x" % self.table_id)
1658 q.text(","); q.breakable()
1659 q.text("name = ");
1660 q.pp(self.name)
1661 q.text(","); q.breakable()
1662 q.text("match = ");
1663 q.pp(self.match)
1664 q.text(","); q.breakable()
1665 q.text("wildcards = ");
1666 q.pp(self.wildcards)
1667 q.text(","); q.breakable()
1668 q.text("write_actions = ");
1669 q.text("%#x" % self.write_actions)
1670 q.text(","); q.breakable()
1671 q.text("apply_actions = ");
1672 q.text("%#x" % self.apply_actions)
1673 q.text(","); q.breakable()
1674 q.text("write_setfields = ");
1675 q.text("%#x" % self.write_setfields)
1676 q.text(","); q.breakable()
1677 q.text("apply_setfields = ");
1678 q.text("%#x" % self.apply_setfields)
1679 q.text(","); q.breakable()
1680 q.text("metadata_match = ");
1681 q.text("%#x" % self.metadata_match)
1682 q.text(","); q.breakable()
1683 q.text("metadata_write = ");
1684 q.text("%#x" % self.metadata_write)
1685 q.text(","); q.breakable()
1686 q.text("instructions = ");
1687 q.text("%#x" % self.instructions)
1688 q.text(","); q.breakable()
1689 q.text("config = ");
1690 q.text("%#x" % self.config)
1691 q.text(","); q.breakable()
1692 q.text("max_entries = ");
1693 q.text("%#x" % self.max_entries)
1694 q.text(","); q.breakable()
1695 q.text("active_count = ");
1696 q.text("%#x" % self.active_count)
1697 q.text(","); q.breakable()
1698 q.text("lookup_count = ");
1699 q.text("%#x" % self.lookup_count)
1700 q.text(","); q.breakable()
1701 q.text("matched_count = ");
1702 q.text("%#x" % self.matched_count)
1703 q.breakable()
1704 q.text('}')
1705
1706
1707
1708match = match_v3