blob: 88e1c799a96bd3f9377efb944436026de5a0632a [file] [log] [blame]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001# Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2# Copyright (c) 2011, 2012 Open Networking Foundation
3# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
Dan Talaycof6202252013-07-02 01:00:29 -07004# See the file LICENSE.pyloxi which should have been included in the source distribution
Rich Lane7dcdf022013-12-11 14:45:27 -08005
6# Automatically generated by LOXI from template module.py
Rich Lanec2ee4b82013-04-24 17:12:38 -07007# Do not modify
8
Rich Lanec2ee4b82013-04-24 17:12:38 -07009import struct
Rich Lane7dcdf022013-12-11 14:45:27 -080010import loxi
Rich Lanec2ee4b82013-04-24 17:12:38 -070011import const
Rich Lane7dcdf022013-12-11 14:45:27 -080012import common
13import action
14import instruction
Rich Lanec2ee4b82013-04-24 17:12:38 -070015import util
16import loxi.generic_util
17
Rich Lane7dcdf022013-12-11 14:45:27 -080018class bsn_interface(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -070019
20 def __init__(self, hw_addr=None, name=None, ipv4_addr=None, ipv4_netmask=None):
21 if hw_addr != None:
22 self.hw_addr = hw_addr
23 else:
24 self.hw_addr = [0,0,0,0,0,0]
25 if name != None:
26 self.name = name
27 else:
28 self.name = ""
29 if ipv4_addr != None:
30 self.ipv4_addr = ipv4_addr
31 else:
32 self.ipv4_addr = 0
33 if ipv4_netmask != None:
34 self.ipv4_netmask = ipv4_netmask
35 else:
36 self.ipv4_netmask = 0
37 return
38
39 def pack(self):
40 packed = []
41 packed.append(struct.pack("!6B", *self.hw_addr))
42 packed.append('\x00' * 2)
43 packed.append(struct.pack("!16s", self.name))
44 packed.append(struct.pack("!L", self.ipv4_addr))
45 packed.append(struct.pack("!L", self.ipv4_netmask))
46 return ''.join(packed)
47
48 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -080049 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -070050 obj = bsn_interface()
Rich Lanec2ee4b82013-04-24 17:12:38 -070051 obj.hw_addr = list(reader.read('!6B'))
52 reader.skip(2)
53 obj.name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -070054 obj.ipv4_addr = reader.read("!L")[0]
55 obj.ipv4_netmask = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -070056 return obj
57
58 def __eq__(self, other):
59 if type(self) != type(other): return False
60 if self.hw_addr != other.hw_addr: return False
61 if self.name != other.name: return False
62 if self.ipv4_addr != other.ipv4_addr: return False
63 if self.ipv4_netmask != other.ipv4_netmask: return False
64 return True
65
Rich Lanec2ee4b82013-04-24 17:12:38 -070066 def pretty_print(self, q):
67 q.text("bsn_interface {")
68 with q.group():
69 with q.indent(2):
70 q.breakable()
71 q.text("hw_addr = ");
72 q.text(util.pretty_mac(self.hw_addr))
73 q.text(","); q.breakable()
74 q.text("name = ");
75 q.pp(self.name)
76 q.text(","); q.breakable()
77 q.text("ipv4_addr = ");
78 q.text(util.pretty_ipv4(self.ipv4_addr))
79 q.text(","); q.breakable()
80 q.text("ipv4_netmask = ");
81 q.text(util.pretty_ipv4(self.ipv4_netmask))
82 q.breakable()
83 q.text('}')
84
Rich Lane7dcdf022013-12-11 14:45:27 -080085
86class bsn_vport(loxi.OFObject):
87 subtypes = {}
88
Rich Lane95f7fc92014-01-27 17:08:16 -080089
90 def __init__(self, type=None):
91 if type != None:
92 self.type = type
93 else:
94 self.type = 0
95 return
96
97 def pack(self):
98 packed = []
99 packed.append(struct.pack("!H", self.type))
100 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
101 length = sum([len(x) for x in packed])
102 packed[1] = struct.pack("!H", length)
103 return ''.join(packed)
104
Rich Lane7dcdf022013-12-11 14:45:27 -0800105 @staticmethod
106 def unpack(reader):
107 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -0800108 subclass = bsn_vport.subtypes.get(subtype)
109 if subclass:
110 return subclass.unpack(reader)
111
112 obj = bsn_vport()
113 obj.type = reader.read("!H")[0]
114 _length = reader.read("!H")[0]
115 orig_reader = reader
116 reader = orig_reader.slice(_length - (2 + 2))
117 return obj
118
119 def __eq__(self, other):
120 if type(self) != type(other): return False
121 if self.type != other.type: return False
122 return True
123
124 def pretty_print(self, q):
125 q.text("bsn_vport {")
126 with q.group():
127 with q.indent(2):
128 q.breakable()
129 q.breakable()
130 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800131
132
Rich Lane93b33132014-04-21 12:20:58 -0700133class bsn_vport_l2gre(bsn_vport):
134 type = 1
135
136 def __init__(self, flags=None, port_no=None, local_mac=None, nh_mac=None, src_ip=None, dst_ip=None, dscp=None, ttl=None, vpn=None, if_name=None):
137 if flags != None:
138 self.flags = flags
139 else:
140 self.flags = 0
141 if port_no != None:
142 self.port_no = port_no
143 else:
144 self.port_no = 0
145 if local_mac != None:
146 self.local_mac = local_mac
147 else:
148 self.local_mac = [0,0,0,0,0,0]
149 if nh_mac != None:
150 self.nh_mac = nh_mac
151 else:
152 self.nh_mac = [0,0,0,0,0,0]
153 if src_ip != None:
154 self.src_ip = src_ip
155 else:
156 self.src_ip = 0
157 if dst_ip != None:
158 self.dst_ip = dst_ip
159 else:
160 self.dst_ip = 0
161 if dscp != None:
162 self.dscp = dscp
163 else:
164 self.dscp = 0
165 if ttl != None:
166 self.ttl = ttl
167 else:
168 self.ttl = 0
169 if vpn != None:
170 self.vpn = vpn
171 else:
172 self.vpn = 0
173 if if_name != None:
174 self.if_name = if_name
175 else:
176 self.if_name = ""
177 return
178
179 def pack(self):
180 packed = []
181 packed.append(struct.pack("!H", self.type))
182 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
183 packed.append(struct.pack("!L", self.flags))
184 packed.append(util.pack_port_no(self.port_no))
185 packed.append(struct.pack("!6B", *self.local_mac))
186 packed.append(struct.pack("!6B", *self.nh_mac))
187 packed.append(struct.pack("!L", self.src_ip))
188 packed.append(struct.pack("!L", self.dst_ip))
189 packed.append(struct.pack("!B", self.dscp))
190 packed.append(struct.pack("!B", self.ttl))
191 packed.append('\x00' * 2)
192 packed.append(struct.pack("!L", self.vpn))
193 packed.append(struct.pack("!16s", self.if_name))
194 length = sum([len(x) for x in packed])
195 packed[1] = struct.pack("!H", length)
196 return ''.join(packed)
197
198 @staticmethod
199 def unpack(reader):
200 obj = bsn_vport_l2gre()
201 _type = reader.read("!H")[0]
202 assert(_type == 1)
203 _length = reader.read("!H")[0]
204 orig_reader = reader
205 reader = orig_reader.slice(_length - (2 + 2))
206 obj.flags = reader.read("!L")[0]
207 obj.port_no = util.unpack_port_no(reader)
208 obj.local_mac = list(reader.read('!6B'))
209 obj.nh_mac = list(reader.read('!6B'))
210 obj.src_ip = reader.read("!L")[0]
211 obj.dst_ip = reader.read("!L")[0]
212 obj.dscp = reader.read("!B")[0]
213 obj.ttl = reader.read("!B")[0]
214 reader.skip(2)
215 obj.vpn = reader.read("!L")[0]
216 obj.if_name = reader.read("!16s")[0].rstrip("\x00")
217 return obj
218
219 def __eq__(self, other):
220 if type(self) != type(other): return False
221 if self.flags != other.flags: return False
222 if self.port_no != other.port_no: return False
223 if self.local_mac != other.local_mac: return False
224 if self.nh_mac != other.nh_mac: return False
225 if self.src_ip != other.src_ip: return False
226 if self.dst_ip != other.dst_ip: return False
227 if self.dscp != other.dscp: return False
228 if self.ttl != other.ttl: return False
229 if self.vpn != other.vpn: return False
230 if self.if_name != other.if_name: return False
231 return True
232
233 def pretty_print(self, q):
234 q.text("bsn_vport_l2gre {")
235 with q.group():
236 with q.indent(2):
237 q.breakable()
238 q.text("flags = ");
239 q.text("%#x" % self.flags)
240 q.text(","); q.breakable()
241 q.text("port_no = ");
242 q.text(util.pretty_port(self.port_no))
243 q.text(","); q.breakable()
244 q.text("local_mac = ");
245 q.text(util.pretty_mac(self.local_mac))
246 q.text(","); q.breakable()
247 q.text("nh_mac = ");
248 q.text(util.pretty_mac(self.nh_mac))
249 q.text(","); q.breakable()
250 q.text("src_ip = ");
251 q.text(util.pretty_ipv4(self.src_ip))
252 q.text(","); q.breakable()
253 q.text("dst_ip = ");
254 q.text(util.pretty_ipv4(self.dst_ip))
255 q.text(","); q.breakable()
256 q.text("dscp = ");
257 q.text("%#x" % self.dscp)
258 q.text(","); q.breakable()
259 q.text("ttl = ");
260 q.text("%#x" % self.ttl)
261 q.text(","); q.breakable()
262 q.text("vpn = ");
263 q.text("%#x" % self.vpn)
264 q.text(","); q.breakable()
265 q.text("if_name = ");
266 q.pp(self.if_name)
267 q.breakable()
268 q.text('}')
269
270bsn_vport.subtypes[1] = bsn_vport_l2gre
271
Rich Lane7dcdf022013-12-11 14:45:27 -0800272class bsn_vport_q_in_q(bsn_vport):
Dan Talaycof6202252013-07-02 01:00:29 -0700273 type = 0
274
Kiran Poola150d8b02013-09-20 13:30:39 -0700275 def __init__(self, port_no=None, ingress_tpid=None, ingress_vlan_id=None, egress_tpid=None, egress_vlan_id=None, if_name=None):
Dan Talaycof6202252013-07-02 01:00:29 -0700276 if port_no != None:
277 self.port_no = port_no
278 else:
279 self.port_no = 0
280 if ingress_tpid != None:
281 self.ingress_tpid = ingress_tpid
282 else:
283 self.ingress_tpid = 0
284 if ingress_vlan_id != None:
285 self.ingress_vlan_id = ingress_vlan_id
286 else:
287 self.ingress_vlan_id = 0
288 if egress_tpid != None:
289 self.egress_tpid = egress_tpid
290 else:
291 self.egress_tpid = 0
292 if egress_vlan_id != None:
293 self.egress_vlan_id = egress_vlan_id
294 else:
295 self.egress_vlan_id = 0
Kiran Poola150d8b02013-09-20 13:30:39 -0700296 if if_name != None:
297 self.if_name = if_name
298 else:
299 self.if_name = ""
Dan Talaycof6202252013-07-02 01:00:29 -0700300 return
301
302 def pack(self):
303 packed = []
304 packed.append(struct.pack("!H", self.type))
Kiran Poola150d8b02013-09-20 13:30:39 -0700305 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700306 packed.append(struct.pack("!L", self.port_no))
307 packed.append(struct.pack("!H", self.ingress_tpid))
308 packed.append(struct.pack("!H", self.ingress_vlan_id))
309 packed.append(struct.pack("!H", self.egress_tpid))
310 packed.append(struct.pack("!H", self.egress_vlan_id))
Kiran Poola150d8b02013-09-20 13:30:39 -0700311 packed.append(struct.pack("!16s", self.if_name))
Dan Talaycof6202252013-07-02 01:00:29 -0700312 length = sum([len(x) for x in packed])
Kiran Poola150d8b02013-09-20 13:30:39 -0700313 packed[1] = struct.pack("!H", length)
Dan Talaycof6202252013-07-02 01:00:29 -0700314 return ''.join(packed)
315
316 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800317 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -0700318 obj = bsn_vport_q_in_q()
Dan Talaycof6202252013-07-02 01:00:29 -0700319 _type = reader.read("!H")[0]
320 assert(_type == 0)
321 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800322 orig_reader = reader
323 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700324 obj.port_no = reader.read("!L")[0]
325 obj.ingress_tpid = reader.read("!H")[0]
326 obj.ingress_vlan_id = reader.read("!H")[0]
327 obj.egress_tpid = reader.read("!H")[0]
328 obj.egress_vlan_id = reader.read("!H")[0]
Kiran Poola150d8b02013-09-20 13:30:39 -0700329 obj.if_name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -0700330 return obj
331
332 def __eq__(self, other):
333 if type(self) != type(other): return False
334 if self.port_no != other.port_no: return False
335 if self.ingress_tpid != other.ingress_tpid: return False
336 if self.ingress_vlan_id != other.ingress_vlan_id: return False
337 if self.egress_tpid != other.egress_tpid: return False
338 if self.egress_vlan_id != other.egress_vlan_id: return False
Kiran Poola150d8b02013-09-20 13:30:39 -0700339 if self.if_name != other.if_name: return False
Dan Talaycof6202252013-07-02 01:00:29 -0700340 return True
341
Dan Talaycof6202252013-07-02 01:00:29 -0700342 def pretty_print(self, q):
343 q.text("bsn_vport_q_in_q {")
344 with q.group():
345 with q.indent(2):
346 q.breakable()
347 q.text("port_no = ");
348 q.text("%#x" % self.port_no)
349 q.text(","); q.breakable()
350 q.text("ingress_tpid = ");
351 q.text("%#x" % self.ingress_tpid)
352 q.text(","); q.breakable()
353 q.text("ingress_vlan_id = ");
354 q.text("%#x" % self.ingress_vlan_id)
355 q.text(","); q.breakable()
356 q.text("egress_tpid = ");
357 q.text("%#x" % self.egress_tpid)
358 q.text(","); q.breakable()
359 q.text("egress_vlan_id = ");
360 q.text("%#x" % self.egress_vlan_id)
Kiran Poola150d8b02013-09-20 13:30:39 -0700361 q.text(","); q.breakable()
362 q.text("if_name = ");
363 q.pp(self.if_name)
Dan Talaycof6202252013-07-02 01:00:29 -0700364 q.breakable()
365 q.text('}')
366
Rich Lane7dcdf022013-12-11 14:45:27 -0800367bsn_vport.subtypes[0] = bsn_vport_q_in_q
368
369class bucket(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700370
371 def __init__(self, weight=None, watch_port=None, watch_group=None, actions=None):
372 if weight != None:
373 self.weight = weight
374 else:
375 self.weight = 0
376 if watch_port != None:
377 self.watch_port = watch_port
378 else:
379 self.watch_port = 0
380 if watch_group != None:
381 self.watch_group = watch_group
382 else:
383 self.watch_group = 0
384 if actions != None:
385 self.actions = actions
386 else:
387 self.actions = []
388 return
389
390 def pack(self):
391 packed = []
392 packed.append(struct.pack("!H", 0)) # placeholder for len at index 0
393 packed.append(struct.pack("!H", self.weight))
Dan Talaycof6202252013-07-02 01:00:29 -0700394 packed.append(util.pack_port_no(self.watch_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700395 packed.append(struct.pack("!L", self.watch_group))
396 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -0800397 packed.append(loxi.generic_util.pack_list(self.actions))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700398 length = sum([len(x) for x in packed])
399 packed[0] = struct.pack("!H", length)
400 return ''.join(packed)
401
402 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800403 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700404 obj = bucket()
Dan Talaycof6202252013-07-02 01:00:29 -0700405 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800406 orig_reader = reader
407 reader = orig_reader.slice(_len - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700408 obj.weight = reader.read("!H")[0]
409 obj.watch_port = util.unpack_port_no(reader)
410 obj.watch_group = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700411 reader.skip(4)
Rich Lane7dcdf022013-12-11 14:45:27 -0800412 obj.actions = loxi.generic_util.unpack_list(reader, action.action.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700413 return obj
414
415 def __eq__(self, other):
416 if type(self) != type(other): return False
417 if self.weight != other.weight: return False
418 if self.watch_port != other.watch_port: return False
419 if self.watch_group != other.watch_group: return False
420 if self.actions != other.actions: return False
421 return True
422
Rich Lanec2ee4b82013-04-24 17:12:38 -0700423 def pretty_print(self, q):
424 q.text("bucket {")
425 with q.group():
426 with q.indent(2):
427 q.breakable()
428 q.text("weight = ");
429 q.text("%#x" % self.weight)
430 q.text(","); q.breakable()
431 q.text("watch_port = ");
432 q.text(util.pretty_port(self.watch_port))
433 q.text(","); q.breakable()
434 q.text("watch_group = ");
435 q.text("%#x" % self.watch_group)
436 q.text(","); q.breakable()
437 q.text("actions = ");
438 q.pp(self.actions)
439 q.breakable()
440 q.text('}')
441
Rich Lane7dcdf022013-12-11 14:45:27 -0800442
443class bucket_counter(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700444
445 def __init__(self, packet_count=None, byte_count=None):
446 if packet_count != None:
447 self.packet_count = packet_count
448 else:
449 self.packet_count = 0
450 if byte_count != None:
451 self.byte_count = byte_count
452 else:
453 self.byte_count = 0
454 return
455
456 def pack(self):
457 packed = []
458 packed.append(struct.pack("!Q", self.packet_count))
459 packed.append(struct.pack("!Q", self.byte_count))
460 return ''.join(packed)
461
462 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800463 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700464 obj = bucket_counter()
Dan Talaycof6202252013-07-02 01:00:29 -0700465 obj.packet_count = reader.read("!Q")[0]
466 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700467 return obj
468
469 def __eq__(self, other):
470 if type(self) != type(other): return False
471 if self.packet_count != other.packet_count: return False
472 if self.byte_count != other.byte_count: return False
473 return True
474
Rich Lanec2ee4b82013-04-24 17:12:38 -0700475 def pretty_print(self, q):
476 q.text("bucket_counter {")
477 with q.group():
478 with q.indent(2):
479 q.breakable()
480 q.text("packet_count = ");
481 q.text("%#x" % self.packet_count)
482 q.text(","); q.breakable()
483 q.text("byte_count = ");
484 q.text("%#x" % self.byte_count)
485 q.breakable()
486 q.text('}')
487
Rich Lane7dcdf022013-12-11 14:45:27 -0800488
489class flow_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700490
491 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):
492 if table_id != None:
493 self.table_id = table_id
494 else:
495 self.table_id = 0
496 if duration_sec != None:
497 self.duration_sec = duration_sec
498 else:
499 self.duration_sec = 0
500 if duration_nsec != None:
501 self.duration_nsec = duration_nsec
502 else:
503 self.duration_nsec = 0
504 if priority != None:
505 self.priority = priority
506 else:
507 self.priority = 0
508 if idle_timeout != None:
509 self.idle_timeout = idle_timeout
510 else:
511 self.idle_timeout = 0
512 if hard_timeout != None:
513 self.hard_timeout = hard_timeout
514 else:
515 self.hard_timeout = 0
516 if cookie != None:
517 self.cookie = cookie
518 else:
519 self.cookie = 0
520 if packet_count != None:
521 self.packet_count = packet_count
522 else:
523 self.packet_count = 0
524 if byte_count != None:
525 self.byte_count = byte_count
526 else:
527 self.byte_count = 0
528 if match != None:
529 self.match = match
530 else:
531 self.match = common.match()
532 if instructions != None:
533 self.instructions = instructions
534 else:
535 self.instructions = []
536 return
537
538 def pack(self):
539 packed = []
540 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
541 packed.append(struct.pack("!B", self.table_id))
542 packed.append('\x00' * 1)
543 packed.append(struct.pack("!L", self.duration_sec))
544 packed.append(struct.pack("!L", self.duration_nsec))
545 packed.append(struct.pack("!H", self.priority))
546 packed.append(struct.pack("!H", self.idle_timeout))
547 packed.append(struct.pack("!H", self.hard_timeout))
548 packed.append('\x00' * 6)
549 packed.append(struct.pack("!Q", self.cookie))
550 packed.append(struct.pack("!Q", self.packet_count))
551 packed.append(struct.pack("!Q", self.byte_count))
552 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -0800553 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700554 length = sum([len(x) for x in packed])
555 packed[0] = struct.pack("!H", length)
556 return ''.join(packed)
557
558 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800559 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700560 obj = flow_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -0700561 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800562 orig_reader = reader
563 reader = orig_reader.slice(_length - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700564 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700565 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -0700566 obj.duration_sec = reader.read("!L")[0]
567 obj.duration_nsec = reader.read("!L")[0]
568 obj.priority = reader.read("!H")[0]
569 obj.idle_timeout = reader.read("!H")[0]
570 obj.hard_timeout = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700571 reader.skip(6)
Dan Talaycof6202252013-07-02 01:00:29 -0700572 obj.cookie = reader.read("!Q")[0]
573 obj.packet_count = reader.read("!Q")[0]
574 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700575 obj.match = common.match.unpack(reader)
Rich Lane7dcdf022013-12-11 14:45:27 -0800576 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700577 return obj
578
579 def __eq__(self, other):
580 if type(self) != type(other): return False
581 if self.table_id != other.table_id: return False
582 if self.duration_sec != other.duration_sec: return False
583 if self.duration_nsec != other.duration_nsec: return False
584 if self.priority != other.priority: return False
585 if self.idle_timeout != other.idle_timeout: return False
586 if self.hard_timeout != other.hard_timeout: return False
587 if self.cookie != other.cookie: return False
588 if self.packet_count != other.packet_count: return False
589 if self.byte_count != other.byte_count: return False
590 if self.match != other.match: return False
591 if self.instructions != other.instructions: return False
592 return True
593
Rich Lanec2ee4b82013-04-24 17:12:38 -0700594 def pretty_print(self, q):
595 q.text("flow_stats_entry {")
596 with q.group():
597 with q.indent(2):
598 q.breakable()
599 q.text("table_id = ");
600 q.text("%#x" % self.table_id)
601 q.text(","); q.breakable()
602 q.text("duration_sec = ");
603 q.text("%#x" % self.duration_sec)
604 q.text(","); q.breakable()
605 q.text("duration_nsec = ");
606 q.text("%#x" % self.duration_nsec)
607 q.text(","); q.breakable()
608 q.text("priority = ");
609 q.text("%#x" % self.priority)
610 q.text(","); q.breakable()
611 q.text("idle_timeout = ");
612 q.text("%#x" % self.idle_timeout)
613 q.text(","); q.breakable()
614 q.text("hard_timeout = ");
615 q.text("%#x" % self.hard_timeout)
616 q.text(","); q.breakable()
617 q.text("cookie = ");
618 q.text("%#x" % self.cookie)
619 q.text(","); q.breakable()
620 q.text("packet_count = ");
621 q.text("%#x" % self.packet_count)
622 q.text(","); q.breakable()
623 q.text("byte_count = ");
624 q.text("%#x" % self.byte_count)
625 q.text(","); q.breakable()
626 q.text("match = ");
627 q.pp(self.match)
628 q.text(","); q.breakable()
629 q.text("instructions = ");
630 q.pp(self.instructions)
631 q.breakable()
632 q.text('}')
633
Rich Lane7dcdf022013-12-11 14:45:27 -0800634
635class group_desc_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700636
Rich Lane6f4978c2013-10-20 21:33:52 -0700637 def __init__(self, group_type=None, group_id=None, buckets=None):
638 if group_type != None:
639 self.group_type = group_type
Rich Lanec2ee4b82013-04-24 17:12:38 -0700640 else:
Rich Lane6f4978c2013-10-20 21:33:52 -0700641 self.group_type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700642 if group_id != None:
643 self.group_id = group_id
644 else:
645 self.group_id = 0
646 if buckets != None:
647 self.buckets = buckets
648 else:
649 self.buckets = []
650 return
651
652 def pack(self):
653 packed = []
654 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
Rich Lane6f4978c2013-10-20 21:33:52 -0700655 packed.append(struct.pack("!B", self.group_type))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700656 packed.append('\x00' * 1)
657 packed.append(struct.pack("!L", self.group_id))
Rich Lane7dcdf022013-12-11 14:45:27 -0800658 packed.append(loxi.generic_util.pack_list(self.buckets))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700659 length = sum([len(x) for x in packed])
660 packed[0] = struct.pack("!H", length)
661 return ''.join(packed)
662
663 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800664 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700665 obj = group_desc_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -0700666 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800667 orig_reader = reader
668 reader = orig_reader.slice(_length - (0 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -0700669 obj.group_type = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700670 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -0700671 obj.group_id = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800672 obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700673 return obj
674
675 def __eq__(self, other):
676 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -0700677 if self.group_type != other.group_type: return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700678 if self.group_id != other.group_id: return False
679 if self.buckets != other.buckets: return False
680 return True
681
Rich Lanec2ee4b82013-04-24 17:12:38 -0700682 def pretty_print(self, q):
683 q.text("group_desc_stats_entry {")
684 with q.group():
685 with q.indent(2):
686 q.breakable()
Rich Lane6f4978c2013-10-20 21:33:52 -0700687 q.text("group_type = ");
688 q.text("%#x" % self.group_type)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700689 q.text(","); q.breakable()
690 q.text("group_id = ");
691 q.text("%#x" % self.group_id)
692 q.text(","); q.breakable()
693 q.text("buckets = ");
694 q.pp(self.buckets)
695 q.breakable()
696 q.text('}')
697
Rich Lane7dcdf022013-12-11 14:45:27 -0800698
699class group_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700700
701 def __init__(self, group_id=None, ref_count=None, packet_count=None, byte_count=None, bucket_stats=None):
702 if group_id != None:
703 self.group_id = group_id
704 else:
705 self.group_id = 0
706 if ref_count != None:
707 self.ref_count = ref_count
708 else:
709 self.ref_count = 0
710 if packet_count != None:
711 self.packet_count = packet_count
712 else:
713 self.packet_count = 0
714 if byte_count != None:
715 self.byte_count = byte_count
716 else:
717 self.byte_count = 0
718 if bucket_stats != None:
719 self.bucket_stats = bucket_stats
720 else:
721 self.bucket_stats = []
722 return
723
724 def pack(self):
725 packed = []
726 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
727 packed.append('\x00' * 2)
728 packed.append(struct.pack("!L", self.group_id))
729 packed.append(struct.pack("!L", self.ref_count))
730 packed.append('\x00' * 4)
731 packed.append(struct.pack("!Q", self.packet_count))
732 packed.append(struct.pack("!Q", self.byte_count))
Rich Lane7dcdf022013-12-11 14:45:27 -0800733 packed.append(loxi.generic_util.pack_list(self.bucket_stats))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700734 length = sum([len(x) for x in packed])
735 packed[0] = struct.pack("!H", length)
736 return ''.join(packed)
737
738 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800739 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700740 obj = group_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -0700741 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800742 orig_reader = reader
743 reader = orig_reader.slice(_length - (0 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700744 reader.skip(2)
Dan Talaycof6202252013-07-02 01:00:29 -0700745 obj.group_id = reader.read("!L")[0]
746 obj.ref_count = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700747 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -0700748 obj.packet_count = reader.read("!Q")[0]
749 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700750 obj.bucket_stats = loxi.generic_util.unpack_list(reader, common.bucket_counter.unpack)
751 return obj
752
753 def __eq__(self, other):
754 if type(self) != type(other): return False
755 if self.group_id != other.group_id: return False
756 if self.ref_count != other.ref_count: return False
757 if self.packet_count != other.packet_count: return False
758 if self.byte_count != other.byte_count: return False
759 if self.bucket_stats != other.bucket_stats: return False
760 return True
761
Rich Lanec2ee4b82013-04-24 17:12:38 -0700762 def pretty_print(self, q):
763 q.text("group_stats_entry {")
764 with q.group():
765 with q.indent(2):
766 q.breakable()
767 q.text("group_id = ");
768 q.text("%#x" % self.group_id)
769 q.text(","); q.breakable()
770 q.text("ref_count = ");
771 q.text("%#x" % self.ref_count)
772 q.text(","); q.breakable()
773 q.text("packet_count = ");
774 q.text("%#x" % self.packet_count)
775 q.text(","); q.breakable()
776 q.text("byte_count = ");
777 q.text("%#x" % self.byte_count)
778 q.text(","); q.breakable()
779 q.text("bucket_stats = ");
780 q.pp(self.bucket_stats)
781 q.breakable()
782 q.text('}')
783
Rich Lane7dcdf022013-12-11 14:45:27 -0800784
785class match_v2(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700786 type = 0
787
788 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):
789 if in_port != None:
790 self.in_port = in_port
791 else:
792 self.in_port = 0
793 if wildcards != None:
794 self.wildcards = wildcards
795 else:
Dan Talaycof6202252013-07-02 01:00:29 -0700796 self.wildcards = util.init_wc_bmap()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700797 if eth_src != None:
798 self.eth_src = eth_src
799 else:
800 self.eth_src = [0,0,0,0,0,0]
801 if eth_src_mask != None:
802 self.eth_src_mask = eth_src_mask
803 else:
804 self.eth_src_mask = [0,0,0,0,0,0]
805 if eth_dst != None:
806 self.eth_dst = eth_dst
807 else:
808 self.eth_dst = [0,0,0,0,0,0]
809 if eth_dst_mask != None:
810 self.eth_dst_mask = eth_dst_mask
811 else:
812 self.eth_dst_mask = [0,0,0,0,0,0]
813 if vlan_vid != None:
814 self.vlan_vid = vlan_vid
815 else:
816 self.vlan_vid = 0
817 if vlan_pcp != None:
818 self.vlan_pcp = vlan_pcp
819 else:
820 self.vlan_pcp = 0
821 if eth_type != None:
822 self.eth_type = eth_type
823 else:
824 self.eth_type = 0
825 if ip_dscp != None:
826 self.ip_dscp = ip_dscp
827 else:
828 self.ip_dscp = 0
829 if ip_proto != None:
830 self.ip_proto = ip_proto
831 else:
832 self.ip_proto = 0
833 if ipv4_src != None:
834 self.ipv4_src = ipv4_src
835 else:
836 self.ipv4_src = 0
837 if ipv4_src_mask != None:
838 self.ipv4_src_mask = ipv4_src_mask
839 else:
840 self.ipv4_src_mask = 0
841 if ipv4_dst != None:
842 self.ipv4_dst = ipv4_dst
843 else:
844 self.ipv4_dst = 0
845 if ipv4_dst_mask != None:
846 self.ipv4_dst_mask = ipv4_dst_mask
847 else:
848 self.ipv4_dst_mask = 0
849 if tcp_src != None:
850 self.tcp_src = tcp_src
851 else:
852 self.tcp_src = 0
853 if tcp_dst != None:
854 self.tcp_dst = tcp_dst
855 else:
856 self.tcp_dst = 0
857 if mpls_label != None:
858 self.mpls_label = mpls_label
859 else:
860 self.mpls_label = 0
861 if mpls_tc != None:
862 self.mpls_tc = mpls_tc
863 else:
864 self.mpls_tc = 0
865 if metadata != None:
866 self.metadata = metadata
867 else:
868 self.metadata = 0
869 if metadata_mask != None:
870 self.metadata_mask = metadata_mask
871 else:
872 self.metadata_mask = 0
873 return
874
875 def pack(self):
876 packed = []
877 packed.append(struct.pack("!H", self.type))
878 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700879 packed.append(util.pack_port_no(self.in_port))
880 packed.append(util.pack_wc_bmap(self.wildcards))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700881 packed.append(struct.pack("!6B", *self.eth_src))
882 packed.append(struct.pack("!6B", *self.eth_src_mask))
883 packed.append(struct.pack("!6B", *self.eth_dst))
884 packed.append(struct.pack("!6B", *self.eth_dst_mask))
885 packed.append(struct.pack("!H", self.vlan_vid))
886 packed.append(struct.pack("!B", self.vlan_pcp))
887 packed.append('\x00' * 1)
888 packed.append(struct.pack("!H", self.eth_type))
889 packed.append(struct.pack("!B", self.ip_dscp))
890 packed.append(struct.pack("!B", self.ip_proto))
891 packed.append(struct.pack("!L", self.ipv4_src))
892 packed.append(struct.pack("!L", self.ipv4_src_mask))
893 packed.append(struct.pack("!L", self.ipv4_dst))
894 packed.append(struct.pack("!L", self.ipv4_dst_mask))
895 packed.append(struct.pack("!H", self.tcp_src))
896 packed.append(struct.pack("!H", self.tcp_dst))
897 packed.append(struct.pack("!L", self.mpls_label))
898 packed.append(struct.pack("!B", self.mpls_tc))
899 packed.append('\x00' * 3)
900 packed.append(struct.pack("!Q", self.metadata))
901 packed.append(struct.pack("!Q", self.metadata_mask))
902 length = sum([len(x) for x in packed])
903 packed[1] = struct.pack("!H", length)
904 return ''.join(packed)
905
906 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800907 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700908 obj = match_v2()
Dan Talaycof6202252013-07-02 01:00:29 -0700909 _type = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700910 assert(_type == 0)
Dan Talaycof6202252013-07-02 01:00:29 -0700911 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800912 orig_reader = reader
913 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700914 obj.in_port = util.unpack_port_no(reader)
915 obj.wildcards = util.unpack_wc_bmap(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700916 obj.eth_src = list(reader.read('!6B'))
917 obj.eth_src_mask = list(reader.read('!6B'))
918 obj.eth_dst = list(reader.read('!6B'))
919 obj.eth_dst_mask = list(reader.read('!6B'))
Dan Talaycof6202252013-07-02 01:00:29 -0700920 obj.vlan_vid = reader.read("!H")[0]
921 obj.vlan_pcp = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700922 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -0700923 obj.eth_type = reader.read("!H")[0]
924 obj.ip_dscp = reader.read("!B")[0]
925 obj.ip_proto = reader.read("!B")[0]
926 obj.ipv4_src = reader.read("!L")[0]
927 obj.ipv4_src_mask = reader.read("!L")[0]
928 obj.ipv4_dst = reader.read("!L")[0]
929 obj.ipv4_dst_mask = reader.read("!L")[0]
930 obj.tcp_src = reader.read("!H")[0]
931 obj.tcp_dst = reader.read("!H")[0]
932 obj.mpls_label = reader.read("!L")[0]
933 obj.mpls_tc = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700934 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -0700935 obj.metadata = reader.read("!Q")[0]
936 obj.metadata_mask = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700937 return obj
938
939 def __eq__(self, other):
940 if type(self) != type(other): return False
941 if self.in_port != other.in_port: return False
942 if self.wildcards != other.wildcards: return False
943 if self.eth_src != other.eth_src: return False
944 if self.eth_src_mask != other.eth_src_mask: return False
945 if self.eth_dst != other.eth_dst: return False
946 if self.eth_dst_mask != other.eth_dst_mask: return False
947 if self.vlan_vid != other.vlan_vid: return False
948 if self.vlan_pcp != other.vlan_pcp: return False
949 if self.eth_type != other.eth_type: return False
950 if self.ip_dscp != other.ip_dscp: return False
951 if self.ip_proto != other.ip_proto: return False
952 if self.ipv4_src != other.ipv4_src: return False
953 if self.ipv4_src_mask != other.ipv4_src_mask: return False
954 if self.ipv4_dst != other.ipv4_dst: return False
955 if self.ipv4_dst_mask != other.ipv4_dst_mask: return False
956 if self.tcp_src != other.tcp_src: return False
957 if self.tcp_dst != other.tcp_dst: return False
958 if self.mpls_label != other.mpls_label: return False
959 if self.mpls_tc != other.mpls_tc: return False
960 if self.metadata != other.metadata: return False
961 if self.metadata_mask != other.metadata_mask: return False
962 return True
963
Rich Lanec2ee4b82013-04-24 17:12:38 -0700964 def pretty_print(self, q):
965 q.text("match_v2 {")
966 with q.group():
967 with q.indent(2):
968 q.breakable()
969 q.text("in_port = ");
970 q.text(util.pretty_port(self.in_port))
971 q.text(","); q.breakable()
972 q.text("wildcards = ");
973 q.text(util.pretty_wildcards(self.wildcards))
974 q.text(","); q.breakable()
975 q.text("eth_src = ");
976 q.text(util.pretty_mac(self.eth_src))
977 q.text(","); q.breakable()
978 q.text("eth_src_mask = ");
979 q.text(util.pretty_mac(self.eth_src_mask))
980 q.text(","); q.breakable()
981 q.text("eth_dst = ");
982 q.text(util.pretty_mac(self.eth_dst))
983 q.text(","); q.breakable()
984 q.text("eth_dst_mask = ");
985 q.text(util.pretty_mac(self.eth_dst_mask))
986 q.text(","); q.breakable()
987 q.text("vlan_vid = ");
988 q.text("%#x" % self.vlan_vid)
989 q.text(","); q.breakable()
990 q.text("vlan_pcp = ");
991 q.text("%#x" % self.vlan_pcp)
992 q.text(","); q.breakable()
993 q.text("eth_type = ");
994 q.text("%#x" % self.eth_type)
995 q.text(","); q.breakable()
996 q.text("ip_dscp = ");
997 q.text("%#x" % self.ip_dscp)
998 q.text(","); q.breakable()
999 q.text("ip_proto = ");
1000 q.text("%#x" % self.ip_proto)
1001 q.text(","); q.breakable()
1002 q.text("ipv4_src = ");
1003 q.text(util.pretty_ipv4(self.ipv4_src))
1004 q.text(","); q.breakable()
1005 q.text("ipv4_src_mask = ");
1006 q.text(util.pretty_ipv4(self.ipv4_src_mask))
1007 q.text(","); q.breakable()
1008 q.text("ipv4_dst = ");
1009 q.text(util.pretty_ipv4(self.ipv4_dst))
1010 q.text(","); q.breakable()
1011 q.text("ipv4_dst_mask = ");
1012 q.text(util.pretty_ipv4(self.ipv4_dst_mask))
1013 q.text(","); q.breakable()
1014 q.text("tcp_src = ");
1015 q.text("%#x" % self.tcp_src)
1016 q.text(","); q.breakable()
1017 q.text("tcp_dst = ");
1018 q.text("%#x" % self.tcp_dst)
1019 q.text(","); q.breakable()
1020 q.text("mpls_label = ");
1021 q.text("%#x" % self.mpls_label)
1022 q.text(","); q.breakable()
1023 q.text("mpls_tc = ");
1024 q.text("%#x" % self.mpls_tc)
1025 q.text(","); q.breakable()
1026 q.text("metadata = ");
1027 q.text("%#x" % self.metadata)
1028 q.text(","); q.breakable()
1029 q.text("metadata_mask = ");
1030 q.text("%#x" % self.metadata_mask)
1031 q.breakable()
1032 q.text('}')
1033
Rich Lane7dcdf022013-12-11 14:45:27 -08001034
1035class packet_queue(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001036
1037 def __init__(self, queue_id=None, properties=None):
1038 if queue_id != None:
1039 self.queue_id = queue_id
1040 else:
1041 self.queue_id = 0
1042 if properties != None:
1043 self.properties = properties
1044 else:
1045 self.properties = []
1046 return
1047
1048 def pack(self):
1049 packed = []
1050 packed.append(struct.pack("!L", self.queue_id))
1051 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1052 packed.append('\x00' * 2)
Rich Lane7dcdf022013-12-11 14:45:27 -08001053 packed.append(loxi.generic_util.pack_list(self.properties))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001054 length = sum([len(x) for x in packed])
1055 packed[1] = struct.pack("!H", length)
1056 return ''.join(packed)
1057
1058 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001059 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001060 obj = packet_queue()
Dan Talaycof6202252013-07-02 01:00:29 -07001061 obj.queue_id = reader.read("!L")[0]
1062 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001063 orig_reader = reader
1064 reader = orig_reader.slice(_len - (4 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001065 reader.skip(2)
Rich Lane7dcdf022013-12-11 14:45:27 -08001066 obj.properties = loxi.generic_util.unpack_list(reader, common.queue_prop.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001067 return obj
1068
1069 def __eq__(self, other):
1070 if type(self) != type(other): return False
1071 if self.queue_id != other.queue_id: return False
1072 if self.properties != other.properties: return False
1073 return True
1074
Rich Lanec2ee4b82013-04-24 17:12:38 -07001075 def pretty_print(self, q):
1076 q.text("packet_queue {")
1077 with q.group():
1078 with q.indent(2):
1079 q.breakable()
1080 q.text("queue_id = ");
1081 q.text("%#x" % self.queue_id)
1082 q.text(","); q.breakable()
1083 q.text("properties = ");
1084 q.pp(self.properties)
1085 q.breakable()
1086 q.text('}')
1087
Rich Lane7dcdf022013-12-11 14:45:27 -08001088
1089class port_desc(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001090
1091 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):
1092 if port_no != None:
1093 self.port_no = port_no
1094 else:
1095 self.port_no = 0
1096 if hw_addr != None:
1097 self.hw_addr = hw_addr
1098 else:
1099 self.hw_addr = [0,0,0,0,0,0]
1100 if name != None:
1101 self.name = name
1102 else:
1103 self.name = ""
1104 if config != None:
1105 self.config = config
1106 else:
1107 self.config = 0
1108 if state != None:
1109 self.state = state
1110 else:
1111 self.state = 0
1112 if curr != None:
1113 self.curr = curr
1114 else:
1115 self.curr = 0
1116 if advertised != None:
1117 self.advertised = advertised
1118 else:
1119 self.advertised = 0
1120 if supported != None:
1121 self.supported = supported
1122 else:
1123 self.supported = 0
1124 if peer != None:
1125 self.peer = peer
1126 else:
1127 self.peer = 0
1128 if curr_speed != None:
1129 self.curr_speed = curr_speed
1130 else:
1131 self.curr_speed = 0
1132 if max_speed != None:
1133 self.max_speed = max_speed
1134 else:
1135 self.max_speed = 0
1136 return
1137
1138 def pack(self):
1139 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07001140 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001141 packed.append('\x00' * 4)
1142 packed.append(struct.pack("!6B", *self.hw_addr))
1143 packed.append('\x00' * 2)
1144 packed.append(struct.pack("!16s", self.name))
1145 packed.append(struct.pack("!L", self.config))
1146 packed.append(struct.pack("!L", self.state))
1147 packed.append(struct.pack("!L", self.curr))
1148 packed.append(struct.pack("!L", self.advertised))
1149 packed.append(struct.pack("!L", self.supported))
1150 packed.append(struct.pack("!L", self.peer))
1151 packed.append(struct.pack("!L", self.curr_speed))
1152 packed.append(struct.pack("!L", self.max_speed))
1153 return ''.join(packed)
1154
1155 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001156 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001157 obj = port_desc()
Dan Talaycof6202252013-07-02 01:00:29 -07001158 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001159 reader.skip(4)
1160 obj.hw_addr = list(reader.read('!6B'))
1161 reader.skip(2)
1162 obj.name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -07001163 obj.config = reader.read("!L")[0]
1164 obj.state = reader.read("!L")[0]
1165 obj.curr = reader.read("!L")[0]
1166 obj.advertised = reader.read("!L")[0]
1167 obj.supported = reader.read("!L")[0]
1168 obj.peer = reader.read("!L")[0]
1169 obj.curr_speed = reader.read("!L")[0]
1170 obj.max_speed = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001171 return obj
1172
1173 def __eq__(self, other):
1174 if type(self) != type(other): return False
1175 if self.port_no != other.port_no: return False
1176 if self.hw_addr != other.hw_addr: return False
1177 if self.name != other.name: return False
1178 if self.config != other.config: return False
1179 if self.state != other.state: return False
1180 if self.curr != other.curr: return False
1181 if self.advertised != other.advertised: return False
1182 if self.supported != other.supported: return False
1183 if self.peer != other.peer: return False
1184 if self.curr_speed != other.curr_speed: return False
1185 if self.max_speed != other.max_speed: return False
1186 return True
1187
Rich Lanec2ee4b82013-04-24 17:12:38 -07001188 def pretty_print(self, q):
1189 q.text("port_desc {")
1190 with q.group():
1191 with q.indent(2):
1192 q.breakable()
1193 q.text("port_no = ");
1194 q.text(util.pretty_port(self.port_no))
1195 q.text(","); q.breakable()
1196 q.text("hw_addr = ");
1197 q.text(util.pretty_mac(self.hw_addr))
1198 q.text(","); q.breakable()
1199 q.text("name = ");
1200 q.pp(self.name)
1201 q.text(","); q.breakable()
1202 q.text("config = ");
1203 q.text("%#x" % self.config)
1204 q.text(","); q.breakable()
1205 q.text("state = ");
1206 q.text("%#x" % self.state)
1207 q.text(","); q.breakable()
1208 q.text("curr = ");
1209 q.text("%#x" % self.curr)
1210 q.text(","); q.breakable()
1211 q.text("advertised = ");
1212 q.text("%#x" % self.advertised)
1213 q.text(","); q.breakable()
1214 q.text("supported = ");
1215 q.text("%#x" % self.supported)
1216 q.text(","); q.breakable()
1217 q.text("peer = ");
1218 q.text("%#x" % self.peer)
1219 q.text(","); q.breakable()
1220 q.text("curr_speed = ");
1221 q.text("%#x" % self.curr_speed)
1222 q.text(","); q.breakable()
1223 q.text("max_speed = ");
1224 q.text("%#x" % self.max_speed)
1225 q.breakable()
1226 q.text('}')
1227
Rich Lane7dcdf022013-12-11 14:45:27 -08001228
1229class port_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001230
1231 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):
1232 if port_no != None:
1233 self.port_no = port_no
1234 else:
1235 self.port_no = 0
1236 if rx_packets != None:
1237 self.rx_packets = rx_packets
1238 else:
1239 self.rx_packets = 0
1240 if tx_packets != None:
1241 self.tx_packets = tx_packets
1242 else:
1243 self.tx_packets = 0
1244 if rx_bytes != None:
1245 self.rx_bytes = rx_bytes
1246 else:
1247 self.rx_bytes = 0
1248 if tx_bytes != None:
1249 self.tx_bytes = tx_bytes
1250 else:
1251 self.tx_bytes = 0
1252 if rx_dropped != None:
1253 self.rx_dropped = rx_dropped
1254 else:
1255 self.rx_dropped = 0
1256 if tx_dropped != None:
1257 self.tx_dropped = tx_dropped
1258 else:
1259 self.tx_dropped = 0
1260 if rx_errors != None:
1261 self.rx_errors = rx_errors
1262 else:
1263 self.rx_errors = 0
1264 if tx_errors != None:
1265 self.tx_errors = tx_errors
1266 else:
1267 self.tx_errors = 0
1268 if rx_frame_err != None:
1269 self.rx_frame_err = rx_frame_err
1270 else:
1271 self.rx_frame_err = 0
1272 if rx_over_err != None:
1273 self.rx_over_err = rx_over_err
1274 else:
1275 self.rx_over_err = 0
1276 if rx_crc_err != None:
1277 self.rx_crc_err = rx_crc_err
1278 else:
1279 self.rx_crc_err = 0
1280 if collisions != None:
1281 self.collisions = collisions
1282 else:
1283 self.collisions = 0
1284 return
1285
1286 def pack(self):
1287 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07001288 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001289 packed.append('\x00' * 4)
1290 packed.append(struct.pack("!Q", self.rx_packets))
1291 packed.append(struct.pack("!Q", self.tx_packets))
1292 packed.append(struct.pack("!Q", self.rx_bytes))
1293 packed.append(struct.pack("!Q", self.tx_bytes))
1294 packed.append(struct.pack("!Q", self.rx_dropped))
1295 packed.append(struct.pack("!Q", self.tx_dropped))
1296 packed.append(struct.pack("!Q", self.rx_errors))
1297 packed.append(struct.pack("!Q", self.tx_errors))
1298 packed.append(struct.pack("!Q", self.rx_frame_err))
1299 packed.append(struct.pack("!Q", self.rx_over_err))
1300 packed.append(struct.pack("!Q", self.rx_crc_err))
1301 packed.append(struct.pack("!Q", self.collisions))
1302 return ''.join(packed)
1303
1304 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001305 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001306 obj = port_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001307 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001308 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001309 obj.rx_packets = reader.read("!Q")[0]
1310 obj.tx_packets = reader.read("!Q")[0]
1311 obj.rx_bytes = reader.read("!Q")[0]
1312 obj.tx_bytes = reader.read("!Q")[0]
1313 obj.rx_dropped = reader.read("!Q")[0]
1314 obj.tx_dropped = reader.read("!Q")[0]
1315 obj.rx_errors = reader.read("!Q")[0]
1316 obj.tx_errors = reader.read("!Q")[0]
1317 obj.rx_frame_err = reader.read("!Q")[0]
1318 obj.rx_over_err = reader.read("!Q")[0]
1319 obj.rx_crc_err = reader.read("!Q")[0]
1320 obj.collisions = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001321 return obj
1322
1323 def __eq__(self, other):
1324 if type(self) != type(other): return False
1325 if self.port_no != other.port_no: return False
1326 if self.rx_packets != other.rx_packets: return False
1327 if self.tx_packets != other.tx_packets: return False
1328 if self.rx_bytes != other.rx_bytes: return False
1329 if self.tx_bytes != other.tx_bytes: return False
1330 if self.rx_dropped != other.rx_dropped: return False
1331 if self.tx_dropped != other.tx_dropped: return False
1332 if self.rx_errors != other.rx_errors: return False
1333 if self.tx_errors != other.tx_errors: return False
1334 if self.rx_frame_err != other.rx_frame_err: return False
1335 if self.rx_over_err != other.rx_over_err: return False
1336 if self.rx_crc_err != other.rx_crc_err: return False
1337 if self.collisions != other.collisions: return False
1338 return True
1339
Rich Lanec2ee4b82013-04-24 17:12:38 -07001340 def pretty_print(self, q):
1341 q.text("port_stats_entry {")
1342 with q.group():
1343 with q.indent(2):
1344 q.breakable()
1345 q.text("port_no = ");
1346 q.text(util.pretty_port(self.port_no))
1347 q.text(","); q.breakable()
1348 q.text("rx_packets = ");
1349 q.text("%#x" % self.rx_packets)
1350 q.text(","); q.breakable()
1351 q.text("tx_packets = ");
1352 q.text("%#x" % self.tx_packets)
1353 q.text(","); q.breakable()
1354 q.text("rx_bytes = ");
1355 q.text("%#x" % self.rx_bytes)
1356 q.text(","); q.breakable()
1357 q.text("tx_bytes = ");
1358 q.text("%#x" % self.tx_bytes)
1359 q.text(","); q.breakable()
1360 q.text("rx_dropped = ");
1361 q.text("%#x" % self.rx_dropped)
1362 q.text(","); q.breakable()
1363 q.text("tx_dropped = ");
1364 q.text("%#x" % self.tx_dropped)
1365 q.text(","); q.breakable()
1366 q.text("rx_errors = ");
1367 q.text("%#x" % self.rx_errors)
1368 q.text(","); q.breakable()
1369 q.text("tx_errors = ");
1370 q.text("%#x" % self.tx_errors)
1371 q.text(","); q.breakable()
1372 q.text("rx_frame_err = ");
1373 q.text("%#x" % self.rx_frame_err)
1374 q.text(","); q.breakable()
1375 q.text("rx_over_err = ");
1376 q.text("%#x" % self.rx_over_err)
1377 q.text(","); q.breakable()
1378 q.text("rx_crc_err = ");
1379 q.text("%#x" % self.rx_crc_err)
1380 q.text(","); q.breakable()
1381 q.text("collisions = ");
1382 q.text("%#x" % self.collisions)
1383 q.breakable()
1384 q.text('}')
1385
Rich Lane7dcdf022013-12-11 14:45:27 -08001386
1387class queue_prop(loxi.OFObject):
1388 subtypes = {}
1389
Rich Lane95f7fc92014-01-27 17:08:16 -08001390
1391 def __init__(self, type=None):
1392 if type != None:
1393 self.type = type
1394 else:
1395 self.type = 0
1396 return
1397
1398 def pack(self):
1399 packed = []
1400 packed.append(struct.pack("!H", self.type))
1401 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1402 packed.append('\x00' * 4)
1403 length = sum([len(x) for x in packed])
1404 packed[1] = struct.pack("!H", length)
1405 return ''.join(packed)
1406
Rich Lane7dcdf022013-12-11 14:45:27 -08001407 @staticmethod
1408 def unpack(reader):
1409 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -08001410 subclass = queue_prop.subtypes.get(subtype)
1411 if subclass:
1412 return subclass.unpack(reader)
1413
1414 obj = queue_prop()
1415 obj.type = reader.read("!H")[0]
1416 _len = reader.read("!H")[0]
1417 orig_reader = reader
1418 reader = orig_reader.slice(_len - (2 + 2))
1419 reader.skip(4)
1420 return obj
1421
1422 def __eq__(self, other):
1423 if type(self) != type(other): return False
1424 if self.type != other.type: return False
1425 return True
1426
1427 def pretty_print(self, q):
1428 q.text("queue_prop {")
1429 with q.group():
1430 with q.indent(2):
1431 q.breakable()
1432 q.breakable()
1433 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08001434
1435
1436class queue_prop_min_rate(queue_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07001437 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07001438
1439 def __init__(self, rate=None):
1440 if rate != None:
1441 self.rate = rate
1442 else:
1443 self.rate = 0
1444 return
1445
1446 def pack(self):
1447 packed = []
1448 packed.append(struct.pack("!H", self.type))
1449 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1450 packed.append('\x00' * 4)
1451 packed.append(struct.pack("!H", self.rate))
1452 packed.append('\x00' * 6)
1453 length = sum([len(x) for x in packed])
1454 packed[1] = struct.pack("!H", length)
1455 return ''.join(packed)
1456
1457 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001458 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001459 obj = queue_prop_min_rate()
Dan Talaycof6202252013-07-02 01:00:29 -07001460 _type = reader.read("!H")[0]
1461 assert(_type == 1)
1462 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001463 orig_reader = reader
1464 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001465 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001466 obj.rate = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001467 reader.skip(6)
1468 return obj
1469
1470 def __eq__(self, other):
1471 if type(self) != type(other): return False
1472 if self.rate != other.rate: return False
1473 return True
1474
Rich Lanec2ee4b82013-04-24 17:12:38 -07001475 def pretty_print(self, q):
1476 q.text("queue_prop_min_rate {")
1477 with q.group():
1478 with q.indent(2):
1479 q.breakable()
1480 q.text("rate = ");
1481 q.text("%#x" % self.rate)
1482 q.breakable()
1483 q.text('}')
1484
Rich Lane7dcdf022013-12-11 14:45:27 -08001485queue_prop.subtypes[1] = queue_prop_min_rate
1486
1487class queue_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001488
1489 def __init__(self, port_no=None, queue_id=None, tx_bytes=None, tx_packets=None, tx_errors=None):
1490 if port_no != None:
1491 self.port_no = port_no
1492 else:
1493 self.port_no = 0
1494 if queue_id != None:
1495 self.queue_id = queue_id
1496 else:
1497 self.queue_id = 0
1498 if tx_bytes != None:
1499 self.tx_bytes = tx_bytes
1500 else:
1501 self.tx_bytes = 0
1502 if tx_packets != None:
1503 self.tx_packets = tx_packets
1504 else:
1505 self.tx_packets = 0
1506 if tx_errors != None:
1507 self.tx_errors = tx_errors
1508 else:
1509 self.tx_errors = 0
1510 return
1511
1512 def pack(self):
1513 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07001514 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001515 packed.append(struct.pack("!L", self.queue_id))
1516 packed.append(struct.pack("!Q", self.tx_bytes))
1517 packed.append(struct.pack("!Q", self.tx_packets))
1518 packed.append(struct.pack("!Q", self.tx_errors))
1519 return ''.join(packed)
1520
1521 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001522 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001523 obj = queue_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001524 obj.port_no = util.unpack_port_no(reader)
1525 obj.queue_id = reader.read("!L")[0]
1526 obj.tx_bytes = reader.read("!Q")[0]
1527 obj.tx_packets = reader.read("!Q")[0]
1528 obj.tx_errors = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001529 return obj
1530
1531 def __eq__(self, other):
1532 if type(self) != type(other): return False
1533 if self.port_no != other.port_no: return False
1534 if self.queue_id != other.queue_id: return False
1535 if self.tx_bytes != other.tx_bytes: return False
1536 if self.tx_packets != other.tx_packets: return False
1537 if self.tx_errors != other.tx_errors: return False
1538 return True
1539
Rich Lanec2ee4b82013-04-24 17:12:38 -07001540 def pretty_print(self, q):
1541 q.text("queue_stats_entry {")
1542 with q.group():
1543 with q.indent(2):
1544 q.breakable()
1545 q.text("port_no = ");
1546 q.text(util.pretty_port(self.port_no))
1547 q.text(","); q.breakable()
1548 q.text("queue_id = ");
1549 q.text("%#x" % self.queue_id)
1550 q.text(","); q.breakable()
1551 q.text("tx_bytes = ");
1552 q.text("%#x" % self.tx_bytes)
1553 q.text(","); q.breakable()
1554 q.text("tx_packets = ");
1555 q.text("%#x" % self.tx_packets)
1556 q.text(","); q.breakable()
1557 q.text("tx_errors = ");
1558 q.text("%#x" % self.tx_errors)
1559 q.breakable()
1560 q.text('}')
1561
Rich Lane7dcdf022013-12-11 14:45:27 -08001562
1563class table_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001564
1565 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):
1566 if table_id != None:
1567 self.table_id = table_id
1568 else:
1569 self.table_id = 0
1570 if name != None:
1571 self.name = name
1572 else:
1573 self.name = ""
1574 if wildcards != None:
1575 self.wildcards = wildcards
1576 else:
Dan Talaycof6202252013-07-02 01:00:29 -07001577 self.wildcards = util.init_wc_bmap()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001578 if match != None:
1579 self.match = match
1580 else:
Dan Talaycof6202252013-07-02 01:00:29 -07001581 self.match = util.init_match_bmap()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001582 if instructions != None:
1583 self.instructions = instructions
1584 else:
1585 self.instructions = 0
1586 if write_actions != None:
1587 self.write_actions = write_actions
1588 else:
1589 self.write_actions = 0
1590 if apply_actions != None:
1591 self.apply_actions = apply_actions
1592 else:
1593 self.apply_actions = 0
1594 if config != None:
1595 self.config = config
1596 else:
1597 self.config = 0
1598 if max_entries != None:
1599 self.max_entries = max_entries
1600 else:
1601 self.max_entries = 0
1602 if active_count != None:
1603 self.active_count = active_count
1604 else:
1605 self.active_count = 0
1606 if lookup_count != None:
1607 self.lookup_count = lookup_count
1608 else:
1609 self.lookup_count = 0
1610 if matched_count != None:
1611 self.matched_count = matched_count
1612 else:
1613 self.matched_count = 0
1614 return
1615
1616 def pack(self):
1617 packed = []
1618 packed.append(struct.pack("!B", self.table_id))
1619 packed.append('\x00' * 7)
1620 packed.append(struct.pack("!32s", self.name))
Dan Talaycof6202252013-07-02 01:00:29 -07001621 packed.append(util.pack_wc_bmap(self.wildcards))
1622 packed.append(util.pack_match_bmap(self.match))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001623 packed.append(struct.pack("!L", self.instructions))
1624 packed.append(struct.pack("!L", self.write_actions))
1625 packed.append(struct.pack("!L", self.apply_actions))
1626 packed.append(struct.pack("!L", self.config))
1627 packed.append(struct.pack("!L", self.max_entries))
1628 packed.append(struct.pack("!L", self.active_count))
1629 packed.append(struct.pack("!Q", self.lookup_count))
1630 packed.append(struct.pack("!Q", self.matched_count))
1631 return ''.join(packed)
1632
1633 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001634 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001635 obj = table_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001636 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001637 reader.skip(7)
1638 obj.name = reader.read("!32s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -07001639 obj.wildcards = util.unpack_wc_bmap(reader)
1640 obj.match = util.unpack_match_bmap(reader)
1641 obj.instructions = reader.read("!L")[0]
1642 obj.write_actions = reader.read("!L")[0]
1643 obj.apply_actions = reader.read("!L")[0]
1644 obj.config = reader.read("!L")[0]
1645 obj.max_entries = reader.read("!L")[0]
1646 obj.active_count = reader.read("!L")[0]
1647 obj.lookup_count = reader.read("!Q")[0]
1648 obj.matched_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001649 return obj
1650
1651 def __eq__(self, other):
1652 if type(self) != type(other): return False
1653 if self.table_id != other.table_id: return False
1654 if self.name != other.name: return False
1655 if self.wildcards != other.wildcards: return False
1656 if self.match != other.match: return False
1657 if self.instructions != other.instructions: return False
1658 if self.write_actions != other.write_actions: return False
1659 if self.apply_actions != other.apply_actions: return False
1660 if self.config != other.config: return False
1661 if self.max_entries != other.max_entries: return False
1662 if self.active_count != other.active_count: return False
1663 if self.lookup_count != other.lookup_count: return False
1664 if self.matched_count != other.matched_count: return False
1665 return True
1666
Rich Lanec2ee4b82013-04-24 17:12:38 -07001667 def pretty_print(self, q):
1668 q.text("table_stats_entry {")
1669 with q.group():
1670 with q.indent(2):
1671 q.breakable()
1672 q.text("table_id = ");
1673 q.text("%#x" % self.table_id)
1674 q.text(","); q.breakable()
1675 q.text("name = ");
1676 q.pp(self.name)
1677 q.text(","); q.breakable()
1678 q.text("wildcards = ");
1679 q.text(util.pretty_wildcards(self.wildcards))
1680 q.text(","); q.breakable()
1681 q.text("match = ");
1682 q.pp(self.match)
1683 q.text(","); q.breakable()
1684 q.text("instructions = ");
1685 q.text("%#x" % self.instructions)
1686 q.text(","); q.breakable()
1687 q.text("write_actions = ");
1688 q.text("%#x" % self.write_actions)
1689 q.text(","); q.breakable()
1690 q.text("apply_actions = ");
1691 q.text("%#x" % self.apply_actions)
1692 q.text(","); q.breakable()
1693 q.text("config = ");
1694 q.text("%#x" % self.config)
1695 q.text(","); q.breakable()
1696 q.text("max_entries = ");
1697 q.text("%#x" % self.max_entries)
1698 q.text(","); q.breakable()
1699 q.text("active_count = ");
1700 q.text("%#x" % self.active_count)
1701 q.text(","); q.breakable()
1702 q.text("lookup_count = ");
1703 q.text("%#x" % self.lookup_count)
1704 q.text(","); q.breakable()
1705 q.text("matched_count = ");
1706 q.text("%#x" % self.matched_count)
1707 q.breakable()
1708 q.text('}')
1709
1710
Rich Lane7dcdf022013-12-11 14:45:27 -08001711
Rich Lanec2ee4b82013-04-24 17:12:38 -07001712match = match_v2