blob: 9565196e482fd724b1450ec86e3d186c6ce05d7f [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
134class bsn_vport_q_in_q(bsn_vport):
Dan Talaycof6202252013-07-02 01:00:29 -0700135 type = 0
136
Kiran Poola150d8b02013-09-20 13:30:39 -0700137 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 -0700138 if port_no != None:
139 self.port_no = port_no
140 else:
141 self.port_no = 0
142 if ingress_tpid != None:
143 self.ingress_tpid = ingress_tpid
144 else:
145 self.ingress_tpid = 0
146 if ingress_vlan_id != None:
147 self.ingress_vlan_id = ingress_vlan_id
148 else:
149 self.ingress_vlan_id = 0
150 if egress_tpid != None:
151 self.egress_tpid = egress_tpid
152 else:
153 self.egress_tpid = 0
154 if egress_vlan_id != None:
155 self.egress_vlan_id = egress_vlan_id
156 else:
157 self.egress_vlan_id = 0
Kiran Poola150d8b02013-09-20 13:30:39 -0700158 if if_name != None:
159 self.if_name = if_name
160 else:
161 self.if_name = ""
Dan Talaycof6202252013-07-02 01:00:29 -0700162 return
163
164 def pack(self):
165 packed = []
166 packed.append(struct.pack("!H", self.type))
Kiran Poola150d8b02013-09-20 13:30:39 -0700167 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700168 packed.append(struct.pack("!L", self.port_no))
169 packed.append(struct.pack("!H", self.ingress_tpid))
170 packed.append(struct.pack("!H", self.ingress_vlan_id))
171 packed.append(struct.pack("!H", self.egress_tpid))
172 packed.append(struct.pack("!H", self.egress_vlan_id))
Kiran Poola150d8b02013-09-20 13:30:39 -0700173 packed.append(struct.pack("!16s", self.if_name))
Dan Talaycof6202252013-07-02 01:00:29 -0700174 length = sum([len(x) for x in packed])
Kiran Poola150d8b02013-09-20 13:30:39 -0700175 packed[1] = struct.pack("!H", length)
Dan Talaycof6202252013-07-02 01:00:29 -0700176 return ''.join(packed)
177
178 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800179 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -0700180 obj = bsn_vport_q_in_q()
Dan Talaycof6202252013-07-02 01:00:29 -0700181 _type = reader.read("!H")[0]
182 assert(_type == 0)
183 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800184 orig_reader = reader
185 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700186 obj.port_no = reader.read("!L")[0]
187 obj.ingress_tpid = reader.read("!H")[0]
188 obj.ingress_vlan_id = reader.read("!H")[0]
189 obj.egress_tpid = reader.read("!H")[0]
190 obj.egress_vlan_id = reader.read("!H")[0]
Kiran Poola150d8b02013-09-20 13:30:39 -0700191 obj.if_name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -0700192 return obj
193
194 def __eq__(self, other):
195 if type(self) != type(other): return False
196 if self.port_no != other.port_no: return False
197 if self.ingress_tpid != other.ingress_tpid: return False
198 if self.ingress_vlan_id != other.ingress_vlan_id: return False
199 if self.egress_tpid != other.egress_tpid: return False
200 if self.egress_vlan_id != other.egress_vlan_id: return False
Kiran Poola150d8b02013-09-20 13:30:39 -0700201 if self.if_name != other.if_name: return False
Dan Talaycof6202252013-07-02 01:00:29 -0700202 return True
203
Dan Talaycof6202252013-07-02 01:00:29 -0700204 def pretty_print(self, q):
205 q.text("bsn_vport_q_in_q {")
206 with q.group():
207 with q.indent(2):
208 q.breakable()
209 q.text("port_no = ");
210 q.text("%#x" % self.port_no)
211 q.text(","); q.breakable()
212 q.text("ingress_tpid = ");
213 q.text("%#x" % self.ingress_tpid)
214 q.text(","); q.breakable()
215 q.text("ingress_vlan_id = ");
216 q.text("%#x" % self.ingress_vlan_id)
217 q.text(","); q.breakable()
218 q.text("egress_tpid = ");
219 q.text("%#x" % self.egress_tpid)
220 q.text(","); q.breakable()
221 q.text("egress_vlan_id = ");
222 q.text("%#x" % self.egress_vlan_id)
Kiran Poola150d8b02013-09-20 13:30:39 -0700223 q.text(","); q.breakable()
224 q.text("if_name = ");
225 q.pp(self.if_name)
Dan Talaycof6202252013-07-02 01:00:29 -0700226 q.breakable()
227 q.text('}')
228
Rich Lane7dcdf022013-12-11 14:45:27 -0800229bsn_vport.subtypes[0] = bsn_vport_q_in_q
230
231class bucket(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700232
233 def __init__(self, weight=None, watch_port=None, watch_group=None, actions=None):
234 if weight != None:
235 self.weight = weight
236 else:
237 self.weight = 0
238 if watch_port != None:
239 self.watch_port = watch_port
240 else:
241 self.watch_port = 0
242 if watch_group != None:
243 self.watch_group = watch_group
244 else:
245 self.watch_group = 0
246 if actions != None:
247 self.actions = actions
248 else:
249 self.actions = []
250 return
251
252 def pack(self):
253 packed = []
254 packed.append(struct.pack("!H", 0)) # placeholder for len at index 0
255 packed.append(struct.pack("!H", self.weight))
Dan Talaycof6202252013-07-02 01:00:29 -0700256 packed.append(util.pack_port_no(self.watch_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700257 packed.append(struct.pack("!L", self.watch_group))
258 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -0800259 packed.append(loxi.generic_util.pack_list(self.actions))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700260 length = sum([len(x) for x in packed])
261 packed[0] = struct.pack("!H", length)
262 return ''.join(packed)
263
264 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800265 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700266 obj = bucket()
Dan Talaycof6202252013-07-02 01:00:29 -0700267 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800268 orig_reader = reader
269 reader = orig_reader.slice(_len - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700270 obj.weight = reader.read("!H")[0]
271 obj.watch_port = util.unpack_port_no(reader)
272 obj.watch_group = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700273 reader.skip(4)
Rich Lane7dcdf022013-12-11 14:45:27 -0800274 obj.actions = loxi.generic_util.unpack_list(reader, action.action.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700275 return obj
276
277 def __eq__(self, other):
278 if type(self) != type(other): return False
279 if self.weight != other.weight: return False
280 if self.watch_port != other.watch_port: return False
281 if self.watch_group != other.watch_group: return False
282 if self.actions != other.actions: return False
283 return True
284
Rich Lanec2ee4b82013-04-24 17:12:38 -0700285 def pretty_print(self, q):
286 q.text("bucket {")
287 with q.group():
288 with q.indent(2):
289 q.breakable()
290 q.text("weight = ");
291 q.text("%#x" % self.weight)
292 q.text(","); q.breakable()
293 q.text("watch_port = ");
294 q.text(util.pretty_port(self.watch_port))
295 q.text(","); q.breakable()
296 q.text("watch_group = ");
297 q.text("%#x" % self.watch_group)
298 q.text(","); q.breakable()
299 q.text("actions = ");
300 q.pp(self.actions)
301 q.breakable()
302 q.text('}')
303
Rich Lane7dcdf022013-12-11 14:45:27 -0800304
305class bucket_counter(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700306
307 def __init__(self, packet_count=None, byte_count=None):
308 if packet_count != None:
309 self.packet_count = packet_count
310 else:
311 self.packet_count = 0
312 if byte_count != None:
313 self.byte_count = byte_count
314 else:
315 self.byte_count = 0
316 return
317
318 def pack(self):
319 packed = []
320 packed.append(struct.pack("!Q", self.packet_count))
321 packed.append(struct.pack("!Q", self.byte_count))
322 return ''.join(packed)
323
324 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800325 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700326 obj = bucket_counter()
Dan Talaycof6202252013-07-02 01:00:29 -0700327 obj.packet_count = reader.read("!Q")[0]
328 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700329 return obj
330
331 def __eq__(self, other):
332 if type(self) != type(other): return False
333 if self.packet_count != other.packet_count: return False
334 if self.byte_count != other.byte_count: return False
335 return True
336
Rich Lanec2ee4b82013-04-24 17:12:38 -0700337 def pretty_print(self, q):
338 q.text("bucket_counter {")
339 with q.group():
340 with q.indent(2):
341 q.breakable()
342 q.text("packet_count = ");
343 q.text("%#x" % self.packet_count)
344 q.text(","); q.breakable()
345 q.text("byte_count = ");
346 q.text("%#x" % self.byte_count)
347 q.breakable()
348 q.text('}')
349
Rich Lane7dcdf022013-12-11 14:45:27 -0800350
351class flow_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700352
353 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):
354 if table_id != None:
355 self.table_id = table_id
356 else:
357 self.table_id = 0
358 if duration_sec != None:
359 self.duration_sec = duration_sec
360 else:
361 self.duration_sec = 0
362 if duration_nsec != None:
363 self.duration_nsec = duration_nsec
364 else:
365 self.duration_nsec = 0
366 if priority != None:
367 self.priority = priority
368 else:
369 self.priority = 0
370 if idle_timeout != None:
371 self.idle_timeout = idle_timeout
372 else:
373 self.idle_timeout = 0
374 if hard_timeout != None:
375 self.hard_timeout = hard_timeout
376 else:
377 self.hard_timeout = 0
378 if cookie != None:
379 self.cookie = cookie
380 else:
381 self.cookie = 0
382 if packet_count != None:
383 self.packet_count = packet_count
384 else:
385 self.packet_count = 0
386 if byte_count != None:
387 self.byte_count = byte_count
388 else:
389 self.byte_count = 0
390 if match != None:
391 self.match = match
392 else:
393 self.match = common.match()
394 if instructions != None:
395 self.instructions = instructions
396 else:
397 self.instructions = []
398 return
399
400 def pack(self):
401 packed = []
402 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
403 packed.append(struct.pack("!B", self.table_id))
404 packed.append('\x00' * 1)
405 packed.append(struct.pack("!L", self.duration_sec))
406 packed.append(struct.pack("!L", self.duration_nsec))
407 packed.append(struct.pack("!H", self.priority))
408 packed.append(struct.pack("!H", self.idle_timeout))
409 packed.append(struct.pack("!H", self.hard_timeout))
410 packed.append('\x00' * 6)
411 packed.append(struct.pack("!Q", self.cookie))
412 packed.append(struct.pack("!Q", self.packet_count))
413 packed.append(struct.pack("!Q", self.byte_count))
414 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -0800415 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700416 length = sum([len(x) for x in packed])
417 packed[0] = struct.pack("!H", length)
418 return ''.join(packed)
419
420 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800421 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700422 obj = flow_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -0700423 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800424 orig_reader = reader
425 reader = orig_reader.slice(_length - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700426 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700427 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -0700428 obj.duration_sec = reader.read("!L")[0]
429 obj.duration_nsec = reader.read("!L")[0]
430 obj.priority = reader.read("!H")[0]
431 obj.idle_timeout = reader.read("!H")[0]
432 obj.hard_timeout = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700433 reader.skip(6)
Dan Talaycof6202252013-07-02 01:00:29 -0700434 obj.cookie = reader.read("!Q")[0]
435 obj.packet_count = reader.read("!Q")[0]
436 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700437 obj.match = common.match.unpack(reader)
Rich Lane7dcdf022013-12-11 14:45:27 -0800438 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700439 return obj
440
441 def __eq__(self, other):
442 if type(self) != type(other): return False
443 if self.table_id != other.table_id: return False
444 if self.duration_sec != other.duration_sec: return False
445 if self.duration_nsec != other.duration_nsec: return False
446 if self.priority != other.priority: return False
447 if self.idle_timeout != other.idle_timeout: return False
448 if self.hard_timeout != other.hard_timeout: return False
449 if self.cookie != other.cookie: return False
450 if self.packet_count != other.packet_count: return False
451 if self.byte_count != other.byte_count: return False
452 if self.match != other.match: return False
453 if self.instructions != other.instructions: return False
454 return True
455
Rich Lanec2ee4b82013-04-24 17:12:38 -0700456 def pretty_print(self, q):
457 q.text("flow_stats_entry {")
458 with q.group():
459 with q.indent(2):
460 q.breakable()
461 q.text("table_id = ");
462 q.text("%#x" % self.table_id)
463 q.text(","); q.breakable()
464 q.text("duration_sec = ");
465 q.text("%#x" % self.duration_sec)
466 q.text(","); q.breakable()
467 q.text("duration_nsec = ");
468 q.text("%#x" % self.duration_nsec)
469 q.text(","); q.breakable()
470 q.text("priority = ");
471 q.text("%#x" % self.priority)
472 q.text(","); q.breakable()
473 q.text("idle_timeout = ");
474 q.text("%#x" % self.idle_timeout)
475 q.text(","); q.breakable()
476 q.text("hard_timeout = ");
477 q.text("%#x" % self.hard_timeout)
478 q.text(","); q.breakable()
479 q.text("cookie = ");
480 q.text("%#x" % self.cookie)
481 q.text(","); q.breakable()
482 q.text("packet_count = ");
483 q.text("%#x" % self.packet_count)
484 q.text(","); q.breakable()
485 q.text("byte_count = ");
486 q.text("%#x" % self.byte_count)
487 q.text(","); q.breakable()
488 q.text("match = ");
489 q.pp(self.match)
490 q.text(","); q.breakable()
491 q.text("instructions = ");
492 q.pp(self.instructions)
493 q.breakable()
494 q.text('}')
495
Rich Lane7dcdf022013-12-11 14:45:27 -0800496
497class group_desc_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700498
Rich Lane6f4978c2013-10-20 21:33:52 -0700499 def __init__(self, group_type=None, group_id=None, buckets=None):
500 if group_type != None:
501 self.group_type = group_type
Rich Lanec2ee4b82013-04-24 17:12:38 -0700502 else:
Rich Lane6f4978c2013-10-20 21:33:52 -0700503 self.group_type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700504 if group_id != None:
505 self.group_id = group_id
506 else:
507 self.group_id = 0
508 if buckets != None:
509 self.buckets = buckets
510 else:
511 self.buckets = []
512 return
513
514 def pack(self):
515 packed = []
516 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
Rich Lane6f4978c2013-10-20 21:33:52 -0700517 packed.append(struct.pack("!B", self.group_type))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700518 packed.append('\x00' * 1)
519 packed.append(struct.pack("!L", self.group_id))
Rich Lane7dcdf022013-12-11 14:45:27 -0800520 packed.append(loxi.generic_util.pack_list(self.buckets))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700521 length = sum([len(x) for x in packed])
522 packed[0] = struct.pack("!H", length)
523 return ''.join(packed)
524
525 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800526 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700527 obj = group_desc_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -0700528 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800529 orig_reader = reader
530 reader = orig_reader.slice(_length - (0 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -0700531 obj.group_type = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700532 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -0700533 obj.group_id = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800534 obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700535 return obj
536
537 def __eq__(self, other):
538 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -0700539 if self.group_type != other.group_type: return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700540 if self.group_id != other.group_id: return False
541 if self.buckets != other.buckets: return False
542 return True
543
Rich Lanec2ee4b82013-04-24 17:12:38 -0700544 def pretty_print(self, q):
545 q.text("group_desc_stats_entry {")
546 with q.group():
547 with q.indent(2):
548 q.breakable()
Rich Lane6f4978c2013-10-20 21:33:52 -0700549 q.text("group_type = ");
550 q.text("%#x" % self.group_type)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700551 q.text(","); q.breakable()
552 q.text("group_id = ");
553 q.text("%#x" % self.group_id)
554 q.text(","); q.breakable()
555 q.text("buckets = ");
556 q.pp(self.buckets)
557 q.breakable()
558 q.text('}')
559
Rich Lane7dcdf022013-12-11 14:45:27 -0800560
561class group_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700562
563 def __init__(self, group_id=None, ref_count=None, packet_count=None, byte_count=None, bucket_stats=None):
564 if group_id != None:
565 self.group_id = group_id
566 else:
567 self.group_id = 0
568 if ref_count != None:
569 self.ref_count = ref_count
570 else:
571 self.ref_count = 0
572 if packet_count != None:
573 self.packet_count = packet_count
574 else:
575 self.packet_count = 0
576 if byte_count != None:
577 self.byte_count = byte_count
578 else:
579 self.byte_count = 0
580 if bucket_stats != None:
581 self.bucket_stats = bucket_stats
582 else:
583 self.bucket_stats = []
584 return
585
586 def pack(self):
587 packed = []
588 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
589 packed.append('\x00' * 2)
590 packed.append(struct.pack("!L", self.group_id))
591 packed.append(struct.pack("!L", self.ref_count))
592 packed.append('\x00' * 4)
593 packed.append(struct.pack("!Q", self.packet_count))
594 packed.append(struct.pack("!Q", self.byte_count))
Rich Lane7dcdf022013-12-11 14:45:27 -0800595 packed.append(loxi.generic_util.pack_list(self.bucket_stats))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700596 length = sum([len(x) for x in packed])
597 packed[0] = struct.pack("!H", length)
598 return ''.join(packed)
599
600 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800601 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700602 obj = group_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -0700603 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800604 orig_reader = reader
605 reader = orig_reader.slice(_length - (0 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700606 reader.skip(2)
Dan Talaycof6202252013-07-02 01:00:29 -0700607 obj.group_id = reader.read("!L")[0]
608 obj.ref_count = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700609 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -0700610 obj.packet_count = reader.read("!Q")[0]
611 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700612 obj.bucket_stats = loxi.generic_util.unpack_list(reader, common.bucket_counter.unpack)
613 return obj
614
615 def __eq__(self, other):
616 if type(self) != type(other): return False
617 if self.group_id != other.group_id: return False
618 if self.ref_count != other.ref_count: return False
619 if self.packet_count != other.packet_count: return False
620 if self.byte_count != other.byte_count: return False
621 if self.bucket_stats != other.bucket_stats: return False
622 return True
623
Rich Lanec2ee4b82013-04-24 17:12:38 -0700624 def pretty_print(self, q):
625 q.text("group_stats_entry {")
626 with q.group():
627 with q.indent(2):
628 q.breakable()
629 q.text("group_id = ");
630 q.text("%#x" % self.group_id)
631 q.text(","); q.breakable()
632 q.text("ref_count = ");
633 q.text("%#x" % self.ref_count)
634 q.text(","); q.breakable()
635 q.text("packet_count = ");
636 q.text("%#x" % self.packet_count)
637 q.text(","); q.breakable()
638 q.text("byte_count = ");
639 q.text("%#x" % self.byte_count)
640 q.text(","); q.breakable()
641 q.text("bucket_stats = ");
642 q.pp(self.bucket_stats)
643 q.breakable()
644 q.text('}')
645
Rich Lane7dcdf022013-12-11 14:45:27 -0800646
647class match_v3(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700648 type = 1
649
650 def __init__(self, oxm_list=None):
651 if oxm_list != None:
652 self.oxm_list = oxm_list
653 else:
654 self.oxm_list = []
655 return
656
657 def pack(self):
658 packed = []
659 packed.append(struct.pack("!H", self.type))
660 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -0800661 packed.append(loxi.generic_util.pack_list(self.oxm_list))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700662 length = sum([len(x) for x in packed])
663 packed[1] = struct.pack("!H", length)
Rich Laned53156a2013-08-05 17:17:33 -0700664 packed.append(loxi.generic_util.pad_to(8, length))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700665 return ''.join(packed)
666
667 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800668 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700669 obj = match_v3()
Dan Talaycof6202252013-07-02 01:00:29 -0700670 _type = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700671 assert(_type == 1)
Dan Talaycof6202252013-07-02 01:00:29 -0700672 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800673 orig_reader = reader
674 reader = orig_reader.slice(_length - (2 + 2))
675 obj.oxm_list = loxi.generic_util.unpack_list(reader, oxm.oxm.unpack)
676 orig_reader.skip_align()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700677 return obj
678
679 def __eq__(self, other):
680 if type(self) != type(other): return False
681 if self.oxm_list != other.oxm_list: return False
682 return True
683
Rich Lanec2ee4b82013-04-24 17:12:38 -0700684 def pretty_print(self, q):
685 q.text("match_v3 {")
686 with q.group():
687 with q.indent(2):
688 q.breakable()
689 q.text("oxm_list = ");
690 q.pp(self.oxm_list)
691 q.breakable()
692 q.text('}')
693
Rich Lane7dcdf022013-12-11 14:45:27 -0800694
695class packet_queue(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700696
697 def __init__(self, queue_id=None, port=None, properties=None):
698 if queue_id != None:
699 self.queue_id = queue_id
700 else:
701 self.queue_id = 0
702 if port != None:
703 self.port = port
704 else:
705 self.port = 0
706 if properties != None:
707 self.properties = properties
708 else:
709 self.properties = []
710 return
711
712 def pack(self):
713 packed = []
714 packed.append(struct.pack("!L", self.queue_id))
Dan Talaycof6202252013-07-02 01:00:29 -0700715 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700716 packed.append(struct.pack("!H", 0)) # placeholder for len at index 2
717 packed.append('\x00' * 6)
Rich Lane7dcdf022013-12-11 14:45:27 -0800718 packed.append(loxi.generic_util.pack_list(self.properties))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700719 length = sum([len(x) for x in packed])
720 packed[2] = struct.pack("!H", length)
721 return ''.join(packed)
722
723 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800724 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700725 obj = packet_queue()
Dan Talaycof6202252013-07-02 01:00:29 -0700726 obj.queue_id = reader.read("!L")[0]
727 obj.port = util.unpack_port_no(reader)
728 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800729 orig_reader = reader
730 reader = orig_reader.slice(_len - (8 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700731 reader.skip(6)
Rich Lane7dcdf022013-12-11 14:45:27 -0800732 obj.properties = loxi.generic_util.unpack_list(reader, common.queue_prop.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700733 return obj
734
735 def __eq__(self, other):
736 if type(self) != type(other): return False
737 if self.queue_id != other.queue_id: return False
738 if self.port != other.port: return False
739 if self.properties != other.properties: return False
740 return True
741
Rich Lanec2ee4b82013-04-24 17:12:38 -0700742 def pretty_print(self, q):
743 q.text("packet_queue {")
744 with q.group():
745 with q.indent(2):
746 q.breakable()
747 q.text("queue_id = ");
748 q.text("%#x" % self.queue_id)
749 q.text(","); q.breakable()
750 q.text("port = ");
751 q.text(util.pretty_port(self.port))
752 q.text(","); q.breakable()
753 q.text("properties = ");
754 q.pp(self.properties)
755 q.breakable()
756 q.text('}')
757
Rich Lane7dcdf022013-12-11 14:45:27 -0800758
759class port_desc(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700760
761 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):
762 if port_no != None:
763 self.port_no = port_no
764 else:
765 self.port_no = 0
766 if hw_addr != None:
767 self.hw_addr = hw_addr
768 else:
769 self.hw_addr = [0,0,0,0,0,0]
770 if name != None:
771 self.name = name
772 else:
773 self.name = ""
774 if config != None:
775 self.config = config
776 else:
777 self.config = 0
778 if state != None:
779 self.state = state
780 else:
781 self.state = 0
782 if curr != None:
783 self.curr = curr
784 else:
785 self.curr = 0
786 if advertised != None:
787 self.advertised = advertised
788 else:
789 self.advertised = 0
790 if supported != None:
791 self.supported = supported
792 else:
793 self.supported = 0
794 if peer != None:
795 self.peer = peer
796 else:
797 self.peer = 0
798 if curr_speed != None:
799 self.curr_speed = curr_speed
800 else:
801 self.curr_speed = 0
802 if max_speed != None:
803 self.max_speed = max_speed
804 else:
805 self.max_speed = 0
806 return
807
808 def pack(self):
809 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -0700810 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700811 packed.append('\x00' * 4)
812 packed.append(struct.pack("!6B", *self.hw_addr))
813 packed.append('\x00' * 2)
814 packed.append(struct.pack("!16s", self.name))
815 packed.append(struct.pack("!L", self.config))
816 packed.append(struct.pack("!L", self.state))
817 packed.append(struct.pack("!L", self.curr))
818 packed.append(struct.pack("!L", self.advertised))
819 packed.append(struct.pack("!L", self.supported))
820 packed.append(struct.pack("!L", self.peer))
821 packed.append(struct.pack("!L", self.curr_speed))
822 packed.append(struct.pack("!L", self.max_speed))
823 return ''.join(packed)
824
825 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800826 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700827 obj = port_desc()
Dan Talaycof6202252013-07-02 01:00:29 -0700828 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700829 reader.skip(4)
830 obj.hw_addr = list(reader.read('!6B'))
831 reader.skip(2)
832 obj.name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -0700833 obj.config = reader.read("!L")[0]
834 obj.state = reader.read("!L")[0]
835 obj.curr = reader.read("!L")[0]
836 obj.advertised = reader.read("!L")[0]
837 obj.supported = reader.read("!L")[0]
838 obj.peer = reader.read("!L")[0]
839 obj.curr_speed = reader.read("!L")[0]
840 obj.max_speed = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700841 return obj
842
843 def __eq__(self, other):
844 if type(self) != type(other): return False
845 if self.port_no != other.port_no: return False
846 if self.hw_addr != other.hw_addr: return False
847 if self.name != other.name: return False
848 if self.config != other.config: return False
849 if self.state != other.state: return False
850 if self.curr != other.curr: return False
851 if self.advertised != other.advertised: return False
852 if self.supported != other.supported: return False
853 if self.peer != other.peer: return False
854 if self.curr_speed != other.curr_speed: return False
855 if self.max_speed != other.max_speed: return False
856 return True
857
Rich Lanec2ee4b82013-04-24 17:12:38 -0700858 def pretty_print(self, q):
859 q.text("port_desc {")
860 with q.group():
861 with q.indent(2):
862 q.breakable()
863 q.text("port_no = ");
864 q.text(util.pretty_port(self.port_no))
865 q.text(","); q.breakable()
866 q.text("hw_addr = ");
867 q.text(util.pretty_mac(self.hw_addr))
868 q.text(","); q.breakable()
869 q.text("name = ");
870 q.pp(self.name)
871 q.text(","); q.breakable()
872 q.text("config = ");
873 q.text("%#x" % self.config)
874 q.text(","); q.breakable()
875 q.text("state = ");
876 q.text("%#x" % self.state)
877 q.text(","); q.breakable()
878 q.text("curr = ");
879 q.text("%#x" % self.curr)
880 q.text(","); q.breakable()
881 q.text("advertised = ");
882 q.text("%#x" % self.advertised)
883 q.text(","); q.breakable()
884 q.text("supported = ");
885 q.text("%#x" % self.supported)
886 q.text(","); q.breakable()
887 q.text("peer = ");
888 q.text("%#x" % self.peer)
889 q.text(","); q.breakable()
890 q.text("curr_speed = ");
891 q.text("%#x" % self.curr_speed)
892 q.text(","); q.breakable()
893 q.text("max_speed = ");
894 q.text("%#x" % self.max_speed)
895 q.breakable()
896 q.text('}')
897
Rich Lane7dcdf022013-12-11 14:45:27 -0800898
899class port_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700900
901 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):
902 if port_no != None:
903 self.port_no = port_no
904 else:
905 self.port_no = 0
906 if rx_packets != None:
907 self.rx_packets = rx_packets
908 else:
909 self.rx_packets = 0
910 if tx_packets != None:
911 self.tx_packets = tx_packets
912 else:
913 self.tx_packets = 0
914 if rx_bytes != None:
915 self.rx_bytes = rx_bytes
916 else:
917 self.rx_bytes = 0
918 if tx_bytes != None:
919 self.tx_bytes = tx_bytes
920 else:
921 self.tx_bytes = 0
922 if rx_dropped != None:
923 self.rx_dropped = rx_dropped
924 else:
925 self.rx_dropped = 0
926 if tx_dropped != None:
927 self.tx_dropped = tx_dropped
928 else:
929 self.tx_dropped = 0
930 if rx_errors != None:
931 self.rx_errors = rx_errors
932 else:
933 self.rx_errors = 0
934 if tx_errors != None:
935 self.tx_errors = tx_errors
936 else:
937 self.tx_errors = 0
938 if rx_frame_err != None:
939 self.rx_frame_err = rx_frame_err
940 else:
941 self.rx_frame_err = 0
942 if rx_over_err != None:
943 self.rx_over_err = rx_over_err
944 else:
945 self.rx_over_err = 0
946 if rx_crc_err != None:
947 self.rx_crc_err = rx_crc_err
948 else:
949 self.rx_crc_err = 0
950 if collisions != None:
951 self.collisions = collisions
952 else:
953 self.collisions = 0
954 return
955
956 def pack(self):
957 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -0700958 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700959 packed.append('\x00' * 4)
960 packed.append(struct.pack("!Q", self.rx_packets))
961 packed.append(struct.pack("!Q", self.tx_packets))
962 packed.append(struct.pack("!Q", self.rx_bytes))
963 packed.append(struct.pack("!Q", self.tx_bytes))
964 packed.append(struct.pack("!Q", self.rx_dropped))
965 packed.append(struct.pack("!Q", self.tx_dropped))
966 packed.append(struct.pack("!Q", self.rx_errors))
967 packed.append(struct.pack("!Q", self.tx_errors))
968 packed.append(struct.pack("!Q", self.rx_frame_err))
969 packed.append(struct.pack("!Q", self.rx_over_err))
970 packed.append(struct.pack("!Q", self.rx_crc_err))
971 packed.append(struct.pack("!Q", self.collisions))
972 return ''.join(packed)
973
974 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800975 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700976 obj = port_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -0700977 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700978 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -0700979 obj.rx_packets = reader.read("!Q")[0]
980 obj.tx_packets = reader.read("!Q")[0]
981 obj.rx_bytes = reader.read("!Q")[0]
982 obj.tx_bytes = reader.read("!Q")[0]
983 obj.rx_dropped = reader.read("!Q")[0]
984 obj.tx_dropped = reader.read("!Q")[0]
985 obj.rx_errors = reader.read("!Q")[0]
986 obj.tx_errors = reader.read("!Q")[0]
987 obj.rx_frame_err = reader.read("!Q")[0]
988 obj.rx_over_err = reader.read("!Q")[0]
989 obj.rx_crc_err = reader.read("!Q")[0]
990 obj.collisions = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700991 return obj
992
993 def __eq__(self, other):
994 if type(self) != type(other): return False
995 if self.port_no != other.port_no: return False
996 if self.rx_packets != other.rx_packets: return False
997 if self.tx_packets != other.tx_packets: return False
998 if self.rx_bytes != other.rx_bytes: return False
999 if self.tx_bytes != other.tx_bytes: return False
1000 if self.rx_dropped != other.rx_dropped: return False
1001 if self.tx_dropped != other.tx_dropped: return False
1002 if self.rx_errors != other.rx_errors: return False
1003 if self.tx_errors != other.tx_errors: return False
1004 if self.rx_frame_err != other.rx_frame_err: return False
1005 if self.rx_over_err != other.rx_over_err: return False
1006 if self.rx_crc_err != other.rx_crc_err: return False
1007 if self.collisions != other.collisions: return False
1008 return True
1009
Rich Lanec2ee4b82013-04-24 17:12:38 -07001010 def pretty_print(self, q):
1011 q.text("port_stats_entry {")
1012 with q.group():
1013 with q.indent(2):
1014 q.breakable()
1015 q.text("port_no = ");
1016 q.text(util.pretty_port(self.port_no))
1017 q.text(","); q.breakable()
1018 q.text("rx_packets = ");
1019 q.text("%#x" % self.rx_packets)
1020 q.text(","); q.breakable()
1021 q.text("tx_packets = ");
1022 q.text("%#x" % self.tx_packets)
1023 q.text(","); q.breakable()
1024 q.text("rx_bytes = ");
1025 q.text("%#x" % self.rx_bytes)
1026 q.text(","); q.breakable()
1027 q.text("tx_bytes = ");
1028 q.text("%#x" % self.tx_bytes)
1029 q.text(","); q.breakable()
1030 q.text("rx_dropped = ");
1031 q.text("%#x" % self.rx_dropped)
1032 q.text(","); q.breakable()
1033 q.text("tx_dropped = ");
1034 q.text("%#x" % self.tx_dropped)
1035 q.text(","); q.breakable()
1036 q.text("rx_errors = ");
1037 q.text("%#x" % self.rx_errors)
1038 q.text(","); q.breakable()
1039 q.text("tx_errors = ");
1040 q.text("%#x" % self.tx_errors)
1041 q.text(","); q.breakable()
1042 q.text("rx_frame_err = ");
1043 q.text("%#x" % self.rx_frame_err)
1044 q.text(","); q.breakable()
1045 q.text("rx_over_err = ");
1046 q.text("%#x" % self.rx_over_err)
1047 q.text(","); q.breakable()
1048 q.text("rx_crc_err = ");
1049 q.text("%#x" % self.rx_crc_err)
1050 q.text(","); q.breakable()
1051 q.text("collisions = ");
1052 q.text("%#x" % self.collisions)
1053 q.breakable()
1054 q.text('}')
1055
Rich Lane7dcdf022013-12-11 14:45:27 -08001056
1057class queue_prop(loxi.OFObject):
1058 subtypes = {}
1059
Rich Lane95f7fc92014-01-27 17:08:16 -08001060
1061 def __init__(self, type=None):
1062 if type != None:
1063 self.type = type
1064 else:
1065 self.type = 0
1066 return
1067
1068 def pack(self):
1069 packed = []
1070 packed.append(struct.pack("!H", self.type))
1071 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1072 packed.append('\x00' * 4)
1073 length = sum([len(x) for x in packed])
1074 packed[1] = struct.pack("!H", length)
1075 return ''.join(packed)
1076
Rich Lane7dcdf022013-12-11 14:45:27 -08001077 @staticmethod
1078 def unpack(reader):
1079 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -08001080 subclass = queue_prop.subtypes.get(subtype)
1081 if subclass:
1082 return subclass.unpack(reader)
1083
1084 obj = queue_prop()
1085 obj.type = reader.read("!H")[0]
1086 _len = reader.read("!H")[0]
1087 orig_reader = reader
1088 reader = orig_reader.slice(_len - (2 + 2))
1089 reader.skip(4)
1090 return obj
1091
1092 def __eq__(self, other):
1093 if type(self) != type(other): return False
1094 if self.type != other.type: return False
1095 return True
1096
1097 def pretty_print(self, q):
1098 q.text("queue_prop {")
1099 with q.group():
1100 with q.indent(2):
1101 q.breakable()
1102 q.breakable()
1103 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08001104
1105
1106class queue_prop_experimenter(queue_prop):
1107 subtypes = {}
1108
Rich Lane95f7fc92014-01-27 17:08:16 -08001109 type = 65535
1110
1111 def __init__(self, experimenter=None, data=None):
1112 if experimenter != None:
1113 self.experimenter = experimenter
1114 else:
1115 self.experimenter = 0
1116 if data != None:
1117 self.data = data
1118 else:
1119 self.data = ''
1120 return
1121
1122 def pack(self):
1123 packed = []
1124 packed.append(struct.pack("!H", self.type))
1125 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1126 packed.append('\x00' * 4)
1127 packed.append(struct.pack("!L", self.experimenter))
1128 packed.append('\x00' * 4)
1129 packed.append(self.data)
1130 length = sum([len(x) for x in packed])
1131 packed[1] = struct.pack("!H", length)
1132 return ''.join(packed)
1133
Rich Lane7dcdf022013-12-11 14:45:27 -08001134 @staticmethod
1135 def unpack(reader):
1136 subtype, = reader.peek('!L', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -08001137 subclass = queue_prop_experimenter.subtypes.get(subtype)
1138 if subclass:
1139 return subclass.unpack(reader)
1140
1141 obj = queue_prop_experimenter()
1142 _type = reader.read("!H")[0]
1143 assert(_type == 65535)
1144 _len = reader.read("!H")[0]
1145 orig_reader = reader
1146 reader = orig_reader.slice(_len - (2 + 2))
1147 reader.skip(4)
1148 obj.experimenter = reader.read("!L")[0]
1149 reader.skip(4)
1150 obj.data = str(reader.read_all())
1151 return obj
1152
1153 def __eq__(self, other):
1154 if type(self) != type(other): return False
1155 if self.experimenter != other.experimenter: return False
1156 if self.data != other.data: return False
1157 return True
1158
1159 def pretty_print(self, q):
1160 q.text("queue_prop_experimenter {")
1161 with q.group():
1162 with q.indent(2):
1163 q.breakable()
1164 q.text("data = ");
1165 q.pp(self.data)
1166 q.breakable()
1167 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -08001168
1169queue_prop.subtypes[65535] = queue_prop_experimenter
1170
1171class queue_prop_max_rate(queue_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07001172 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07001173
1174 def __init__(self, rate=None):
1175 if rate != None:
1176 self.rate = rate
1177 else:
1178 self.rate = 0
1179 return
1180
1181 def pack(self):
1182 packed = []
1183 packed.append(struct.pack("!H", self.type))
1184 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1185 packed.append('\x00' * 4)
1186 packed.append(struct.pack("!H", self.rate))
1187 packed.append('\x00' * 6)
1188 length = sum([len(x) for x in packed])
1189 packed[1] = struct.pack("!H", length)
1190 return ''.join(packed)
1191
1192 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001193 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001194 obj = queue_prop_max_rate()
Dan Talaycof6202252013-07-02 01:00:29 -07001195 _type = reader.read("!H")[0]
1196 assert(_type == 2)
1197 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001198 orig_reader = reader
1199 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001200 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001201 obj.rate = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001202 reader.skip(6)
1203 return obj
1204
1205 def __eq__(self, other):
1206 if type(self) != type(other): return False
1207 if self.rate != other.rate: return False
1208 return True
1209
Rich Lanec2ee4b82013-04-24 17:12:38 -07001210 def pretty_print(self, q):
1211 q.text("queue_prop_max_rate {")
1212 with q.group():
1213 with q.indent(2):
1214 q.breakable()
1215 q.text("rate = ");
1216 q.text("%#x" % self.rate)
1217 q.breakable()
1218 q.text('}')
1219
Rich Lane7dcdf022013-12-11 14:45:27 -08001220queue_prop.subtypes[2] = queue_prop_max_rate
1221
1222class queue_prop_min_rate(queue_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07001223 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07001224
1225 def __init__(self, rate=None):
1226 if rate != None:
1227 self.rate = rate
1228 else:
1229 self.rate = 0
1230 return
1231
1232 def pack(self):
1233 packed = []
1234 packed.append(struct.pack("!H", self.type))
1235 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1236 packed.append('\x00' * 4)
1237 packed.append(struct.pack("!H", self.rate))
1238 packed.append('\x00' * 6)
1239 length = sum([len(x) for x in packed])
1240 packed[1] = struct.pack("!H", length)
1241 return ''.join(packed)
1242
1243 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001244 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001245 obj = queue_prop_min_rate()
Dan Talaycof6202252013-07-02 01:00:29 -07001246 _type = reader.read("!H")[0]
1247 assert(_type == 1)
1248 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001249 orig_reader = reader
1250 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001251 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001252 obj.rate = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001253 reader.skip(6)
1254 return obj
1255
1256 def __eq__(self, other):
1257 if type(self) != type(other): return False
1258 if self.rate != other.rate: return False
1259 return True
1260
Rich Lanec2ee4b82013-04-24 17:12:38 -07001261 def pretty_print(self, q):
1262 q.text("queue_prop_min_rate {")
1263 with q.group():
1264 with q.indent(2):
1265 q.breakable()
1266 q.text("rate = ");
1267 q.text("%#x" % self.rate)
1268 q.breakable()
1269 q.text('}')
1270
Rich Lane7dcdf022013-12-11 14:45:27 -08001271queue_prop.subtypes[1] = queue_prop_min_rate
1272
1273class queue_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001274
1275 def __init__(self, port_no=None, queue_id=None, tx_bytes=None, tx_packets=None, tx_errors=None):
1276 if port_no != None:
1277 self.port_no = port_no
1278 else:
1279 self.port_no = 0
1280 if queue_id != None:
1281 self.queue_id = queue_id
1282 else:
1283 self.queue_id = 0
1284 if tx_bytes != None:
1285 self.tx_bytes = tx_bytes
1286 else:
1287 self.tx_bytes = 0
1288 if tx_packets != None:
1289 self.tx_packets = tx_packets
1290 else:
1291 self.tx_packets = 0
1292 if tx_errors != None:
1293 self.tx_errors = tx_errors
1294 else:
1295 self.tx_errors = 0
1296 return
1297
1298 def pack(self):
1299 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07001300 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001301 packed.append(struct.pack("!L", self.queue_id))
1302 packed.append(struct.pack("!Q", self.tx_bytes))
1303 packed.append(struct.pack("!Q", self.tx_packets))
1304 packed.append(struct.pack("!Q", self.tx_errors))
1305 return ''.join(packed)
1306
1307 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001308 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001309 obj = queue_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001310 obj.port_no = util.unpack_port_no(reader)
1311 obj.queue_id = reader.read("!L")[0]
1312 obj.tx_bytes = reader.read("!Q")[0]
1313 obj.tx_packets = reader.read("!Q")[0]
1314 obj.tx_errors = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001315 return obj
1316
1317 def __eq__(self, other):
1318 if type(self) != type(other): return False
1319 if self.port_no != other.port_no: return False
1320 if self.queue_id != other.queue_id: return False
1321 if self.tx_bytes != other.tx_bytes: return False
1322 if self.tx_packets != other.tx_packets: return False
1323 if self.tx_errors != other.tx_errors: return False
1324 return True
1325
Rich Lanec2ee4b82013-04-24 17:12:38 -07001326 def pretty_print(self, q):
1327 q.text("queue_stats_entry {")
1328 with q.group():
1329 with q.indent(2):
1330 q.breakable()
1331 q.text("port_no = ");
1332 q.text(util.pretty_port(self.port_no))
1333 q.text(","); q.breakable()
1334 q.text("queue_id = ");
1335 q.text("%#x" % self.queue_id)
1336 q.text(","); q.breakable()
1337 q.text("tx_bytes = ");
1338 q.text("%#x" % self.tx_bytes)
1339 q.text(","); q.breakable()
1340 q.text("tx_packets = ");
1341 q.text("%#x" % self.tx_packets)
1342 q.text(","); q.breakable()
1343 q.text("tx_errors = ");
1344 q.text("%#x" % self.tx_errors)
1345 q.breakable()
1346 q.text('}')
1347
Rich Lane7dcdf022013-12-11 14:45:27 -08001348
1349class table_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001350
1351 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):
1352 if table_id != None:
1353 self.table_id = table_id
1354 else:
1355 self.table_id = 0
1356 if name != None:
1357 self.name = name
1358 else:
1359 self.name = ""
1360 if match != None:
1361 self.match = match
1362 else:
Dan Talaycof6202252013-07-02 01:00:29 -07001363 self.match = util.init_match_bmap()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001364 if wildcards != None:
1365 self.wildcards = wildcards
1366 else:
Dan Talaycof6202252013-07-02 01:00:29 -07001367 self.wildcards = util.init_wc_bmap()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001368 if write_actions != None:
1369 self.write_actions = write_actions
1370 else:
1371 self.write_actions = 0
1372 if apply_actions != None:
1373 self.apply_actions = apply_actions
1374 else:
1375 self.apply_actions = 0
1376 if write_setfields != None:
1377 self.write_setfields = write_setfields
1378 else:
1379 self.write_setfields = 0
1380 if apply_setfields != None:
1381 self.apply_setfields = apply_setfields
1382 else:
1383 self.apply_setfields = 0
1384 if metadata_match != None:
1385 self.metadata_match = metadata_match
1386 else:
1387 self.metadata_match = 0
1388 if metadata_write != None:
1389 self.metadata_write = metadata_write
1390 else:
1391 self.metadata_write = 0
1392 if instructions != None:
1393 self.instructions = instructions
1394 else:
1395 self.instructions = 0
1396 if config != None:
1397 self.config = config
1398 else:
1399 self.config = 0
1400 if max_entries != None:
1401 self.max_entries = max_entries
1402 else:
1403 self.max_entries = 0
1404 if active_count != None:
1405 self.active_count = active_count
1406 else:
1407 self.active_count = 0
1408 if lookup_count != None:
1409 self.lookup_count = lookup_count
1410 else:
1411 self.lookup_count = 0
1412 if matched_count != None:
1413 self.matched_count = matched_count
1414 else:
1415 self.matched_count = 0
1416 return
1417
1418 def pack(self):
1419 packed = []
1420 packed.append(struct.pack("!B", self.table_id))
1421 packed.append('\x00' * 7)
1422 packed.append(struct.pack("!32s", self.name))
Dan Talaycof6202252013-07-02 01:00:29 -07001423 packed.append(util.pack_match_bmap(self.match))
1424 packed.append(util.pack_wc_bmap(self.wildcards))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001425 packed.append(struct.pack("!L", self.write_actions))
1426 packed.append(struct.pack("!L", self.apply_actions))
1427 packed.append(struct.pack("!Q", self.write_setfields))
1428 packed.append(struct.pack("!Q", self.apply_setfields))
1429 packed.append(struct.pack("!Q", self.metadata_match))
1430 packed.append(struct.pack("!Q", self.metadata_write))
1431 packed.append(struct.pack("!L", self.instructions))
1432 packed.append(struct.pack("!L", self.config))
1433 packed.append(struct.pack("!L", self.max_entries))
1434 packed.append(struct.pack("!L", self.active_count))
1435 packed.append(struct.pack("!Q", self.lookup_count))
1436 packed.append(struct.pack("!Q", self.matched_count))
1437 return ''.join(packed)
1438
1439 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001440 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001441 obj = table_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001442 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001443 reader.skip(7)
1444 obj.name = reader.read("!32s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -07001445 obj.match = util.unpack_match_bmap(reader)
1446 obj.wildcards = util.unpack_wc_bmap(reader)
1447 obj.write_actions = reader.read("!L")[0]
1448 obj.apply_actions = reader.read("!L")[0]
1449 obj.write_setfields = reader.read("!Q")[0]
1450 obj.apply_setfields = reader.read("!Q")[0]
1451 obj.metadata_match = reader.read("!Q")[0]
1452 obj.metadata_write = reader.read("!Q")[0]
1453 obj.instructions = reader.read("!L")[0]
1454 obj.config = reader.read("!L")[0]
1455 obj.max_entries = reader.read("!L")[0]
1456 obj.active_count = reader.read("!L")[0]
1457 obj.lookup_count = reader.read("!Q")[0]
1458 obj.matched_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001459 return obj
1460
1461 def __eq__(self, other):
1462 if type(self) != type(other): return False
1463 if self.table_id != other.table_id: return False
1464 if self.name != other.name: return False
1465 if self.match != other.match: return False
1466 if self.wildcards != other.wildcards: return False
1467 if self.write_actions != other.write_actions: return False
1468 if self.apply_actions != other.apply_actions: return False
1469 if self.write_setfields != other.write_setfields: return False
1470 if self.apply_setfields != other.apply_setfields: return False
1471 if self.metadata_match != other.metadata_match: return False
1472 if self.metadata_write != other.metadata_write: return False
1473 if self.instructions != other.instructions: return False
1474 if self.config != other.config: return False
1475 if self.max_entries != other.max_entries: return False
1476 if self.active_count != other.active_count: return False
1477 if self.lookup_count != other.lookup_count: return False
1478 if self.matched_count != other.matched_count: return False
1479 return True
1480
Rich Lanec2ee4b82013-04-24 17:12:38 -07001481 def pretty_print(self, q):
1482 q.text("table_stats_entry {")
1483 with q.group():
1484 with q.indent(2):
1485 q.breakable()
1486 q.text("table_id = ");
1487 q.text("%#x" % self.table_id)
1488 q.text(","); q.breakable()
1489 q.text("name = ");
1490 q.pp(self.name)
1491 q.text(","); q.breakable()
1492 q.text("match = ");
1493 q.pp(self.match)
1494 q.text(","); q.breakable()
1495 q.text("wildcards = ");
1496 q.pp(self.wildcards)
1497 q.text(","); q.breakable()
1498 q.text("write_actions = ");
1499 q.text("%#x" % self.write_actions)
1500 q.text(","); q.breakable()
1501 q.text("apply_actions = ");
1502 q.text("%#x" % self.apply_actions)
1503 q.text(","); q.breakable()
1504 q.text("write_setfields = ");
1505 q.text("%#x" % self.write_setfields)
1506 q.text(","); q.breakable()
1507 q.text("apply_setfields = ");
1508 q.text("%#x" % self.apply_setfields)
1509 q.text(","); q.breakable()
1510 q.text("metadata_match = ");
1511 q.text("%#x" % self.metadata_match)
1512 q.text(","); q.breakable()
1513 q.text("metadata_write = ");
1514 q.text("%#x" % self.metadata_write)
1515 q.text(","); q.breakable()
1516 q.text("instructions = ");
1517 q.text("%#x" % self.instructions)
1518 q.text(","); q.breakable()
1519 q.text("config = ");
1520 q.text("%#x" % self.config)
1521 q.text(","); q.breakable()
1522 q.text("max_entries = ");
1523 q.text("%#x" % self.max_entries)
1524 q.text(","); q.breakable()
1525 q.text("active_count = ");
1526 q.text("%#x" % self.active_count)
1527 q.text(","); q.breakable()
1528 q.text("lookup_count = ");
1529 q.text("%#x" % self.lookup_count)
1530 q.text(","); q.breakable()
1531 q.text("matched_count = ");
1532 q.text("%#x" % self.matched_count)
1533 q.breakable()
1534 q.text('}')
1535
1536
Rich Lane7dcdf022013-12-11 14:45:27 -08001537
Rich Lanec2ee4b82013-04-24 17:12:38 -07001538match = match_v3