blob: a1f2a097c5ff2c8657b3f2f4c3a40c39ff780b1f [file] [log] [blame]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001# Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2# Copyright (c) 2011, 2012 Open Networking Foundation
3# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
Dan Talaycof6202252013-07-02 01:00:29 -07004# See the file LICENSE.pyloxi which should have been included in the source distribution
Rich Lane7dcdf022013-12-11 14:45:27 -08005
6# Automatically generated by LOXI from template module.py
Rich Lanec2ee4b82013-04-24 17:12:38 -07007# Do not modify
8
Rich Lanec2ee4b82013-04-24 17:12:38 -07009import struct
Rich Lane7dcdf022013-12-11 14:45:27 -080010import loxi
Rich Lanec2ee4b82013-04-24 17:12:38 -070011import const
Rich Lane7dcdf022013-12-11 14:45:27 -080012import common
13import action
14import instruction
15import oxm
Rich Lanec2ee4b82013-04-24 17:12:38 -070016import util
17import loxi.generic_util
18
Rich Lane7dcdf022013-12-11 14:45:27 -080019class bsn_interface(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -070020
21 def __init__(self, hw_addr=None, name=None, ipv4_addr=None, ipv4_netmask=None):
22 if hw_addr != None:
23 self.hw_addr = hw_addr
24 else:
25 self.hw_addr = [0,0,0,0,0,0]
26 if name != None:
27 self.name = name
28 else:
29 self.name = ""
30 if ipv4_addr != None:
31 self.ipv4_addr = ipv4_addr
32 else:
33 self.ipv4_addr = 0
34 if ipv4_netmask != None:
35 self.ipv4_netmask = ipv4_netmask
36 else:
37 self.ipv4_netmask = 0
38 return
39
40 def pack(self):
41 packed = []
42 packed.append(struct.pack("!6B", *self.hw_addr))
43 packed.append('\x00' * 2)
44 packed.append(struct.pack("!16s", self.name))
45 packed.append(struct.pack("!L", self.ipv4_addr))
46 packed.append(struct.pack("!L", self.ipv4_netmask))
47 return ''.join(packed)
48
49 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -080050 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -070051 obj = bsn_interface()
Rich Lanec2ee4b82013-04-24 17:12:38 -070052 obj.hw_addr = list(reader.read('!6B'))
53 reader.skip(2)
54 obj.name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -070055 obj.ipv4_addr = reader.read("!L")[0]
56 obj.ipv4_netmask = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -070057 return obj
58
59 def __eq__(self, other):
60 if type(self) != type(other): return False
61 if self.hw_addr != other.hw_addr: return False
62 if self.name != other.name: return False
63 if self.ipv4_addr != other.ipv4_addr: return False
64 if self.ipv4_netmask != other.ipv4_netmask: return False
65 return True
66
Rich Lanec2ee4b82013-04-24 17:12:38 -070067 def pretty_print(self, q):
68 q.text("bsn_interface {")
69 with q.group():
70 with q.indent(2):
71 q.breakable()
72 q.text("hw_addr = ");
73 q.text(util.pretty_mac(self.hw_addr))
74 q.text(","); q.breakable()
75 q.text("name = ");
76 q.pp(self.name)
77 q.text(","); q.breakable()
78 q.text("ipv4_addr = ");
79 q.text(util.pretty_ipv4(self.ipv4_addr))
80 q.text(","); q.breakable()
81 q.text("ipv4_netmask = ");
82 q.text(util.pretty_ipv4(self.ipv4_netmask))
83 q.breakable()
84 q.text('}')
85
Rich Lane7dcdf022013-12-11 14:45:27 -080086
87class bsn_vport(loxi.OFObject):
88 subtypes = {}
89
Rich Lane95f7fc92014-01-27 17:08:16 -080090
91 def __init__(self, type=None):
92 if type != None:
93 self.type = type
94 else:
95 self.type = 0
96 return
97
98 def pack(self):
99 packed = []
100 packed.append(struct.pack("!H", self.type))
101 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
102 length = sum([len(x) for x in packed])
103 packed[1] = struct.pack("!H", length)
104 return ''.join(packed)
105
Rich Lane7dcdf022013-12-11 14:45:27 -0800106 @staticmethod
107 def unpack(reader):
108 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -0800109 subclass = bsn_vport.subtypes.get(subtype)
110 if subclass:
111 return subclass.unpack(reader)
112
113 obj = bsn_vport()
114 obj.type = reader.read("!H")[0]
115 _length = reader.read("!H")[0]
116 orig_reader = reader
117 reader = orig_reader.slice(_length - (2 + 2))
118 return obj
119
120 def __eq__(self, other):
121 if type(self) != type(other): return False
122 if self.type != other.type: return False
123 return True
124
125 def pretty_print(self, q):
126 q.text("bsn_vport {")
127 with q.group():
128 with q.indent(2):
129 q.breakable()
130 q.breakable()
131 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800132
133
Rich Lane93b33132014-04-21 12:20:58 -0700134class bsn_vport_l2gre(bsn_vport):
135 type = 1
136
137 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):
138 if flags != None:
139 self.flags = flags
140 else:
141 self.flags = 0
142 if port_no != None:
143 self.port_no = port_no
144 else:
145 self.port_no = 0
146 if local_mac != None:
147 self.local_mac = local_mac
148 else:
149 self.local_mac = [0,0,0,0,0,0]
150 if nh_mac != None:
151 self.nh_mac = nh_mac
152 else:
153 self.nh_mac = [0,0,0,0,0,0]
154 if src_ip != None:
155 self.src_ip = src_ip
156 else:
157 self.src_ip = 0
158 if dst_ip != None:
159 self.dst_ip = dst_ip
160 else:
161 self.dst_ip = 0
162 if dscp != None:
163 self.dscp = dscp
164 else:
165 self.dscp = 0
166 if ttl != None:
167 self.ttl = ttl
168 else:
169 self.ttl = 0
170 if vpn != None:
171 self.vpn = vpn
172 else:
173 self.vpn = 0
174 if if_name != None:
175 self.if_name = if_name
176 else:
177 self.if_name = ""
178 return
179
180 def pack(self):
181 packed = []
182 packed.append(struct.pack("!H", self.type))
183 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
184 packed.append(struct.pack("!L", self.flags))
185 packed.append(util.pack_port_no(self.port_no))
186 packed.append(struct.pack("!6B", *self.local_mac))
187 packed.append(struct.pack("!6B", *self.nh_mac))
188 packed.append(struct.pack("!L", self.src_ip))
189 packed.append(struct.pack("!L", self.dst_ip))
190 packed.append(struct.pack("!B", self.dscp))
191 packed.append(struct.pack("!B", self.ttl))
192 packed.append('\x00' * 2)
193 packed.append(struct.pack("!L", self.vpn))
194 packed.append(struct.pack("!16s", self.if_name))
195 length = sum([len(x) for x in packed])
196 packed[1] = struct.pack("!H", length)
197 return ''.join(packed)
198
199 @staticmethod
200 def unpack(reader):
201 obj = bsn_vport_l2gre()
202 _type = reader.read("!H")[0]
203 assert(_type == 1)
204 _length = reader.read("!H")[0]
205 orig_reader = reader
206 reader = orig_reader.slice(_length - (2 + 2))
207 obj.flags = reader.read("!L")[0]
208 obj.port_no = util.unpack_port_no(reader)
209 obj.local_mac = list(reader.read('!6B'))
210 obj.nh_mac = list(reader.read('!6B'))
211 obj.src_ip = reader.read("!L")[0]
212 obj.dst_ip = reader.read("!L")[0]
213 obj.dscp = reader.read("!B")[0]
214 obj.ttl = reader.read("!B")[0]
215 reader.skip(2)
216 obj.vpn = reader.read("!L")[0]
217 obj.if_name = reader.read("!16s")[0].rstrip("\x00")
218 return obj
219
220 def __eq__(self, other):
221 if type(self) != type(other): return False
222 if self.flags != other.flags: return False
223 if self.port_no != other.port_no: return False
224 if self.local_mac != other.local_mac: return False
225 if self.nh_mac != other.nh_mac: return False
226 if self.src_ip != other.src_ip: return False
227 if self.dst_ip != other.dst_ip: return False
228 if self.dscp != other.dscp: return False
229 if self.ttl != other.ttl: return False
230 if self.vpn != other.vpn: return False
231 if self.if_name != other.if_name: return False
232 return True
233
234 def pretty_print(self, q):
235 q.text("bsn_vport_l2gre {")
236 with q.group():
237 with q.indent(2):
238 q.breakable()
239 q.text("flags = ");
240 q.text("%#x" % self.flags)
241 q.text(","); q.breakable()
242 q.text("port_no = ");
243 q.text(util.pretty_port(self.port_no))
244 q.text(","); q.breakable()
245 q.text("local_mac = ");
246 q.text(util.pretty_mac(self.local_mac))
247 q.text(","); q.breakable()
248 q.text("nh_mac = ");
249 q.text(util.pretty_mac(self.nh_mac))
250 q.text(","); q.breakable()
251 q.text("src_ip = ");
252 q.text(util.pretty_ipv4(self.src_ip))
253 q.text(","); q.breakable()
254 q.text("dst_ip = ");
255 q.text(util.pretty_ipv4(self.dst_ip))
256 q.text(","); q.breakable()
257 q.text("dscp = ");
258 q.text("%#x" % self.dscp)
259 q.text(","); q.breakable()
260 q.text("ttl = ");
261 q.text("%#x" % self.ttl)
262 q.text(","); q.breakable()
263 q.text("vpn = ");
264 q.text("%#x" % self.vpn)
265 q.text(","); q.breakable()
266 q.text("if_name = ");
267 q.pp(self.if_name)
268 q.breakable()
269 q.text('}')
270
271bsn_vport.subtypes[1] = bsn_vport_l2gre
272
Rich Lane7dcdf022013-12-11 14:45:27 -0800273class bsn_vport_q_in_q(bsn_vport):
Dan Talaycof6202252013-07-02 01:00:29 -0700274 type = 0
275
Kiran Poola150d8b02013-09-20 13:30:39 -0700276 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 -0700277 if port_no != None:
278 self.port_no = port_no
279 else:
280 self.port_no = 0
281 if ingress_tpid != None:
282 self.ingress_tpid = ingress_tpid
283 else:
284 self.ingress_tpid = 0
285 if ingress_vlan_id != None:
286 self.ingress_vlan_id = ingress_vlan_id
287 else:
288 self.ingress_vlan_id = 0
289 if egress_tpid != None:
290 self.egress_tpid = egress_tpid
291 else:
292 self.egress_tpid = 0
293 if egress_vlan_id != None:
294 self.egress_vlan_id = egress_vlan_id
295 else:
296 self.egress_vlan_id = 0
Kiran Poola150d8b02013-09-20 13:30:39 -0700297 if if_name != None:
298 self.if_name = if_name
299 else:
300 self.if_name = ""
Dan Talaycof6202252013-07-02 01:00:29 -0700301 return
302
303 def pack(self):
304 packed = []
305 packed.append(struct.pack("!H", self.type))
Kiran Poola150d8b02013-09-20 13:30:39 -0700306 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700307 packed.append(struct.pack("!L", self.port_no))
308 packed.append(struct.pack("!H", self.ingress_tpid))
309 packed.append(struct.pack("!H", self.ingress_vlan_id))
310 packed.append(struct.pack("!H", self.egress_tpid))
311 packed.append(struct.pack("!H", self.egress_vlan_id))
Kiran Poola150d8b02013-09-20 13:30:39 -0700312 packed.append(struct.pack("!16s", self.if_name))
Dan Talaycof6202252013-07-02 01:00:29 -0700313 length = sum([len(x) for x in packed])
Kiran Poola150d8b02013-09-20 13:30:39 -0700314 packed[1] = struct.pack("!H", length)
Dan Talaycof6202252013-07-02 01:00:29 -0700315 return ''.join(packed)
316
317 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800318 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -0700319 obj = bsn_vport_q_in_q()
Dan Talaycof6202252013-07-02 01:00:29 -0700320 _type = reader.read("!H")[0]
321 assert(_type == 0)
322 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800323 orig_reader = reader
324 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700325 obj.port_no = reader.read("!L")[0]
326 obj.ingress_tpid = reader.read("!H")[0]
327 obj.ingress_vlan_id = reader.read("!H")[0]
328 obj.egress_tpid = reader.read("!H")[0]
329 obj.egress_vlan_id = reader.read("!H")[0]
Kiran Poola150d8b02013-09-20 13:30:39 -0700330 obj.if_name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -0700331 return obj
332
333 def __eq__(self, other):
334 if type(self) != type(other): return False
335 if self.port_no != other.port_no: return False
336 if self.ingress_tpid != other.ingress_tpid: return False
337 if self.ingress_vlan_id != other.ingress_vlan_id: return False
338 if self.egress_tpid != other.egress_tpid: return False
339 if self.egress_vlan_id != other.egress_vlan_id: return False
Kiran Poola150d8b02013-09-20 13:30:39 -0700340 if self.if_name != other.if_name: return False
Dan Talaycof6202252013-07-02 01:00:29 -0700341 return True
342
Dan Talaycof6202252013-07-02 01:00:29 -0700343 def pretty_print(self, q):
344 q.text("bsn_vport_q_in_q {")
345 with q.group():
346 with q.indent(2):
347 q.breakable()
348 q.text("port_no = ");
349 q.text("%#x" % self.port_no)
350 q.text(","); q.breakable()
351 q.text("ingress_tpid = ");
352 q.text("%#x" % self.ingress_tpid)
353 q.text(","); q.breakable()
354 q.text("ingress_vlan_id = ");
355 q.text("%#x" % self.ingress_vlan_id)
356 q.text(","); q.breakable()
357 q.text("egress_tpid = ");
358 q.text("%#x" % self.egress_tpid)
359 q.text(","); q.breakable()
360 q.text("egress_vlan_id = ");
361 q.text("%#x" % self.egress_vlan_id)
Kiran Poola150d8b02013-09-20 13:30:39 -0700362 q.text(","); q.breakable()
363 q.text("if_name = ");
364 q.pp(self.if_name)
Dan Talaycof6202252013-07-02 01:00:29 -0700365 q.breakable()
366 q.text('}')
367
Rich Lane7dcdf022013-12-11 14:45:27 -0800368bsn_vport.subtypes[0] = bsn_vport_q_in_q
369
370class bucket(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700371
372 def __init__(self, weight=None, watch_port=None, watch_group=None, actions=None):
373 if weight != None:
374 self.weight = weight
375 else:
376 self.weight = 0
377 if watch_port != None:
378 self.watch_port = watch_port
379 else:
380 self.watch_port = 0
381 if watch_group != None:
382 self.watch_group = watch_group
383 else:
384 self.watch_group = 0
385 if actions != None:
386 self.actions = actions
387 else:
388 self.actions = []
389 return
390
391 def pack(self):
392 packed = []
393 packed.append(struct.pack("!H", 0)) # placeholder for len at index 0
394 packed.append(struct.pack("!H", self.weight))
Dan Talaycof6202252013-07-02 01:00:29 -0700395 packed.append(util.pack_port_no(self.watch_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700396 packed.append(struct.pack("!L", self.watch_group))
397 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -0800398 packed.append(loxi.generic_util.pack_list(self.actions))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700399 length = sum([len(x) for x in packed])
400 packed[0] = struct.pack("!H", length)
401 return ''.join(packed)
402
403 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800404 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700405 obj = bucket()
Dan Talaycof6202252013-07-02 01:00:29 -0700406 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800407 orig_reader = reader
408 reader = orig_reader.slice(_len - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700409 obj.weight = reader.read("!H")[0]
410 obj.watch_port = util.unpack_port_no(reader)
411 obj.watch_group = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700412 reader.skip(4)
Rich Lane7dcdf022013-12-11 14:45:27 -0800413 obj.actions = loxi.generic_util.unpack_list(reader, action.action.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700414 return obj
415
416 def __eq__(self, other):
417 if type(self) != type(other): return False
418 if self.weight != other.weight: return False
419 if self.watch_port != other.watch_port: return False
420 if self.watch_group != other.watch_group: return False
421 if self.actions != other.actions: return False
422 return True
423
Rich Lanec2ee4b82013-04-24 17:12:38 -0700424 def pretty_print(self, q):
425 q.text("bucket {")
426 with q.group():
427 with q.indent(2):
428 q.breakable()
429 q.text("weight = ");
430 q.text("%#x" % self.weight)
431 q.text(","); q.breakable()
432 q.text("watch_port = ");
433 q.text(util.pretty_port(self.watch_port))
434 q.text(","); q.breakable()
435 q.text("watch_group = ");
436 q.text("%#x" % self.watch_group)
437 q.text(","); q.breakable()
438 q.text("actions = ");
439 q.pp(self.actions)
440 q.breakable()
441 q.text('}')
442
Rich Lane7dcdf022013-12-11 14:45:27 -0800443
444class bucket_counter(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700445
446 def __init__(self, packet_count=None, byte_count=None):
447 if packet_count != None:
448 self.packet_count = packet_count
449 else:
450 self.packet_count = 0
451 if byte_count != None:
452 self.byte_count = byte_count
453 else:
454 self.byte_count = 0
455 return
456
457 def pack(self):
458 packed = []
459 packed.append(struct.pack("!Q", self.packet_count))
460 packed.append(struct.pack("!Q", self.byte_count))
461 return ''.join(packed)
462
463 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800464 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700465 obj = bucket_counter()
Dan Talaycof6202252013-07-02 01:00:29 -0700466 obj.packet_count = reader.read("!Q")[0]
467 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700468 return obj
469
470 def __eq__(self, other):
471 if type(self) != type(other): return False
472 if self.packet_count != other.packet_count: return False
473 if self.byte_count != other.byte_count: return False
474 return True
475
Rich Lanec2ee4b82013-04-24 17:12:38 -0700476 def pretty_print(self, q):
477 q.text("bucket_counter {")
478 with q.group():
479 with q.indent(2):
480 q.breakable()
481 q.text("packet_count = ");
482 q.text("%#x" % self.packet_count)
483 q.text(","); q.breakable()
484 q.text("byte_count = ");
485 q.text("%#x" % self.byte_count)
486 q.breakable()
487 q.text('}')
488
Rich Lane7dcdf022013-12-11 14:45:27 -0800489
490class flow_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700491
492 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):
493 if table_id != None:
494 self.table_id = table_id
495 else:
496 self.table_id = 0
497 if duration_sec != None:
498 self.duration_sec = duration_sec
499 else:
500 self.duration_sec = 0
501 if duration_nsec != None:
502 self.duration_nsec = duration_nsec
503 else:
504 self.duration_nsec = 0
505 if priority != None:
506 self.priority = priority
507 else:
508 self.priority = 0
509 if idle_timeout != None:
510 self.idle_timeout = idle_timeout
511 else:
512 self.idle_timeout = 0
513 if hard_timeout != None:
514 self.hard_timeout = hard_timeout
515 else:
516 self.hard_timeout = 0
517 if cookie != None:
518 self.cookie = cookie
519 else:
520 self.cookie = 0
521 if packet_count != None:
522 self.packet_count = packet_count
523 else:
524 self.packet_count = 0
525 if byte_count != None:
526 self.byte_count = byte_count
527 else:
528 self.byte_count = 0
529 if match != None:
530 self.match = match
531 else:
532 self.match = common.match()
533 if instructions != None:
534 self.instructions = instructions
535 else:
536 self.instructions = []
537 return
538
539 def pack(self):
540 packed = []
541 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
542 packed.append(struct.pack("!B", self.table_id))
543 packed.append('\x00' * 1)
544 packed.append(struct.pack("!L", self.duration_sec))
545 packed.append(struct.pack("!L", self.duration_nsec))
546 packed.append(struct.pack("!H", self.priority))
547 packed.append(struct.pack("!H", self.idle_timeout))
548 packed.append(struct.pack("!H", self.hard_timeout))
549 packed.append('\x00' * 6)
550 packed.append(struct.pack("!Q", self.cookie))
551 packed.append(struct.pack("!Q", self.packet_count))
552 packed.append(struct.pack("!Q", self.byte_count))
553 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -0800554 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700555 length = sum([len(x) for x in packed])
556 packed[0] = struct.pack("!H", length)
557 return ''.join(packed)
558
559 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800560 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700561 obj = flow_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -0700562 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800563 orig_reader = reader
564 reader = orig_reader.slice(_length - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700565 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700566 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -0700567 obj.duration_sec = reader.read("!L")[0]
568 obj.duration_nsec = reader.read("!L")[0]
569 obj.priority = reader.read("!H")[0]
570 obj.idle_timeout = reader.read("!H")[0]
571 obj.hard_timeout = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700572 reader.skip(6)
Dan Talaycof6202252013-07-02 01:00:29 -0700573 obj.cookie = reader.read("!Q")[0]
574 obj.packet_count = reader.read("!Q")[0]
575 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700576 obj.match = common.match.unpack(reader)
Rich Lane7dcdf022013-12-11 14:45:27 -0800577 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700578 return obj
579
580 def __eq__(self, other):
581 if type(self) != type(other): return False
582 if self.table_id != other.table_id: return False
583 if self.duration_sec != other.duration_sec: return False
584 if self.duration_nsec != other.duration_nsec: return False
585 if self.priority != other.priority: return False
586 if self.idle_timeout != other.idle_timeout: return False
587 if self.hard_timeout != other.hard_timeout: return False
588 if self.cookie != other.cookie: return False
589 if self.packet_count != other.packet_count: return False
590 if self.byte_count != other.byte_count: return False
591 if self.match != other.match: return False
592 if self.instructions != other.instructions: return False
593 return True
594
Rich Lanec2ee4b82013-04-24 17:12:38 -0700595 def pretty_print(self, q):
596 q.text("flow_stats_entry {")
597 with q.group():
598 with q.indent(2):
599 q.breakable()
600 q.text("table_id = ");
601 q.text("%#x" % self.table_id)
602 q.text(","); q.breakable()
603 q.text("duration_sec = ");
604 q.text("%#x" % self.duration_sec)
605 q.text(","); q.breakable()
606 q.text("duration_nsec = ");
607 q.text("%#x" % self.duration_nsec)
608 q.text(","); q.breakable()
609 q.text("priority = ");
610 q.text("%#x" % self.priority)
611 q.text(","); q.breakable()
612 q.text("idle_timeout = ");
613 q.text("%#x" % self.idle_timeout)
614 q.text(","); q.breakable()
615 q.text("hard_timeout = ");
616 q.text("%#x" % self.hard_timeout)
617 q.text(","); q.breakable()
618 q.text("cookie = ");
619 q.text("%#x" % self.cookie)
620 q.text(","); q.breakable()
621 q.text("packet_count = ");
622 q.text("%#x" % self.packet_count)
623 q.text(","); q.breakable()
624 q.text("byte_count = ");
625 q.text("%#x" % self.byte_count)
626 q.text(","); q.breakable()
627 q.text("match = ");
628 q.pp(self.match)
629 q.text(","); q.breakable()
630 q.text("instructions = ");
631 q.pp(self.instructions)
632 q.breakable()
633 q.text('}')
634
Rich Lane7dcdf022013-12-11 14:45:27 -0800635
636class group_desc_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700637
Rich Lane6f4978c2013-10-20 21:33:52 -0700638 def __init__(self, group_type=None, group_id=None, buckets=None):
639 if group_type != None:
640 self.group_type = group_type
Rich Lanec2ee4b82013-04-24 17:12:38 -0700641 else:
Rich Lane6f4978c2013-10-20 21:33:52 -0700642 self.group_type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700643 if group_id != None:
644 self.group_id = group_id
645 else:
646 self.group_id = 0
647 if buckets != None:
648 self.buckets = buckets
649 else:
650 self.buckets = []
651 return
652
653 def pack(self):
654 packed = []
655 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
Rich Lane6f4978c2013-10-20 21:33:52 -0700656 packed.append(struct.pack("!B", self.group_type))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700657 packed.append('\x00' * 1)
658 packed.append(struct.pack("!L", self.group_id))
Rich Lane7dcdf022013-12-11 14:45:27 -0800659 packed.append(loxi.generic_util.pack_list(self.buckets))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700660 length = sum([len(x) for x in packed])
661 packed[0] = struct.pack("!H", length)
662 return ''.join(packed)
663
664 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800665 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700666 obj = group_desc_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -0700667 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800668 orig_reader = reader
669 reader = orig_reader.slice(_length - (0 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -0700670 obj.group_type = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700671 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -0700672 obj.group_id = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800673 obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700674 return obj
675
676 def __eq__(self, other):
677 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -0700678 if self.group_type != other.group_type: return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700679 if self.group_id != other.group_id: return False
680 if self.buckets != other.buckets: return False
681 return True
682
Rich Lanec2ee4b82013-04-24 17:12:38 -0700683 def pretty_print(self, q):
684 q.text("group_desc_stats_entry {")
685 with q.group():
686 with q.indent(2):
687 q.breakable()
Rich Lane6f4978c2013-10-20 21:33:52 -0700688 q.text("group_type = ");
689 q.text("%#x" % self.group_type)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700690 q.text(","); q.breakable()
691 q.text("group_id = ");
692 q.text("%#x" % self.group_id)
693 q.text(","); q.breakable()
694 q.text("buckets = ");
695 q.pp(self.buckets)
696 q.breakable()
697 q.text('}')
698
Rich Lane7dcdf022013-12-11 14:45:27 -0800699
700class group_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700701
702 def __init__(self, group_id=None, ref_count=None, packet_count=None, byte_count=None, bucket_stats=None):
703 if group_id != None:
704 self.group_id = group_id
705 else:
706 self.group_id = 0
707 if ref_count != None:
708 self.ref_count = ref_count
709 else:
710 self.ref_count = 0
711 if packet_count != None:
712 self.packet_count = packet_count
713 else:
714 self.packet_count = 0
715 if byte_count != None:
716 self.byte_count = byte_count
717 else:
718 self.byte_count = 0
719 if bucket_stats != None:
720 self.bucket_stats = bucket_stats
721 else:
722 self.bucket_stats = []
723 return
724
725 def pack(self):
726 packed = []
727 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
728 packed.append('\x00' * 2)
729 packed.append(struct.pack("!L", self.group_id))
730 packed.append(struct.pack("!L", self.ref_count))
731 packed.append('\x00' * 4)
732 packed.append(struct.pack("!Q", self.packet_count))
733 packed.append(struct.pack("!Q", self.byte_count))
Rich Lane7dcdf022013-12-11 14:45:27 -0800734 packed.append(loxi.generic_util.pack_list(self.bucket_stats))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700735 length = sum([len(x) for x in packed])
736 packed[0] = struct.pack("!H", length)
737 return ''.join(packed)
738
739 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800740 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700741 obj = group_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -0700742 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800743 orig_reader = reader
744 reader = orig_reader.slice(_length - (0 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700745 reader.skip(2)
Dan Talaycof6202252013-07-02 01:00:29 -0700746 obj.group_id = reader.read("!L")[0]
747 obj.ref_count = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700748 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -0700749 obj.packet_count = reader.read("!Q")[0]
750 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700751 obj.bucket_stats = loxi.generic_util.unpack_list(reader, common.bucket_counter.unpack)
752 return obj
753
754 def __eq__(self, other):
755 if type(self) != type(other): return False
756 if self.group_id != other.group_id: return False
757 if self.ref_count != other.ref_count: return False
758 if self.packet_count != other.packet_count: return False
759 if self.byte_count != other.byte_count: return False
760 if self.bucket_stats != other.bucket_stats: return False
761 return True
762
Rich Lanec2ee4b82013-04-24 17:12:38 -0700763 def pretty_print(self, q):
764 q.text("group_stats_entry {")
765 with q.group():
766 with q.indent(2):
767 q.breakable()
768 q.text("group_id = ");
769 q.text("%#x" % self.group_id)
770 q.text(","); q.breakable()
771 q.text("ref_count = ");
772 q.text("%#x" % self.ref_count)
773 q.text(","); q.breakable()
774 q.text("packet_count = ");
775 q.text("%#x" % self.packet_count)
776 q.text(","); q.breakable()
777 q.text("byte_count = ");
778 q.text("%#x" % self.byte_count)
779 q.text(","); q.breakable()
780 q.text("bucket_stats = ");
781 q.pp(self.bucket_stats)
782 q.breakable()
783 q.text('}')
784
Rich Lane7dcdf022013-12-11 14:45:27 -0800785
786class match_v3(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700787 type = 1
788
789 def __init__(self, oxm_list=None):
790 if oxm_list != None:
791 self.oxm_list = oxm_list
792 else:
793 self.oxm_list = []
794 return
795
796 def pack(self):
797 packed = []
798 packed.append(struct.pack("!H", self.type))
799 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -0800800 packed.append(loxi.generic_util.pack_list(self.oxm_list))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700801 length = sum([len(x) for x in packed])
802 packed[1] = struct.pack("!H", length)
Rich Laned53156a2013-08-05 17:17:33 -0700803 packed.append(loxi.generic_util.pad_to(8, length))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700804 return ''.join(packed)
805
806 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800807 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700808 obj = match_v3()
Dan Talaycof6202252013-07-02 01:00:29 -0700809 _type = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700810 assert(_type == 1)
Dan Talaycof6202252013-07-02 01:00:29 -0700811 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800812 orig_reader = reader
813 reader = orig_reader.slice(_length - (2 + 2))
814 obj.oxm_list = loxi.generic_util.unpack_list(reader, oxm.oxm.unpack)
815 orig_reader.skip_align()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700816 return obj
817
818 def __eq__(self, other):
819 if type(self) != type(other): return False
820 if self.oxm_list != other.oxm_list: return False
821 return True
822
Rich Lanec2ee4b82013-04-24 17:12:38 -0700823 def pretty_print(self, q):
824 q.text("match_v3 {")
825 with q.group():
826 with q.indent(2):
827 q.breakable()
828 q.text("oxm_list = ");
829 q.pp(self.oxm_list)
830 q.breakable()
831 q.text('}')
832
Rich Lane7dcdf022013-12-11 14:45:27 -0800833
834class packet_queue(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700835
836 def __init__(self, queue_id=None, port=None, properties=None):
837 if queue_id != None:
838 self.queue_id = queue_id
839 else:
840 self.queue_id = 0
841 if port != None:
842 self.port = port
843 else:
844 self.port = 0
845 if properties != None:
846 self.properties = properties
847 else:
848 self.properties = []
849 return
850
851 def pack(self):
852 packed = []
853 packed.append(struct.pack("!L", self.queue_id))
Dan Talaycof6202252013-07-02 01:00:29 -0700854 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700855 packed.append(struct.pack("!H", 0)) # placeholder for len at index 2
856 packed.append('\x00' * 6)
Rich Lane7dcdf022013-12-11 14:45:27 -0800857 packed.append(loxi.generic_util.pack_list(self.properties))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700858 length = sum([len(x) for x in packed])
859 packed[2] = struct.pack("!H", length)
860 return ''.join(packed)
861
862 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800863 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700864 obj = packet_queue()
Dan Talaycof6202252013-07-02 01:00:29 -0700865 obj.queue_id = reader.read("!L")[0]
866 obj.port = util.unpack_port_no(reader)
867 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800868 orig_reader = reader
869 reader = orig_reader.slice(_len - (8 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700870 reader.skip(6)
Rich Lane7dcdf022013-12-11 14:45:27 -0800871 obj.properties = loxi.generic_util.unpack_list(reader, common.queue_prop.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700872 return obj
873
874 def __eq__(self, other):
875 if type(self) != type(other): return False
876 if self.queue_id != other.queue_id: return False
877 if self.port != other.port: return False
878 if self.properties != other.properties: return False
879 return True
880
Rich Lanec2ee4b82013-04-24 17:12:38 -0700881 def pretty_print(self, q):
882 q.text("packet_queue {")
883 with q.group():
884 with q.indent(2):
885 q.breakable()
886 q.text("queue_id = ");
887 q.text("%#x" % self.queue_id)
888 q.text(","); q.breakable()
889 q.text("port = ");
890 q.text(util.pretty_port(self.port))
891 q.text(","); q.breakable()
892 q.text("properties = ");
893 q.pp(self.properties)
894 q.breakable()
895 q.text('}')
896
Rich Lane7dcdf022013-12-11 14:45:27 -0800897
898class port_desc(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700899
900 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):
901 if port_no != None:
902 self.port_no = port_no
903 else:
904 self.port_no = 0
905 if hw_addr != None:
906 self.hw_addr = hw_addr
907 else:
908 self.hw_addr = [0,0,0,0,0,0]
909 if name != None:
910 self.name = name
911 else:
912 self.name = ""
913 if config != None:
914 self.config = config
915 else:
916 self.config = 0
917 if state != None:
918 self.state = state
919 else:
920 self.state = 0
921 if curr != None:
922 self.curr = curr
923 else:
924 self.curr = 0
925 if advertised != None:
926 self.advertised = advertised
927 else:
928 self.advertised = 0
929 if supported != None:
930 self.supported = supported
931 else:
932 self.supported = 0
933 if peer != None:
934 self.peer = peer
935 else:
936 self.peer = 0
937 if curr_speed != None:
938 self.curr_speed = curr_speed
939 else:
940 self.curr_speed = 0
941 if max_speed != None:
942 self.max_speed = max_speed
943 else:
944 self.max_speed = 0
945 return
946
947 def pack(self):
948 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -0700949 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700950 packed.append('\x00' * 4)
951 packed.append(struct.pack("!6B", *self.hw_addr))
952 packed.append('\x00' * 2)
953 packed.append(struct.pack("!16s", self.name))
954 packed.append(struct.pack("!L", self.config))
955 packed.append(struct.pack("!L", self.state))
956 packed.append(struct.pack("!L", self.curr))
957 packed.append(struct.pack("!L", self.advertised))
958 packed.append(struct.pack("!L", self.supported))
959 packed.append(struct.pack("!L", self.peer))
960 packed.append(struct.pack("!L", self.curr_speed))
961 packed.append(struct.pack("!L", self.max_speed))
962 return ''.join(packed)
963
964 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800965 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700966 obj = port_desc()
Dan Talaycof6202252013-07-02 01:00:29 -0700967 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700968 reader.skip(4)
969 obj.hw_addr = list(reader.read('!6B'))
970 reader.skip(2)
971 obj.name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -0700972 obj.config = reader.read("!L")[0]
973 obj.state = reader.read("!L")[0]
974 obj.curr = reader.read("!L")[0]
975 obj.advertised = reader.read("!L")[0]
976 obj.supported = reader.read("!L")[0]
977 obj.peer = reader.read("!L")[0]
978 obj.curr_speed = reader.read("!L")[0]
979 obj.max_speed = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700980 return obj
981
982 def __eq__(self, other):
983 if type(self) != type(other): return False
984 if self.port_no != other.port_no: return False
985 if self.hw_addr != other.hw_addr: return False
986 if self.name != other.name: return False
987 if self.config != other.config: return False
988 if self.state != other.state: return False
989 if self.curr != other.curr: return False
990 if self.advertised != other.advertised: return False
991 if self.supported != other.supported: return False
992 if self.peer != other.peer: return False
993 if self.curr_speed != other.curr_speed: return False
994 if self.max_speed != other.max_speed: return False
995 return True
996
Rich Lanec2ee4b82013-04-24 17:12:38 -0700997 def pretty_print(self, q):
998 q.text("port_desc {")
999 with q.group():
1000 with q.indent(2):
1001 q.breakable()
1002 q.text("port_no = ");
1003 q.text(util.pretty_port(self.port_no))
1004 q.text(","); q.breakable()
1005 q.text("hw_addr = ");
1006 q.text(util.pretty_mac(self.hw_addr))
1007 q.text(","); q.breakable()
1008 q.text("name = ");
1009 q.pp(self.name)
1010 q.text(","); q.breakable()
1011 q.text("config = ");
1012 q.text("%#x" % self.config)
1013 q.text(","); q.breakable()
1014 q.text("state = ");
1015 q.text("%#x" % self.state)
1016 q.text(","); q.breakable()
1017 q.text("curr = ");
1018 q.text("%#x" % self.curr)
1019 q.text(","); q.breakable()
1020 q.text("advertised = ");
1021 q.text("%#x" % self.advertised)
1022 q.text(","); q.breakable()
1023 q.text("supported = ");
1024 q.text("%#x" % self.supported)
1025 q.text(","); q.breakable()
1026 q.text("peer = ");
1027 q.text("%#x" % self.peer)
1028 q.text(","); q.breakable()
1029 q.text("curr_speed = ");
1030 q.text("%#x" % self.curr_speed)
1031 q.text(","); q.breakable()
1032 q.text("max_speed = ");
1033 q.text("%#x" % self.max_speed)
1034 q.breakable()
1035 q.text('}')
1036
Rich Lane7dcdf022013-12-11 14:45:27 -08001037
1038class port_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001039
1040 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):
1041 if port_no != None:
1042 self.port_no = port_no
1043 else:
1044 self.port_no = 0
1045 if rx_packets != None:
1046 self.rx_packets = rx_packets
1047 else:
1048 self.rx_packets = 0
1049 if tx_packets != None:
1050 self.tx_packets = tx_packets
1051 else:
1052 self.tx_packets = 0
1053 if rx_bytes != None:
1054 self.rx_bytes = rx_bytes
1055 else:
1056 self.rx_bytes = 0
1057 if tx_bytes != None:
1058 self.tx_bytes = tx_bytes
1059 else:
1060 self.tx_bytes = 0
1061 if rx_dropped != None:
1062 self.rx_dropped = rx_dropped
1063 else:
1064 self.rx_dropped = 0
1065 if tx_dropped != None:
1066 self.tx_dropped = tx_dropped
1067 else:
1068 self.tx_dropped = 0
1069 if rx_errors != None:
1070 self.rx_errors = rx_errors
1071 else:
1072 self.rx_errors = 0
1073 if tx_errors != None:
1074 self.tx_errors = tx_errors
1075 else:
1076 self.tx_errors = 0
1077 if rx_frame_err != None:
1078 self.rx_frame_err = rx_frame_err
1079 else:
1080 self.rx_frame_err = 0
1081 if rx_over_err != None:
1082 self.rx_over_err = rx_over_err
1083 else:
1084 self.rx_over_err = 0
1085 if rx_crc_err != None:
1086 self.rx_crc_err = rx_crc_err
1087 else:
1088 self.rx_crc_err = 0
1089 if collisions != None:
1090 self.collisions = collisions
1091 else:
1092 self.collisions = 0
1093 return
1094
1095 def pack(self):
1096 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07001097 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001098 packed.append('\x00' * 4)
1099 packed.append(struct.pack("!Q", self.rx_packets))
1100 packed.append(struct.pack("!Q", self.tx_packets))
1101 packed.append(struct.pack("!Q", self.rx_bytes))
1102 packed.append(struct.pack("!Q", self.tx_bytes))
1103 packed.append(struct.pack("!Q", self.rx_dropped))
1104 packed.append(struct.pack("!Q", self.tx_dropped))
1105 packed.append(struct.pack("!Q", self.rx_errors))
1106 packed.append(struct.pack("!Q", self.tx_errors))
1107 packed.append(struct.pack("!Q", self.rx_frame_err))
1108 packed.append(struct.pack("!Q", self.rx_over_err))
1109 packed.append(struct.pack("!Q", self.rx_crc_err))
1110 packed.append(struct.pack("!Q", self.collisions))
1111 return ''.join(packed)
1112
1113 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001114 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001115 obj = port_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001116 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001117 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001118 obj.rx_packets = reader.read("!Q")[0]
1119 obj.tx_packets = reader.read("!Q")[0]
1120 obj.rx_bytes = reader.read("!Q")[0]
1121 obj.tx_bytes = reader.read("!Q")[0]
1122 obj.rx_dropped = reader.read("!Q")[0]
1123 obj.tx_dropped = reader.read("!Q")[0]
1124 obj.rx_errors = reader.read("!Q")[0]
1125 obj.tx_errors = reader.read("!Q")[0]
1126 obj.rx_frame_err = reader.read("!Q")[0]
1127 obj.rx_over_err = reader.read("!Q")[0]
1128 obj.rx_crc_err = reader.read("!Q")[0]
1129 obj.collisions = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001130 return obj
1131
1132 def __eq__(self, other):
1133 if type(self) != type(other): return False
1134 if self.port_no != other.port_no: return False
1135 if self.rx_packets != other.rx_packets: return False
1136 if self.tx_packets != other.tx_packets: return False
1137 if self.rx_bytes != other.rx_bytes: return False
1138 if self.tx_bytes != other.tx_bytes: return False
1139 if self.rx_dropped != other.rx_dropped: return False
1140 if self.tx_dropped != other.tx_dropped: return False
1141 if self.rx_errors != other.rx_errors: return False
1142 if self.tx_errors != other.tx_errors: return False
1143 if self.rx_frame_err != other.rx_frame_err: return False
1144 if self.rx_over_err != other.rx_over_err: return False
1145 if self.rx_crc_err != other.rx_crc_err: return False
1146 if self.collisions != other.collisions: return False
1147 return True
1148
Rich Lanec2ee4b82013-04-24 17:12:38 -07001149 def pretty_print(self, q):
1150 q.text("port_stats_entry {")
1151 with q.group():
1152 with q.indent(2):
1153 q.breakable()
1154 q.text("port_no = ");
1155 q.text(util.pretty_port(self.port_no))
1156 q.text(","); q.breakable()
1157 q.text("rx_packets = ");
1158 q.text("%#x" % self.rx_packets)
1159 q.text(","); q.breakable()
1160 q.text("tx_packets = ");
1161 q.text("%#x" % self.tx_packets)
1162 q.text(","); q.breakable()
1163 q.text("rx_bytes = ");
1164 q.text("%#x" % self.rx_bytes)
1165 q.text(","); q.breakable()
1166 q.text("tx_bytes = ");
1167 q.text("%#x" % self.tx_bytes)
1168 q.text(","); q.breakable()
1169 q.text("rx_dropped = ");
1170 q.text("%#x" % self.rx_dropped)
1171 q.text(","); q.breakable()
1172 q.text("tx_dropped = ");
1173 q.text("%#x" % self.tx_dropped)
1174 q.text(","); q.breakable()
1175 q.text("rx_errors = ");
1176 q.text("%#x" % self.rx_errors)
1177 q.text(","); q.breakable()
1178 q.text("tx_errors = ");
1179 q.text("%#x" % self.tx_errors)
1180 q.text(","); q.breakable()
1181 q.text("rx_frame_err = ");
1182 q.text("%#x" % self.rx_frame_err)
1183 q.text(","); q.breakable()
1184 q.text("rx_over_err = ");
1185 q.text("%#x" % self.rx_over_err)
1186 q.text(","); q.breakable()
1187 q.text("rx_crc_err = ");
1188 q.text("%#x" % self.rx_crc_err)
1189 q.text(","); q.breakable()
1190 q.text("collisions = ");
1191 q.text("%#x" % self.collisions)
1192 q.breakable()
1193 q.text('}')
1194
Rich Lane7dcdf022013-12-11 14:45:27 -08001195
1196class queue_prop(loxi.OFObject):
1197 subtypes = {}
1198
Rich Lane95f7fc92014-01-27 17:08:16 -08001199
1200 def __init__(self, type=None):
1201 if type != None:
1202 self.type = type
1203 else:
1204 self.type = 0
1205 return
1206
1207 def pack(self):
1208 packed = []
1209 packed.append(struct.pack("!H", self.type))
1210 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1211 packed.append('\x00' * 4)
1212 length = sum([len(x) for x in packed])
1213 packed[1] = struct.pack("!H", length)
1214 return ''.join(packed)
1215
Rich Lane7dcdf022013-12-11 14:45:27 -08001216 @staticmethod
1217 def unpack(reader):
1218 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -08001219 subclass = queue_prop.subtypes.get(subtype)
1220 if subclass:
1221 return subclass.unpack(reader)
1222
1223 obj = queue_prop()
1224 obj.type = reader.read("!H")[0]
1225 _len = reader.read("!H")[0]
1226 orig_reader = reader
1227 reader = orig_reader.slice(_len - (2 + 2))
1228 reader.skip(4)
1229 return obj
1230
1231 def __eq__(self, other):
1232 if type(self) != type(other): return False
1233 if self.type != other.type: return False
1234 return True
1235
1236 def pretty_print(self, q):
1237 q.text("queue_prop {")
1238 with q.group():
1239 with q.indent(2):
1240 q.breakable()
1241 q.breakable()
1242 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08001243
1244
1245class queue_prop_experimenter(queue_prop):
1246 subtypes = {}
1247
Rich Lane95f7fc92014-01-27 17:08:16 -08001248 type = 65535
1249
1250 def __init__(self, experimenter=None, data=None):
1251 if experimenter != None:
1252 self.experimenter = experimenter
1253 else:
1254 self.experimenter = 0
1255 if data != None:
1256 self.data = data
1257 else:
1258 self.data = ''
1259 return
1260
1261 def pack(self):
1262 packed = []
1263 packed.append(struct.pack("!H", self.type))
1264 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1265 packed.append('\x00' * 4)
1266 packed.append(struct.pack("!L", self.experimenter))
1267 packed.append('\x00' * 4)
1268 packed.append(self.data)
1269 length = sum([len(x) for x in packed])
1270 packed[1] = struct.pack("!H", length)
1271 return ''.join(packed)
1272
Rich Lane7dcdf022013-12-11 14:45:27 -08001273 @staticmethod
1274 def unpack(reader):
1275 subtype, = reader.peek('!L', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -08001276 subclass = queue_prop_experimenter.subtypes.get(subtype)
1277 if subclass:
1278 return subclass.unpack(reader)
1279
1280 obj = queue_prop_experimenter()
1281 _type = reader.read("!H")[0]
1282 assert(_type == 65535)
1283 _len = reader.read("!H")[0]
1284 orig_reader = reader
1285 reader = orig_reader.slice(_len - (2 + 2))
1286 reader.skip(4)
1287 obj.experimenter = reader.read("!L")[0]
1288 reader.skip(4)
1289 obj.data = str(reader.read_all())
1290 return obj
1291
1292 def __eq__(self, other):
1293 if type(self) != type(other): return False
1294 if self.experimenter != other.experimenter: return False
1295 if self.data != other.data: return False
1296 return True
1297
1298 def pretty_print(self, q):
1299 q.text("queue_prop_experimenter {")
1300 with q.group():
1301 with q.indent(2):
1302 q.breakable()
1303 q.text("data = ");
1304 q.pp(self.data)
1305 q.breakable()
1306 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08001307
1308queue_prop.subtypes[65535] = queue_prop_experimenter
1309
1310class queue_prop_max_rate(queue_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07001311 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07001312
1313 def __init__(self, rate=None):
1314 if rate != None:
1315 self.rate = rate
1316 else:
1317 self.rate = 0
1318 return
1319
1320 def pack(self):
1321 packed = []
1322 packed.append(struct.pack("!H", self.type))
1323 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1324 packed.append('\x00' * 4)
1325 packed.append(struct.pack("!H", self.rate))
1326 packed.append('\x00' * 6)
1327 length = sum([len(x) for x in packed])
1328 packed[1] = struct.pack("!H", length)
1329 return ''.join(packed)
1330
1331 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001332 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001333 obj = queue_prop_max_rate()
Dan Talaycof6202252013-07-02 01:00:29 -07001334 _type = reader.read("!H")[0]
1335 assert(_type == 2)
1336 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001337 orig_reader = reader
1338 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001339 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001340 obj.rate = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001341 reader.skip(6)
1342 return obj
1343
1344 def __eq__(self, other):
1345 if type(self) != type(other): return False
1346 if self.rate != other.rate: return False
1347 return True
1348
Rich Lanec2ee4b82013-04-24 17:12:38 -07001349 def pretty_print(self, q):
1350 q.text("queue_prop_max_rate {")
1351 with q.group():
1352 with q.indent(2):
1353 q.breakable()
1354 q.text("rate = ");
1355 q.text("%#x" % self.rate)
1356 q.breakable()
1357 q.text('}')
1358
Rich Lane7dcdf022013-12-11 14:45:27 -08001359queue_prop.subtypes[2] = queue_prop_max_rate
1360
1361class queue_prop_min_rate(queue_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07001362 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07001363
1364 def __init__(self, rate=None):
1365 if rate != None:
1366 self.rate = rate
1367 else:
1368 self.rate = 0
1369 return
1370
1371 def pack(self):
1372 packed = []
1373 packed.append(struct.pack("!H", self.type))
1374 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1375 packed.append('\x00' * 4)
1376 packed.append(struct.pack("!H", self.rate))
1377 packed.append('\x00' * 6)
1378 length = sum([len(x) for x in packed])
1379 packed[1] = struct.pack("!H", length)
1380 return ''.join(packed)
1381
1382 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001383 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001384 obj = queue_prop_min_rate()
Dan Talaycof6202252013-07-02 01:00:29 -07001385 _type = reader.read("!H")[0]
1386 assert(_type == 1)
1387 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001388 orig_reader = reader
1389 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001390 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001391 obj.rate = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001392 reader.skip(6)
1393 return obj
1394
1395 def __eq__(self, other):
1396 if type(self) != type(other): return False
1397 if self.rate != other.rate: return False
1398 return True
1399
Rich Lanec2ee4b82013-04-24 17:12:38 -07001400 def pretty_print(self, q):
1401 q.text("queue_prop_min_rate {")
1402 with q.group():
1403 with q.indent(2):
1404 q.breakable()
1405 q.text("rate = ");
1406 q.text("%#x" % self.rate)
1407 q.breakable()
1408 q.text('}')
1409
Rich Lane7dcdf022013-12-11 14:45:27 -08001410queue_prop.subtypes[1] = queue_prop_min_rate
1411
1412class queue_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001413
1414 def __init__(self, port_no=None, queue_id=None, tx_bytes=None, tx_packets=None, tx_errors=None):
1415 if port_no != None:
1416 self.port_no = port_no
1417 else:
1418 self.port_no = 0
1419 if queue_id != None:
1420 self.queue_id = queue_id
1421 else:
1422 self.queue_id = 0
1423 if tx_bytes != None:
1424 self.tx_bytes = tx_bytes
1425 else:
1426 self.tx_bytes = 0
1427 if tx_packets != None:
1428 self.tx_packets = tx_packets
1429 else:
1430 self.tx_packets = 0
1431 if tx_errors != None:
1432 self.tx_errors = tx_errors
1433 else:
1434 self.tx_errors = 0
1435 return
1436
1437 def pack(self):
1438 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07001439 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001440 packed.append(struct.pack("!L", self.queue_id))
1441 packed.append(struct.pack("!Q", self.tx_bytes))
1442 packed.append(struct.pack("!Q", self.tx_packets))
1443 packed.append(struct.pack("!Q", self.tx_errors))
1444 return ''.join(packed)
1445
1446 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001447 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001448 obj = queue_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001449 obj.port_no = util.unpack_port_no(reader)
1450 obj.queue_id = reader.read("!L")[0]
1451 obj.tx_bytes = reader.read("!Q")[0]
1452 obj.tx_packets = reader.read("!Q")[0]
1453 obj.tx_errors = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001454 return obj
1455
1456 def __eq__(self, other):
1457 if type(self) != type(other): return False
1458 if self.port_no != other.port_no: return False
1459 if self.queue_id != other.queue_id: return False
1460 if self.tx_bytes != other.tx_bytes: return False
1461 if self.tx_packets != other.tx_packets: return False
1462 if self.tx_errors != other.tx_errors: return False
1463 return True
1464
Rich Lanec2ee4b82013-04-24 17:12:38 -07001465 def pretty_print(self, q):
1466 q.text("queue_stats_entry {")
1467 with q.group():
1468 with q.indent(2):
1469 q.breakable()
1470 q.text("port_no = ");
1471 q.text(util.pretty_port(self.port_no))
1472 q.text(","); q.breakable()
1473 q.text("queue_id = ");
1474 q.text("%#x" % self.queue_id)
1475 q.text(","); q.breakable()
1476 q.text("tx_bytes = ");
1477 q.text("%#x" % self.tx_bytes)
1478 q.text(","); q.breakable()
1479 q.text("tx_packets = ");
1480 q.text("%#x" % self.tx_packets)
1481 q.text(","); q.breakable()
1482 q.text("tx_errors = ");
1483 q.text("%#x" % self.tx_errors)
1484 q.breakable()
1485 q.text('}')
1486
Rich Lane7dcdf022013-12-11 14:45:27 -08001487
1488class table_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001489
1490 def __init__(self, table_id=None, name=None, match=None, wildcards=None, write_actions=None, apply_actions=None, write_setfields=None, apply_setfields=None, metadata_match=None, metadata_write=None, instructions=None, config=None, max_entries=None, active_count=None, lookup_count=None, matched_count=None):
1491 if table_id != None:
1492 self.table_id = table_id
1493 else:
1494 self.table_id = 0
1495 if name != None:
1496 self.name = name
1497 else:
1498 self.name = ""
1499 if match != None:
1500 self.match = match
1501 else:
Dan Talaycof6202252013-07-02 01:00:29 -07001502 self.match = util.init_match_bmap()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001503 if wildcards != None:
1504 self.wildcards = wildcards
1505 else:
Dan Talaycof6202252013-07-02 01:00:29 -07001506 self.wildcards = util.init_wc_bmap()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001507 if write_actions != None:
1508 self.write_actions = write_actions
1509 else:
1510 self.write_actions = 0
1511 if apply_actions != None:
1512 self.apply_actions = apply_actions
1513 else:
1514 self.apply_actions = 0
1515 if write_setfields != None:
1516 self.write_setfields = write_setfields
1517 else:
1518 self.write_setfields = 0
1519 if apply_setfields != None:
1520 self.apply_setfields = apply_setfields
1521 else:
1522 self.apply_setfields = 0
1523 if metadata_match != None:
1524 self.metadata_match = metadata_match
1525 else:
1526 self.metadata_match = 0
1527 if metadata_write != None:
1528 self.metadata_write = metadata_write
1529 else:
1530 self.metadata_write = 0
1531 if instructions != None:
1532 self.instructions = instructions
1533 else:
1534 self.instructions = 0
1535 if config != None:
1536 self.config = config
1537 else:
1538 self.config = 0
1539 if max_entries != None:
1540 self.max_entries = max_entries
1541 else:
1542 self.max_entries = 0
1543 if active_count != None:
1544 self.active_count = active_count
1545 else:
1546 self.active_count = 0
1547 if lookup_count != None:
1548 self.lookup_count = lookup_count
1549 else:
1550 self.lookup_count = 0
1551 if matched_count != None:
1552 self.matched_count = matched_count
1553 else:
1554 self.matched_count = 0
1555 return
1556
1557 def pack(self):
1558 packed = []
1559 packed.append(struct.pack("!B", self.table_id))
1560 packed.append('\x00' * 7)
1561 packed.append(struct.pack("!32s", self.name))
Dan Talaycof6202252013-07-02 01:00:29 -07001562 packed.append(util.pack_match_bmap(self.match))
1563 packed.append(util.pack_wc_bmap(self.wildcards))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001564 packed.append(struct.pack("!L", self.write_actions))
1565 packed.append(struct.pack("!L", self.apply_actions))
1566 packed.append(struct.pack("!Q", self.write_setfields))
1567 packed.append(struct.pack("!Q", self.apply_setfields))
1568 packed.append(struct.pack("!Q", self.metadata_match))
1569 packed.append(struct.pack("!Q", self.metadata_write))
1570 packed.append(struct.pack("!L", self.instructions))
1571 packed.append(struct.pack("!L", self.config))
1572 packed.append(struct.pack("!L", self.max_entries))
1573 packed.append(struct.pack("!L", self.active_count))
1574 packed.append(struct.pack("!Q", self.lookup_count))
1575 packed.append(struct.pack("!Q", self.matched_count))
1576 return ''.join(packed)
1577
1578 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001579 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001580 obj = table_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001581 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001582 reader.skip(7)
1583 obj.name = reader.read("!32s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -07001584 obj.match = util.unpack_match_bmap(reader)
1585 obj.wildcards = util.unpack_wc_bmap(reader)
1586 obj.write_actions = reader.read("!L")[0]
1587 obj.apply_actions = reader.read("!L")[0]
1588 obj.write_setfields = reader.read("!Q")[0]
1589 obj.apply_setfields = reader.read("!Q")[0]
1590 obj.metadata_match = reader.read("!Q")[0]
1591 obj.metadata_write = reader.read("!Q")[0]
1592 obj.instructions = reader.read("!L")[0]
1593 obj.config = reader.read("!L")[0]
1594 obj.max_entries = reader.read("!L")[0]
1595 obj.active_count = reader.read("!L")[0]
1596 obj.lookup_count = reader.read("!Q")[0]
1597 obj.matched_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001598 return obj
1599
1600 def __eq__(self, other):
1601 if type(self) != type(other): return False
1602 if self.table_id != other.table_id: return False
1603 if self.name != other.name: return False
1604 if self.match != other.match: return False
1605 if self.wildcards != other.wildcards: return False
1606 if self.write_actions != other.write_actions: return False
1607 if self.apply_actions != other.apply_actions: return False
1608 if self.write_setfields != other.write_setfields: return False
1609 if self.apply_setfields != other.apply_setfields: return False
1610 if self.metadata_match != other.metadata_match: return False
1611 if self.metadata_write != other.metadata_write: return False
1612 if self.instructions != other.instructions: return False
1613 if self.config != other.config: return False
1614 if self.max_entries != other.max_entries: return False
1615 if self.active_count != other.active_count: return False
1616 if self.lookup_count != other.lookup_count: return False
1617 if self.matched_count != other.matched_count: return False
1618 return True
1619
Rich Lanec2ee4b82013-04-24 17:12:38 -07001620 def pretty_print(self, q):
1621 q.text("table_stats_entry {")
1622 with q.group():
1623 with q.indent(2):
1624 q.breakable()
1625 q.text("table_id = ");
1626 q.text("%#x" % self.table_id)
1627 q.text(","); q.breakable()
1628 q.text("name = ");
1629 q.pp(self.name)
1630 q.text(","); q.breakable()
1631 q.text("match = ");
1632 q.pp(self.match)
1633 q.text(","); q.breakable()
1634 q.text("wildcards = ");
1635 q.pp(self.wildcards)
1636 q.text(","); q.breakable()
1637 q.text("write_actions = ");
1638 q.text("%#x" % self.write_actions)
1639 q.text(","); q.breakable()
1640 q.text("apply_actions = ");
1641 q.text("%#x" % self.apply_actions)
1642 q.text(","); q.breakable()
1643 q.text("write_setfields = ");
1644 q.text("%#x" % self.write_setfields)
1645 q.text(","); q.breakable()
1646 q.text("apply_setfields = ");
1647 q.text("%#x" % self.apply_setfields)
1648 q.text(","); q.breakable()
1649 q.text("metadata_match = ");
1650 q.text("%#x" % self.metadata_match)
1651 q.text(","); q.breakable()
1652 q.text("metadata_write = ");
1653 q.text("%#x" % self.metadata_write)
1654 q.text(","); q.breakable()
1655 q.text("instructions = ");
1656 q.text("%#x" % self.instructions)
1657 q.text(","); q.breakable()
1658 q.text("config = ");
1659 q.text("%#x" % self.config)
1660 q.text(","); q.breakable()
1661 q.text("max_entries = ");
1662 q.text("%#x" % self.max_entries)
1663 q.text(","); q.breakable()
1664 q.text("active_count = ");
1665 q.text("%#x" % self.active_count)
1666 q.text(","); q.breakable()
1667 q.text("lookup_count = ");
1668 q.text("%#x" % self.lookup_count)
1669 q.text(","); q.breakable()
1670 q.text("matched_count = ");
1671 q.text("%#x" % self.matched_count)
1672 q.breakable()
1673 q.text('}')
1674
1675
Rich Lane7dcdf022013-12-11 14:45:27 -08001676
Rich Lanec2ee4b82013-04-24 17:12:38 -07001677match = match_v3