blob: dadd6bc2deff2ffe55e47a6558ada1a71948ce27 [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.of11']
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_v2(loxi.OFObject):
818 type = 0
819
820 def __init__(self, in_port=None, wildcards=None, eth_src=None, eth_src_mask=None, eth_dst=None, eth_dst_mask=None, vlan_vid=None, vlan_pcp=None, eth_type=None, ip_dscp=None, ip_proto=None, ipv4_src=None, ipv4_src_mask=None, ipv4_dst=None, ipv4_dst_mask=None, tcp_src=None, tcp_dst=None, mpls_label=None, mpls_tc=None, metadata=None, metadata_mask=None):
821 if in_port != None:
822 self.in_port = in_port
823 else:
824 self.in_port = 0
825 if wildcards != None:
826 self.wildcards = wildcards
827 else:
828 self.wildcards = util.init_wc_bmap()
829 if eth_src != None:
830 self.eth_src = eth_src
831 else:
832 self.eth_src = [0,0,0,0,0,0]
833 if eth_src_mask != None:
834 self.eth_src_mask = eth_src_mask
835 else:
836 self.eth_src_mask = [0,0,0,0,0,0]
837 if eth_dst != None:
838 self.eth_dst = eth_dst
839 else:
840 self.eth_dst = [0,0,0,0,0,0]
841 if eth_dst_mask != None:
842 self.eth_dst_mask = eth_dst_mask
843 else:
844 self.eth_dst_mask = [0,0,0,0,0,0]
845 if vlan_vid != None:
846 self.vlan_vid = vlan_vid
847 else:
848 self.vlan_vid = 0
849 if vlan_pcp != None:
850 self.vlan_pcp = vlan_pcp
851 else:
852 self.vlan_pcp = 0
853 if eth_type != None:
854 self.eth_type = eth_type
855 else:
856 self.eth_type = 0
857 if ip_dscp != None:
858 self.ip_dscp = ip_dscp
859 else:
860 self.ip_dscp = 0
861 if ip_proto != None:
862 self.ip_proto = ip_proto
863 else:
864 self.ip_proto = 0
865 if ipv4_src != None:
866 self.ipv4_src = ipv4_src
867 else:
868 self.ipv4_src = 0
869 if ipv4_src_mask != None:
870 self.ipv4_src_mask = ipv4_src_mask
871 else:
872 self.ipv4_src_mask = 0
873 if ipv4_dst != None:
874 self.ipv4_dst = ipv4_dst
875 else:
876 self.ipv4_dst = 0
877 if ipv4_dst_mask != None:
878 self.ipv4_dst_mask = ipv4_dst_mask
879 else:
880 self.ipv4_dst_mask = 0
881 if tcp_src != None:
882 self.tcp_src = tcp_src
883 else:
884 self.tcp_src = 0
885 if tcp_dst != None:
886 self.tcp_dst = tcp_dst
887 else:
888 self.tcp_dst = 0
889 if mpls_label != None:
890 self.mpls_label = mpls_label
891 else:
892 self.mpls_label = 0
893 if mpls_tc != None:
894 self.mpls_tc = mpls_tc
895 else:
896 self.mpls_tc = 0
897 if metadata != None:
898 self.metadata = metadata
899 else:
900 self.metadata = 0
901 if metadata_mask != None:
902 self.metadata_mask = metadata_mask
903 else:
904 self.metadata_mask = 0
905 return
906
907 def pack(self):
908 packed = []
909 packed.append(struct.pack("!H", self.type))
910 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
911 packed.append(util.pack_port_no(self.in_port))
912 packed.append(util.pack_wc_bmap(self.wildcards))
913 packed.append(struct.pack("!6B", *self.eth_src))
914 packed.append(struct.pack("!6B", *self.eth_src_mask))
915 packed.append(struct.pack("!6B", *self.eth_dst))
916 packed.append(struct.pack("!6B", *self.eth_dst_mask))
917 packed.append(struct.pack("!H", self.vlan_vid))
918 packed.append(struct.pack("!B", self.vlan_pcp))
919 packed.append('\x00' * 1)
920 packed.append(struct.pack("!H", self.eth_type))
921 packed.append(struct.pack("!B", self.ip_dscp))
922 packed.append(struct.pack("!B", self.ip_proto))
923 packed.append(struct.pack("!L", self.ipv4_src))
924 packed.append(struct.pack("!L", self.ipv4_src_mask))
925 packed.append(struct.pack("!L", self.ipv4_dst))
926 packed.append(struct.pack("!L", self.ipv4_dst_mask))
927 packed.append(struct.pack("!H", self.tcp_src))
928 packed.append(struct.pack("!H", self.tcp_dst))
929 packed.append(struct.pack("!L", self.mpls_label))
930 packed.append(struct.pack("!B", self.mpls_tc))
931 packed.append('\x00' * 3)
932 packed.append(struct.pack("!Q", self.metadata))
933 packed.append(struct.pack("!Q", self.metadata_mask))
934 length = sum([len(x) for x in packed])
935 packed[1] = struct.pack("!H", length)
936 return ''.join(packed)
937
938 @staticmethod
939 def unpack(reader):
940 obj = match_v2()
941 _type = reader.read("!H")[0]
942 assert(_type == 0)
943 _length = reader.read("!H")[0]
944 orig_reader = reader
945 reader = orig_reader.slice(_length, 4)
946 obj.in_port = util.unpack_port_no(reader)
947 obj.wildcards = util.unpack_wc_bmap(reader)
948 obj.eth_src = list(reader.read('!6B'))
949 obj.eth_src_mask = list(reader.read('!6B'))
950 obj.eth_dst = list(reader.read('!6B'))
951 obj.eth_dst_mask = list(reader.read('!6B'))
952 obj.vlan_vid = reader.read("!H")[0]
953 obj.vlan_pcp = reader.read("!B")[0]
954 reader.skip(1)
955 obj.eth_type = reader.read("!H")[0]
956 obj.ip_dscp = reader.read("!B")[0]
957 obj.ip_proto = reader.read("!B")[0]
958 obj.ipv4_src = reader.read("!L")[0]
959 obj.ipv4_src_mask = reader.read("!L")[0]
960 obj.ipv4_dst = reader.read("!L")[0]
961 obj.ipv4_dst_mask = reader.read("!L")[0]
962 obj.tcp_src = reader.read("!H")[0]
963 obj.tcp_dst = reader.read("!H")[0]
964 obj.mpls_label = reader.read("!L")[0]
965 obj.mpls_tc = reader.read("!B")[0]
966 reader.skip(3)
967 obj.metadata = reader.read("!Q")[0]
968 obj.metadata_mask = reader.read("!Q")[0]
969 return obj
970
971 def __eq__(self, other):
972 if type(self) != type(other): return False
973 if self.in_port != other.in_port: return False
974 if self.wildcards != other.wildcards: return False
975 if self.eth_src != other.eth_src: return False
976 if self.eth_src_mask != other.eth_src_mask: return False
977 if self.eth_dst != other.eth_dst: return False
978 if self.eth_dst_mask != other.eth_dst_mask: return False
979 if self.vlan_vid != other.vlan_vid: return False
980 if self.vlan_pcp != other.vlan_pcp: return False
981 if self.eth_type != other.eth_type: return False
982 if self.ip_dscp != other.ip_dscp: return False
983 if self.ip_proto != other.ip_proto: return False
984 if self.ipv4_src != other.ipv4_src: return False
985 if self.ipv4_src_mask != other.ipv4_src_mask: return False
986 if self.ipv4_dst != other.ipv4_dst: return False
987 if self.ipv4_dst_mask != other.ipv4_dst_mask: return False
988 if self.tcp_src != other.tcp_src: return False
989 if self.tcp_dst != other.tcp_dst: return False
990 if self.mpls_label != other.mpls_label: return False
991 if self.mpls_tc != other.mpls_tc: return False
992 if self.metadata != other.metadata: return False
993 if self.metadata_mask != other.metadata_mask: return False
994 return True
995
996 def pretty_print(self, q):
997 q.text("match_v2 {")
998 with q.group():
999 with q.indent(2):
1000 q.breakable()
1001 q.text("in_port = ");
1002 q.text(util.pretty_port(self.in_port))
1003 q.text(","); q.breakable()
1004 q.text("wildcards = ");
1005 q.text(util.pretty_wildcards(self.wildcards))
1006 q.text(","); q.breakable()
1007 q.text("eth_src = ");
1008 q.text(util.pretty_mac(self.eth_src))
1009 q.text(","); q.breakable()
1010 q.text("eth_src_mask = ");
1011 q.text(util.pretty_mac(self.eth_src_mask))
1012 q.text(","); q.breakable()
1013 q.text("eth_dst = ");
1014 q.text(util.pretty_mac(self.eth_dst))
1015 q.text(","); q.breakable()
1016 q.text("eth_dst_mask = ");
1017 q.text(util.pretty_mac(self.eth_dst_mask))
1018 q.text(","); q.breakable()
1019 q.text("vlan_vid = ");
1020 q.text("%#x" % self.vlan_vid)
1021 q.text(","); q.breakable()
1022 q.text("vlan_pcp = ");
1023 q.text("%#x" % self.vlan_pcp)
1024 q.text(","); q.breakable()
1025 q.text("eth_type = ");
1026 q.text("%#x" % self.eth_type)
1027 q.text(","); q.breakable()
1028 q.text("ip_dscp = ");
1029 q.text("%#x" % self.ip_dscp)
1030 q.text(","); q.breakable()
1031 q.text("ip_proto = ");
1032 q.text("%#x" % self.ip_proto)
1033 q.text(","); q.breakable()
1034 q.text("ipv4_src = ");
1035 q.text(util.pretty_ipv4(self.ipv4_src))
1036 q.text(","); q.breakable()
1037 q.text("ipv4_src_mask = ");
1038 q.text(util.pretty_ipv4(self.ipv4_src_mask))
1039 q.text(","); q.breakable()
1040 q.text("ipv4_dst = ");
1041 q.text(util.pretty_ipv4(self.ipv4_dst))
1042 q.text(","); q.breakable()
1043 q.text("ipv4_dst_mask = ");
1044 q.text(util.pretty_ipv4(self.ipv4_dst_mask))
1045 q.text(","); q.breakable()
1046 q.text("tcp_src = ");
1047 q.text("%#x" % self.tcp_src)
1048 q.text(","); q.breakable()
1049 q.text("tcp_dst = ");
1050 q.text("%#x" % self.tcp_dst)
1051 q.text(","); q.breakable()
1052 q.text("mpls_label = ");
1053 q.text("%#x" % self.mpls_label)
1054 q.text(","); q.breakable()
1055 q.text("mpls_tc = ");
1056 q.text("%#x" % self.mpls_tc)
1057 q.text(","); q.breakable()
1058 q.text("metadata = ");
1059 q.text("%#x" % self.metadata)
1060 q.text(","); q.breakable()
1061 q.text("metadata_mask = ");
1062 q.text("%#x" % self.metadata_mask)
1063 q.breakable()
1064 q.text('}')
1065
1066
1067class packet_queue(loxi.OFObject):
1068
1069 def __init__(self, queue_id=None, properties=None):
1070 if queue_id != None:
1071 self.queue_id = queue_id
1072 else:
1073 self.queue_id = 0
1074 if properties != None:
1075 self.properties = properties
1076 else:
1077 self.properties = []
1078 return
1079
1080 def pack(self):
1081 packed = []
1082 packed.append(struct.pack("!L", self.queue_id))
1083 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1084 packed.append('\x00' * 2)
1085 packed.append(loxi.generic_util.pack_list(self.properties))
1086 length = sum([len(x) for x in packed])
1087 packed[1] = struct.pack("!H", length)
1088 return ''.join(packed)
1089
1090 @staticmethod
1091 def unpack(reader):
1092 obj = packet_queue()
1093 obj.queue_id = reader.read("!L")[0]
1094 _len = reader.read("!H")[0]
1095 orig_reader = reader
1096 reader = orig_reader.slice(_len, 6)
1097 reader.skip(2)
1098 obj.properties = loxi.generic_util.unpack_list(reader, ofp.common.queue_prop.unpack)
1099 return obj
1100
1101 def __eq__(self, other):
1102 if type(self) != type(other): return False
1103 if self.queue_id != other.queue_id: return False
1104 if self.properties != other.properties: return False
1105 return True
1106
1107 def pretty_print(self, q):
1108 q.text("packet_queue {")
1109 with q.group():
1110 with q.indent(2):
1111 q.breakable()
1112 q.text("queue_id = ");
1113 q.text("%#x" % self.queue_id)
1114 q.text(","); q.breakable()
1115 q.text("properties = ");
1116 q.pp(self.properties)
1117 q.breakable()
1118 q.text('}')
1119
1120
1121class port_desc(loxi.OFObject):
1122
1123 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):
1124 if port_no != None:
1125 self.port_no = port_no
1126 else:
1127 self.port_no = 0
1128 if hw_addr != None:
1129 self.hw_addr = hw_addr
1130 else:
1131 self.hw_addr = [0,0,0,0,0,0]
1132 if name != None:
1133 self.name = name
1134 else:
1135 self.name = ""
1136 if config != None:
1137 self.config = config
1138 else:
1139 self.config = 0
1140 if state != None:
1141 self.state = state
1142 else:
1143 self.state = 0
1144 if curr != None:
1145 self.curr = curr
1146 else:
1147 self.curr = 0
1148 if advertised != None:
1149 self.advertised = advertised
1150 else:
1151 self.advertised = 0
1152 if supported != None:
1153 self.supported = supported
1154 else:
1155 self.supported = 0
1156 if peer != None:
1157 self.peer = peer
1158 else:
1159 self.peer = 0
1160 if curr_speed != None:
1161 self.curr_speed = curr_speed
1162 else:
1163 self.curr_speed = 0
1164 if max_speed != None:
1165 self.max_speed = max_speed
1166 else:
1167 self.max_speed = 0
1168 return
1169
1170 def pack(self):
1171 packed = []
1172 packed.append(util.pack_port_no(self.port_no))
1173 packed.append('\x00' * 4)
1174 packed.append(struct.pack("!6B", *self.hw_addr))
1175 packed.append('\x00' * 2)
1176 packed.append(struct.pack("!16s", self.name))
1177 packed.append(struct.pack("!L", self.config))
1178 packed.append(struct.pack("!L", self.state))
1179 packed.append(struct.pack("!L", self.curr))
1180 packed.append(struct.pack("!L", self.advertised))
1181 packed.append(struct.pack("!L", self.supported))
1182 packed.append(struct.pack("!L", self.peer))
1183 packed.append(struct.pack("!L", self.curr_speed))
1184 packed.append(struct.pack("!L", self.max_speed))
1185 return ''.join(packed)
1186
1187 @staticmethod
1188 def unpack(reader):
1189 obj = port_desc()
1190 obj.port_no = util.unpack_port_no(reader)
1191 reader.skip(4)
1192 obj.hw_addr = list(reader.read('!6B'))
1193 reader.skip(2)
1194 obj.name = reader.read("!16s")[0].rstrip("\x00")
1195 obj.config = reader.read("!L")[0]
1196 obj.state = reader.read("!L")[0]
1197 obj.curr = reader.read("!L")[0]
1198 obj.advertised = reader.read("!L")[0]
1199 obj.supported = reader.read("!L")[0]
1200 obj.peer = reader.read("!L")[0]
1201 obj.curr_speed = reader.read("!L")[0]
1202 obj.max_speed = reader.read("!L")[0]
1203 return obj
1204
1205 def __eq__(self, other):
1206 if type(self) != type(other): return False
1207 if self.port_no != other.port_no: return False
1208 if self.hw_addr != other.hw_addr: return False
1209 if self.name != other.name: return False
1210 if self.config != other.config: return False
1211 if self.state != other.state: return False
1212 if self.curr != other.curr: return False
1213 if self.advertised != other.advertised: return False
1214 if self.supported != other.supported: return False
1215 if self.peer != other.peer: return False
1216 if self.curr_speed != other.curr_speed: return False
1217 if self.max_speed != other.max_speed: return False
1218 return True
1219
1220 def pretty_print(self, q):
1221 q.text("port_desc {")
1222 with q.group():
1223 with q.indent(2):
1224 q.breakable()
1225 q.text("port_no = ");
1226 q.text(util.pretty_port(self.port_no))
1227 q.text(","); q.breakable()
1228 q.text("hw_addr = ");
1229 q.text(util.pretty_mac(self.hw_addr))
1230 q.text(","); q.breakable()
1231 q.text("name = ");
1232 q.pp(self.name)
1233 q.text(","); q.breakable()
1234 q.text("config = ");
1235 q.text("%#x" % self.config)
1236 q.text(","); q.breakable()
1237 q.text("state = ");
1238 q.text("%#x" % self.state)
1239 q.text(","); q.breakable()
1240 q.text("curr = ");
1241 q.text("%#x" % self.curr)
1242 q.text(","); q.breakable()
1243 q.text("advertised = ");
1244 q.text("%#x" % self.advertised)
1245 q.text(","); q.breakable()
1246 q.text("supported = ");
1247 q.text("%#x" % self.supported)
1248 q.text(","); q.breakable()
1249 q.text("peer = ");
1250 q.text("%#x" % self.peer)
1251 q.text(","); q.breakable()
1252 q.text("curr_speed = ");
1253 q.text("%#x" % self.curr_speed)
1254 q.text(","); q.breakable()
1255 q.text("max_speed = ");
1256 q.text("%#x" % self.max_speed)
1257 q.breakable()
1258 q.text('}')
1259
1260
1261class port_stats_entry(loxi.OFObject):
1262
1263 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):
1264 if port_no != None:
1265 self.port_no = port_no
1266 else:
1267 self.port_no = 0
1268 if rx_packets != None:
1269 self.rx_packets = rx_packets
1270 else:
1271 self.rx_packets = 0
1272 if tx_packets != None:
1273 self.tx_packets = tx_packets
1274 else:
1275 self.tx_packets = 0
1276 if rx_bytes != None:
1277 self.rx_bytes = rx_bytes
1278 else:
1279 self.rx_bytes = 0
1280 if tx_bytes != None:
1281 self.tx_bytes = tx_bytes
1282 else:
1283 self.tx_bytes = 0
1284 if rx_dropped != None:
1285 self.rx_dropped = rx_dropped
1286 else:
1287 self.rx_dropped = 0
1288 if tx_dropped != None:
1289 self.tx_dropped = tx_dropped
1290 else:
1291 self.tx_dropped = 0
1292 if rx_errors != None:
1293 self.rx_errors = rx_errors
1294 else:
1295 self.rx_errors = 0
1296 if tx_errors != None:
1297 self.tx_errors = tx_errors
1298 else:
1299 self.tx_errors = 0
1300 if rx_frame_err != None:
1301 self.rx_frame_err = rx_frame_err
1302 else:
1303 self.rx_frame_err = 0
1304 if rx_over_err != None:
1305 self.rx_over_err = rx_over_err
1306 else:
1307 self.rx_over_err = 0
1308 if rx_crc_err != None:
1309 self.rx_crc_err = rx_crc_err
1310 else:
1311 self.rx_crc_err = 0
1312 if collisions != None:
1313 self.collisions = collisions
1314 else:
1315 self.collisions = 0
1316 return
1317
1318 def pack(self):
1319 packed = []
1320 packed.append(util.pack_port_no(self.port_no))
1321 packed.append('\x00' * 4)
1322 packed.append(struct.pack("!Q", self.rx_packets))
1323 packed.append(struct.pack("!Q", self.tx_packets))
1324 packed.append(struct.pack("!Q", self.rx_bytes))
1325 packed.append(struct.pack("!Q", self.tx_bytes))
1326 packed.append(struct.pack("!Q", self.rx_dropped))
1327 packed.append(struct.pack("!Q", self.tx_dropped))
1328 packed.append(struct.pack("!Q", self.rx_errors))
1329 packed.append(struct.pack("!Q", self.tx_errors))
1330 packed.append(struct.pack("!Q", self.rx_frame_err))
1331 packed.append(struct.pack("!Q", self.rx_over_err))
1332 packed.append(struct.pack("!Q", self.rx_crc_err))
1333 packed.append(struct.pack("!Q", self.collisions))
1334 return ''.join(packed)
1335
1336 @staticmethod
1337 def unpack(reader):
1338 obj = port_stats_entry()
1339 obj.port_no = util.unpack_port_no(reader)
1340 reader.skip(4)
1341 obj.rx_packets = reader.read("!Q")[0]
1342 obj.tx_packets = reader.read("!Q")[0]
1343 obj.rx_bytes = reader.read("!Q")[0]
1344 obj.tx_bytes = reader.read("!Q")[0]
1345 obj.rx_dropped = reader.read("!Q")[0]
1346 obj.tx_dropped = reader.read("!Q")[0]
1347 obj.rx_errors = reader.read("!Q")[0]
1348 obj.tx_errors = reader.read("!Q")[0]
1349 obj.rx_frame_err = reader.read("!Q")[0]
1350 obj.rx_over_err = reader.read("!Q")[0]
1351 obj.rx_crc_err = reader.read("!Q")[0]
1352 obj.collisions = reader.read("!Q")[0]
1353 return obj
1354
1355 def __eq__(self, other):
1356 if type(self) != type(other): return False
1357 if self.port_no != other.port_no: return False
1358 if self.rx_packets != other.rx_packets: return False
1359 if self.tx_packets != other.tx_packets: return False
1360 if self.rx_bytes != other.rx_bytes: return False
1361 if self.tx_bytes != other.tx_bytes: return False
1362 if self.rx_dropped != other.rx_dropped: return False
1363 if self.tx_dropped != other.tx_dropped: return False
1364 if self.rx_errors != other.rx_errors: return False
1365 if self.tx_errors != other.tx_errors: return False
1366 if self.rx_frame_err != other.rx_frame_err: return False
1367 if self.rx_over_err != other.rx_over_err: return False
1368 if self.rx_crc_err != other.rx_crc_err: return False
1369 if self.collisions != other.collisions: return False
1370 return True
1371
1372 def pretty_print(self, q):
1373 q.text("port_stats_entry {")
1374 with q.group():
1375 with q.indent(2):
1376 q.breakable()
1377 q.text("port_no = ");
1378 q.text(util.pretty_port(self.port_no))
1379 q.text(","); q.breakable()
1380 q.text("rx_packets = ");
1381 q.text("%#x" % self.rx_packets)
1382 q.text(","); q.breakable()
1383 q.text("tx_packets = ");
1384 q.text("%#x" % self.tx_packets)
1385 q.text(","); q.breakable()
1386 q.text("rx_bytes = ");
1387 q.text("%#x" % self.rx_bytes)
1388 q.text(","); q.breakable()
1389 q.text("tx_bytes = ");
1390 q.text("%#x" % self.tx_bytes)
1391 q.text(","); q.breakable()
1392 q.text("rx_dropped = ");
1393 q.text("%#x" % self.rx_dropped)
1394 q.text(","); q.breakable()
1395 q.text("tx_dropped = ");
1396 q.text("%#x" % self.tx_dropped)
1397 q.text(","); q.breakable()
1398 q.text("rx_errors = ");
1399 q.text("%#x" % self.rx_errors)
1400 q.text(","); q.breakable()
1401 q.text("tx_errors = ");
1402 q.text("%#x" % self.tx_errors)
1403 q.text(","); q.breakable()
1404 q.text("rx_frame_err = ");
1405 q.text("%#x" % self.rx_frame_err)
1406 q.text(","); q.breakable()
1407 q.text("rx_over_err = ");
1408 q.text("%#x" % self.rx_over_err)
1409 q.text(","); q.breakable()
1410 q.text("rx_crc_err = ");
1411 q.text("%#x" % self.rx_crc_err)
1412 q.text(","); q.breakable()
1413 q.text("collisions = ");
1414 q.text("%#x" % self.collisions)
1415 q.breakable()
1416 q.text('}')
1417
1418
1419class queue_prop(loxi.OFObject):
1420 subtypes = {}
1421
1422
1423 def __init__(self, type=None):
1424 if type != None:
1425 self.type = type
1426 else:
1427 self.type = 0
1428 return
1429
1430 def pack(self):
1431 packed = []
1432 packed.append(struct.pack("!H", self.type))
1433 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1434 packed.append('\x00' * 4)
1435 length = sum([len(x) for x in packed])
1436 packed[1] = struct.pack("!H", length)
1437 return ''.join(packed)
1438
1439 @staticmethod
1440 def unpack(reader):
1441 subtype, = reader.peek('!H', 0)
1442 subclass = queue_prop.subtypes.get(subtype)
1443 if subclass:
1444 return subclass.unpack(reader)
1445
1446 obj = queue_prop()
1447 obj.type = reader.read("!H")[0]
1448 _len = reader.read("!H")[0]
1449 orig_reader = reader
1450 reader = orig_reader.slice(_len, 4)
1451 reader.skip(4)
1452 return obj
1453
1454 def __eq__(self, other):
1455 if type(self) != type(other): return False
1456 if self.type != other.type: return False
1457 return True
1458
1459 def pretty_print(self, q):
1460 q.text("queue_prop {")
1461 with q.group():
1462 with q.indent(2):
1463 q.breakable()
1464 q.breakable()
1465 q.text('}')
1466
1467
1468class queue_prop_min_rate(queue_prop):
1469 type = 1
1470
1471 def __init__(self, rate=None):
1472 if rate != None:
1473 self.rate = rate
1474 else:
1475 self.rate = 0
1476 return
1477
1478 def pack(self):
1479 packed = []
1480 packed.append(struct.pack("!H", self.type))
1481 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1482 packed.append('\x00' * 4)
1483 packed.append(struct.pack("!H", self.rate))
1484 packed.append('\x00' * 6)
1485 length = sum([len(x) for x in packed])
1486 packed[1] = struct.pack("!H", length)
1487 return ''.join(packed)
1488
1489 @staticmethod
1490 def unpack(reader):
1491 obj = queue_prop_min_rate()
1492 _type = reader.read("!H")[0]
1493 assert(_type == 1)
1494 _len = reader.read("!H")[0]
1495 orig_reader = reader
1496 reader = orig_reader.slice(_len, 4)
1497 reader.skip(4)
1498 obj.rate = reader.read("!H")[0]
1499 reader.skip(6)
1500 return obj
1501
1502 def __eq__(self, other):
1503 if type(self) != type(other): return False
1504 if self.rate != other.rate: return False
1505 return True
1506
1507 def pretty_print(self, q):
1508 q.text("queue_prop_min_rate {")
1509 with q.group():
1510 with q.indent(2):
1511 q.breakable()
1512 q.text("rate = ");
1513 q.text("%#x" % self.rate)
1514 q.breakable()
1515 q.text('}')
1516
1517queue_prop.subtypes[1] = queue_prop_min_rate
1518
1519class queue_stats_entry(loxi.OFObject):
1520
1521 def __init__(self, port_no=None, queue_id=None, tx_bytes=None, tx_packets=None, tx_errors=None):
1522 if port_no != None:
1523 self.port_no = port_no
1524 else:
1525 self.port_no = 0
1526 if queue_id != None:
1527 self.queue_id = queue_id
1528 else:
1529 self.queue_id = 0
1530 if tx_bytes != None:
1531 self.tx_bytes = tx_bytes
1532 else:
1533 self.tx_bytes = 0
1534 if tx_packets != None:
1535 self.tx_packets = tx_packets
1536 else:
1537 self.tx_packets = 0
1538 if tx_errors != None:
1539 self.tx_errors = tx_errors
1540 else:
1541 self.tx_errors = 0
1542 return
1543
1544 def pack(self):
1545 packed = []
1546 packed.append(util.pack_port_no(self.port_no))
1547 packed.append(struct.pack("!L", self.queue_id))
1548 packed.append(struct.pack("!Q", self.tx_bytes))
1549 packed.append(struct.pack("!Q", self.tx_packets))
1550 packed.append(struct.pack("!Q", self.tx_errors))
1551 return ''.join(packed)
1552
1553 @staticmethod
1554 def unpack(reader):
1555 obj = queue_stats_entry()
1556 obj.port_no = util.unpack_port_no(reader)
1557 obj.queue_id = reader.read("!L")[0]
1558 obj.tx_bytes = reader.read("!Q")[0]
1559 obj.tx_packets = reader.read("!Q")[0]
1560 obj.tx_errors = reader.read("!Q")[0]
1561 return obj
1562
1563 def __eq__(self, other):
1564 if type(self) != type(other): return False
1565 if self.port_no != other.port_no: return False
1566 if self.queue_id != other.queue_id: return False
1567 if self.tx_bytes != other.tx_bytes: return False
1568 if self.tx_packets != other.tx_packets: return False
1569 if self.tx_errors != other.tx_errors: return False
1570 return True
1571
1572 def pretty_print(self, q):
1573 q.text("queue_stats_entry {")
1574 with q.group():
1575 with q.indent(2):
1576 q.breakable()
1577 q.text("port_no = ");
1578 q.text(util.pretty_port(self.port_no))
1579 q.text(","); q.breakable()
1580 q.text("queue_id = ");
1581 q.text("%#x" % self.queue_id)
1582 q.text(","); q.breakable()
1583 q.text("tx_bytes = ");
1584 q.text("%#x" % self.tx_bytes)
1585 q.text(","); q.breakable()
1586 q.text("tx_packets = ");
1587 q.text("%#x" % self.tx_packets)
1588 q.text(","); q.breakable()
1589 q.text("tx_errors = ");
1590 q.text("%#x" % self.tx_errors)
1591 q.breakable()
1592 q.text('}')
1593
1594
1595class table_stats_entry(loxi.OFObject):
1596
1597 def __init__(self, table_id=None, name=None, wildcards=None, match=None, instructions=None, write_actions=None, apply_actions=None, config=None, max_entries=None, active_count=None, lookup_count=None, matched_count=None):
1598 if table_id != None:
1599 self.table_id = table_id
1600 else:
1601 self.table_id = 0
1602 if name != None:
1603 self.name = name
1604 else:
1605 self.name = ""
1606 if wildcards != None:
1607 self.wildcards = wildcards
1608 else:
1609 self.wildcards = util.init_wc_bmap()
1610 if match != None:
1611 self.match = match
1612 else:
1613 self.match = util.init_match_bmap()
1614 if instructions != None:
1615 self.instructions = instructions
1616 else:
1617 self.instructions = 0
1618 if write_actions != None:
1619 self.write_actions = write_actions
1620 else:
1621 self.write_actions = 0
1622 if apply_actions != None:
1623 self.apply_actions = apply_actions
1624 else:
1625 self.apply_actions = 0
1626 if config != None:
1627 self.config = config
1628 else:
1629 self.config = 0
1630 if max_entries != None:
1631 self.max_entries = max_entries
1632 else:
1633 self.max_entries = 0
1634 if active_count != None:
1635 self.active_count = active_count
1636 else:
1637 self.active_count = 0
1638 if lookup_count != None:
1639 self.lookup_count = lookup_count
1640 else:
1641 self.lookup_count = 0
1642 if matched_count != None:
1643 self.matched_count = matched_count
1644 else:
1645 self.matched_count = 0
1646 return
1647
1648 def pack(self):
1649 packed = []
1650 packed.append(struct.pack("!B", self.table_id))
1651 packed.append('\x00' * 7)
1652 packed.append(struct.pack("!32s", self.name))
1653 packed.append(util.pack_wc_bmap(self.wildcards))
1654 packed.append(util.pack_match_bmap(self.match))
1655 packed.append(struct.pack("!L", self.instructions))
1656 packed.append(struct.pack("!L", self.write_actions))
1657 packed.append(struct.pack("!L", self.apply_actions))
1658 packed.append(struct.pack("!L", self.config))
1659 packed.append(struct.pack("!L", self.max_entries))
1660 packed.append(struct.pack("!L", self.active_count))
1661 packed.append(struct.pack("!Q", self.lookup_count))
1662 packed.append(struct.pack("!Q", self.matched_count))
1663 return ''.join(packed)
1664
1665 @staticmethod
1666 def unpack(reader):
1667 obj = table_stats_entry()
1668 obj.table_id = reader.read("!B")[0]
1669 reader.skip(7)
1670 obj.name = reader.read("!32s")[0].rstrip("\x00")
1671 obj.wildcards = util.unpack_wc_bmap(reader)
1672 obj.match = util.unpack_match_bmap(reader)
1673 obj.instructions = reader.read("!L")[0]
1674 obj.write_actions = reader.read("!L")[0]
1675 obj.apply_actions = reader.read("!L")[0]
1676 obj.config = reader.read("!L")[0]
1677 obj.max_entries = reader.read("!L")[0]
1678 obj.active_count = reader.read("!L")[0]
1679 obj.lookup_count = reader.read("!Q")[0]
1680 obj.matched_count = reader.read("!Q")[0]
1681 return obj
1682
1683 def __eq__(self, other):
1684 if type(self) != type(other): return False
1685 if self.table_id != other.table_id: return False
1686 if self.name != other.name: return False
1687 if self.wildcards != other.wildcards: return False
1688 if self.match != other.match: return False
1689 if self.instructions != other.instructions: return False
1690 if self.write_actions != other.write_actions: return False
1691 if self.apply_actions != other.apply_actions: return False
1692 if self.config != other.config: return False
1693 if self.max_entries != other.max_entries: return False
1694 if self.active_count != other.active_count: return False
1695 if self.lookup_count != other.lookup_count: return False
1696 if self.matched_count != other.matched_count: return False
1697 return True
1698
1699 def pretty_print(self, q):
1700 q.text("table_stats_entry {")
1701 with q.group():
1702 with q.indent(2):
1703 q.breakable()
1704 q.text("table_id = ");
1705 q.text("%#x" % self.table_id)
1706 q.text(","); q.breakable()
1707 q.text("name = ");
1708 q.pp(self.name)
1709 q.text(","); q.breakable()
1710 q.text("wildcards = ");
1711 q.text(util.pretty_wildcards(self.wildcards))
1712 q.text(","); q.breakable()
1713 q.text("match = ");
1714 q.pp(self.match)
1715 q.text(","); q.breakable()
1716 q.text("instructions = ");
1717 q.text("%#x" % self.instructions)
1718 q.text(","); q.breakable()
1719 q.text("write_actions = ");
1720 q.text("%#x" % self.write_actions)
1721 q.text(","); q.breakable()
1722 q.text("apply_actions = ");
1723 q.text("%#x" % self.apply_actions)
1724 q.text(","); q.breakable()
1725 q.text("config = ");
1726 q.text("%#x" % self.config)
1727 q.text(","); q.breakable()
1728 q.text("max_entries = ");
1729 q.text("%#x" % self.max_entries)
1730 q.text(","); q.breakable()
1731 q.text("active_count = ");
1732 q.text("%#x" % self.active_count)
1733 q.text(","); q.breakable()
1734 q.text("lookup_count = ");
1735 q.text("%#x" % self.lookup_count)
1736 q.text(","); q.breakable()
1737 q.text("matched_count = ");
1738 q.text("%#x" % self.matched_count)
1739 q.breakable()
1740 q.text('}')
1741
1742
1743
1744match = match_v2