blob: 8d86467b586ef72246160b790cce07b17282c48c [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
16import action_id
17import instruction_id
18import meter_band
Rich Lanec2ee4b82013-04-24 17:12:38 -070019import util
20import loxi.generic_util
21
Rich Lane7dcdf022013-12-11 14:45:27 -080022class bsn_interface(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -070023
24 def __init__(self, hw_addr=None, name=None, ipv4_addr=None, ipv4_netmask=None):
25 if hw_addr != None:
26 self.hw_addr = hw_addr
27 else:
28 self.hw_addr = [0,0,0,0,0,0]
29 if name != None:
30 self.name = name
31 else:
32 self.name = ""
33 if ipv4_addr != None:
34 self.ipv4_addr = ipv4_addr
35 else:
36 self.ipv4_addr = 0
37 if ipv4_netmask != None:
38 self.ipv4_netmask = ipv4_netmask
39 else:
40 self.ipv4_netmask = 0
41 return
42
43 def pack(self):
44 packed = []
45 packed.append(struct.pack("!6B", *self.hw_addr))
46 packed.append('\x00' * 2)
47 packed.append(struct.pack("!16s", self.name))
48 packed.append(struct.pack("!L", self.ipv4_addr))
49 packed.append(struct.pack("!L", self.ipv4_netmask))
50 return ''.join(packed)
51
52 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -080053 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -070054 obj = bsn_interface()
Rich Lanec2ee4b82013-04-24 17:12:38 -070055 obj.hw_addr = list(reader.read('!6B'))
56 reader.skip(2)
57 obj.name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -070058 obj.ipv4_addr = reader.read("!L")[0]
59 obj.ipv4_netmask = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -070060 return obj
61
62 def __eq__(self, other):
63 if type(self) != type(other): return False
64 if self.hw_addr != other.hw_addr: return False
65 if self.name != other.name: return False
66 if self.ipv4_addr != other.ipv4_addr: return False
67 if self.ipv4_netmask != other.ipv4_netmask: return False
68 return True
69
Rich Lanec2ee4b82013-04-24 17:12:38 -070070 def pretty_print(self, q):
71 q.text("bsn_interface {")
72 with q.group():
73 with q.indent(2):
74 q.breakable()
75 q.text("hw_addr = ");
76 q.text(util.pretty_mac(self.hw_addr))
77 q.text(","); q.breakable()
78 q.text("name = ");
79 q.pp(self.name)
80 q.text(","); q.breakable()
81 q.text("ipv4_addr = ");
82 q.text(util.pretty_ipv4(self.ipv4_addr))
83 q.text(","); q.breakable()
84 q.text("ipv4_netmask = ");
85 q.text(util.pretty_ipv4(self.ipv4_netmask))
86 q.breakable()
87 q.text('}')
88
Rich Lane7dcdf022013-12-11 14:45:27 -080089
90class bsn_lacp_stats_entry(loxi.OFObject):
Rich Lane7b0f2012013-11-22 14:15:26 -080091
92 def __init__(self, port_no=None, actor_sys_priority=None, actor_sys_mac=None, actor_port_priority=None, actor_port_num=None, actor_key=None, convergence_status=None, partner_sys_priority=None, partner_sys_mac=None, partner_port_priority=None, partner_port_num=None, partner_key=None):
93 if port_no != None:
94 self.port_no = port_no
95 else:
96 self.port_no = 0
97 if actor_sys_priority != None:
98 self.actor_sys_priority = actor_sys_priority
99 else:
100 self.actor_sys_priority = 0
101 if actor_sys_mac != None:
102 self.actor_sys_mac = actor_sys_mac
103 else:
104 self.actor_sys_mac = [0,0,0,0,0,0]
105 if actor_port_priority != None:
106 self.actor_port_priority = actor_port_priority
107 else:
108 self.actor_port_priority = 0
109 if actor_port_num != None:
110 self.actor_port_num = actor_port_num
111 else:
112 self.actor_port_num = 0
113 if actor_key != None:
114 self.actor_key = actor_key
115 else:
116 self.actor_key = 0
117 if convergence_status != None:
118 self.convergence_status = convergence_status
119 else:
120 self.convergence_status = 0
121 if partner_sys_priority != None:
122 self.partner_sys_priority = partner_sys_priority
123 else:
124 self.partner_sys_priority = 0
125 if partner_sys_mac != None:
126 self.partner_sys_mac = partner_sys_mac
127 else:
128 self.partner_sys_mac = [0,0,0,0,0,0]
129 if partner_port_priority != None:
130 self.partner_port_priority = partner_port_priority
131 else:
132 self.partner_port_priority = 0
133 if partner_port_num != None:
134 self.partner_port_num = partner_port_num
135 else:
136 self.partner_port_num = 0
137 if partner_key != None:
138 self.partner_key = partner_key
139 else:
140 self.partner_key = 0
141 return
142
143 def pack(self):
144 packed = []
145 packed.append(util.pack_port_no(self.port_no))
146 packed.append(struct.pack("!H", self.actor_sys_priority))
147 packed.append(struct.pack("!6B", *self.actor_sys_mac))
148 packed.append(struct.pack("!H", self.actor_port_priority))
149 packed.append(struct.pack("!H", self.actor_port_num))
150 packed.append(struct.pack("!H", self.actor_key))
151 packed.append(struct.pack("!B", self.convergence_status))
152 packed.append('\x00' * 1)
153 packed.append(struct.pack("!H", self.partner_sys_priority))
154 packed.append(struct.pack("!6B", *self.partner_sys_mac))
155 packed.append(struct.pack("!H", self.partner_port_priority))
156 packed.append(struct.pack("!H", self.partner_port_num))
157 packed.append(struct.pack("!H", self.partner_key))
158 packed.append('\x00' * 2)
159 return ''.join(packed)
160
161 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800162 def unpack(reader):
Rich Lane7b0f2012013-11-22 14:15:26 -0800163 obj = bsn_lacp_stats_entry()
Rich Lane7b0f2012013-11-22 14:15:26 -0800164 obj.port_no = util.unpack_port_no(reader)
165 obj.actor_sys_priority = reader.read("!H")[0]
166 obj.actor_sys_mac = list(reader.read('!6B'))
167 obj.actor_port_priority = reader.read("!H")[0]
168 obj.actor_port_num = reader.read("!H")[0]
169 obj.actor_key = reader.read("!H")[0]
170 obj.convergence_status = reader.read("!B")[0]
171 reader.skip(1)
172 obj.partner_sys_priority = reader.read("!H")[0]
173 obj.partner_sys_mac = list(reader.read('!6B'))
174 obj.partner_port_priority = reader.read("!H")[0]
175 obj.partner_port_num = reader.read("!H")[0]
176 obj.partner_key = reader.read("!H")[0]
177 reader.skip(2)
178 return obj
179
180 def __eq__(self, other):
181 if type(self) != type(other): return False
182 if self.port_no != other.port_no: return False
183 if self.actor_sys_priority != other.actor_sys_priority: return False
184 if self.actor_sys_mac != other.actor_sys_mac: return False
185 if self.actor_port_priority != other.actor_port_priority: return False
186 if self.actor_port_num != other.actor_port_num: return False
187 if self.actor_key != other.actor_key: return False
188 if self.convergence_status != other.convergence_status: return False
189 if self.partner_sys_priority != other.partner_sys_priority: return False
190 if self.partner_sys_mac != other.partner_sys_mac: return False
191 if self.partner_port_priority != other.partner_port_priority: return False
192 if self.partner_port_num != other.partner_port_num: return False
193 if self.partner_key != other.partner_key: return False
194 return True
195
Rich Lane7b0f2012013-11-22 14:15:26 -0800196 def pretty_print(self, q):
197 q.text("bsn_lacp_stats_entry {")
198 with q.group():
199 with q.indent(2):
200 q.breakable()
201 q.text("port_no = ");
202 q.text(util.pretty_port(self.port_no))
203 q.text(","); q.breakable()
204 q.text("actor_sys_priority = ");
205 q.text("%#x" % self.actor_sys_priority)
206 q.text(","); q.breakable()
207 q.text("actor_sys_mac = ");
208 q.text(util.pretty_mac(self.actor_sys_mac))
209 q.text(","); q.breakable()
210 q.text("actor_port_priority = ");
211 q.text("%#x" % self.actor_port_priority)
212 q.text(","); q.breakable()
213 q.text("actor_port_num = ");
214 q.text("%#x" % self.actor_port_num)
215 q.text(","); q.breakable()
216 q.text("actor_key = ");
217 q.text("%#x" % self.actor_key)
218 q.text(","); q.breakable()
219 q.text("convergence_status = ");
220 q.text("%#x" % self.convergence_status)
221 q.text(","); q.breakable()
222 q.text("partner_sys_priority = ");
223 q.text("%#x" % self.partner_sys_priority)
224 q.text(","); q.breakable()
225 q.text("partner_sys_mac = ");
226 q.text(util.pretty_mac(self.partner_sys_mac))
227 q.text(","); q.breakable()
228 q.text("partner_port_priority = ");
229 q.text("%#x" % self.partner_port_priority)
230 q.text(","); q.breakable()
231 q.text("partner_port_num = ");
232 q.text("%#x" % self.partner_port_num)
233 q.text(","); q.breakable()
234 q.text("partner_key = ");
235 q.text("%#x" % self.partner_key)
236 q.breakable()
237 q.text('}')
238
Rich Lane7dcdf022013-12-11 14:45:27 -0800239
240class bsn_port_counter_stats_entry(loxi.OFObject):
241
242 def __init__(self, port_no=None, values=None):
243 if port_no != None:
244 self.port_no = port_no
245 else:
246 self.port_no = 0
247 if values != None:
248 self.values = values
249 else:
250 self.values = []
251 return
252
253 def pack(self):
254 packed = []
255 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
256 packed.append('\x00' * 2)
257 packed.append(util.pack_port_no(self.port_no))
258 packed.append(loxi.generic_util.pack_list(self.values))
259 length = sum([len(x) for x in packed])
260 packed[0] = struct.pack("!H", length)
261 return ''.join(packed)
262
263 @staticmethod
264 def unpack(reader):
265 obj = bsn_port_counter_stats_entry()
266 _length = reader.read("!H")[0]
267 orig_reader = reader
268 reader = orig_reader.slice(_length - (0 + 2))
269 reader.skip(2)
270 obj.port_no = util.unpack_port_no(reader)
271 obj.values = loxi.generic_util.unpack_list(reader, common.uint64.unpack)
272 return obj
273
274 def __eq__(self, other):
275 if type(self) != type(other): return False
276 if self.port_no != other.port_no: return False
277 if self.values != other.values: return False
278 return True
279
280 def pretty_print(self, q):
281 q.text("bsn_port_counter_stats_entry {")
282 with q.group():
283 with q.indent(2):
284 q.breakable()
285 q.text("port_no = ");
286 q.text(util.pretty_port(self.port_no))
287 q.text(","); q.breakable()
288 q.text("values = ");
289 q.pp(self.values)
290 q.breakable()
291 q.text('}')
292
293
294class bsn_switch_pipeline_stats_entry(loxi.OFObject):
295
296 def __init__(self, pipeline=None):
297 if pipeline != None:
298 self.pipeline = pipeline
299 else:
300 self.pipeline = ""
301 return
302
303 def pack(self):
304 packed = []
305 packed.append(struct.pack("!256s", self.pipeline))
306 return ''.join(packed)
307
308 @staticmethod
309 def unpack(reader):
310 obj = bsn_switch_pipeline_stats_entry()
311 obj.pipeline = reader.read("!256s")[0].rstrip("\x00")
312 return obj
313
314 def __eq__(self, other):
315 if type(self) != type(other): return False
316 if self.pipeline != other.pipeline: return False
317 return True
318
319 def pretty_print(self, q):
320 q.text("bsn_switch_pipeline_stats_entry {")
321 with q.group():
322 with q.indent(2):
323 q.breakable()
324 q.text("pipeline = ");
325 q.pp(self.pipeline)
326 q.breakable()
327 q.text('}')
328
329
330class bsn_vport(loxi.OFObject):
331 subtypes = {}
332
333 @staticmethod
334 def unpack(reader):
335 subtype, = reader.peek('!H', 0)
336 try:
337 subclass = bsn_vport.subtypes[subtype]
338 except KeyError:
339 raise loxi.ProtocolError("unknown bsn_vport subtype %#x" % subtype)
340 return subclass.unpack(reader)
341
342
343class bsn_vport_q_in_q(bsn_vport):
Dan Talaycof6202252013-07-02 01:00:29 -0700344 type = 0
345
Kiran Poola150d8b02013-09-20 13:30:39 -0700346 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 -0700347 if port_no != None:
348 self.port_no = port_no
349 else:
350 self.port_no = 0
351 if ingress_tpid != None:
352 self.ingress_tpid = ingress_tpid
353 else:
354 self.ingress_tpid = 0
355 if ingress_vlan_id != None:
356 self.ingress_vlan_id = ingress_vlan_id
357 else:
358 self.ingress_vlan_id = 0
359 if egress_tpid != None:
360 self.egress_tpid = egress_tpid
361 else:
362 self.egress_tpid = 0
363 if egress_vlan_id != None:
364 self.egress_vlan_id = egress_vlan_id
365 else:
366 self.egress_vlan_id = 0
Kiran Poola150d8b02013-09-20 13:30:39 -0700367 if if_name != None:
368 self.if_name = if_name
369 else:
370 self.if_name = ""
Dan Talaycof6202252013-07-02 01:00:29 -0700371 return
372
373 def pack(self):
374 packed = []
375 packed.append(struct.pack("!H", self.type))
Kiran Poola150d8b02013-09-20 13:30:39 -0700376 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700377 packed.append(struct.pack("!L", self.port_no))
378 packed.append(struct.pack("!H", self.ingress_tpid))
379 packed.append(struct.pack("!H", self.ingress_vlan_id))
380 packed.append(struct.pack("!H", self.egress_tpid))
381 packed.append(struct.pack("!H", self.egress_vlan_id))
Kiran Poola150d8b02013-09-20 13:30:39 -0700382 packed.append(struct.pack("!16s", self.if_name))
Dan Talaycof6202252013-07-02 01:00:29 -0700383 length = sum([len(x) for x in packed])
Kiran Poola150d8b02013-09-20 13:30:39 -0700384 packed[1] = struct.pack("!H", length)
Dan Talaycof6202252013-07-02 01:00:29 -0700385 return ''.join(packed)
386
387 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800388 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -0700389 obj = bsn_vport_q_in_q()
Dan Talaycof6202252013-07-02 01:00:29 -0700390 _type = reader.read("!H")[0]
391 assert(_type == 0)
392 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800393 orig_reader = reader
394 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700395 obj.port_no = reader.read("!L")[0]
396 obj.ingress_tpid = reader.read("!H")[0]
397 obj.ingress_vlan_id = reader.read("!H")[0]
398 obj.egress_tpid = reader.read("!H")[0]
399 obj.egress_vlan_id = reader.read("!H")[0]
Kiran Poola150d8b02013-09-20 13:30:39 -0700400 obj.if_name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -0700401 return obj
402
403 def __eq__(self, other):
404 if type(self) != type(other): return False
405 if self.port_no != other.port_no: return False
406 if self.ingress_tpid != other.ingress_tpid: return False
407 if self.ingress_vlan_id != other.ingress_vlan_id: return False
408 if self.egress_tpid != other.egress_tpid: return False
409 if self.egress_vlan_id != other.egress_vlan_id: return False
Kiran Poola150d8b02013-09-20 13:30:39 -0700410 if self.if_name != other.if_name: return False
Dan Talaycof6202252013-07-02 01:00:29 -0700411 return True
412
Dan Talaycof6202252013-07-02 01:00:29 -0700413 def pretty_print(self, q):
414 q.text("bsn_vport_q_in_q {")
415 with q.group():
416 with q.indent(2):
417 q.breakable()
418 q.text("port_no = ");
419 q.text("%#x" % self.port_no)
420 q.text(","); q.breakable()
421 q.text("ingress_tpid = ");
422 q.text("%#x" % self.ingress_tpid)
423 q.text(","); q.breakable()
424 q.text("ingress_vlan_id = ");
425 q.text("%#x" % self.ingress_vlan_id)
426 q.text(","); q.breakable()
427 q.text("egress_tpid = ");
428 q.text("%#x" % self.egress_tpid)
429 q.text(","); q.breakable()
430 q.text("egress_vlan_id = ");
431 q.text("%#x" % self.egress_vlan_id)
Kiran Poola150d8b02013-09-20 13:30:39 -0700432 q.text(","); q.breakable()
433 q.text("if_name = ");
434 q.pp(self.if_name)
Dan Talaycof6202252013-07-02 01:00:29 -0700435 q.breakable()
436 q.text('}')
437
Rich Lane7dcdf022013-12-11 14:45:27 -0800438bsn_vport.subtypes[0] = bsn_vport_q_in_q
439
440class bsn_vlan_counter_stats_entry(loxi.OFObject):
441
442 def __init__(self, vlan_vid=None, values=None):
443 if vlan_vid != None:
444 self.vlan_vid = vlan_vid
445 else:
446 self.vlan_vid = 0
447 if values != None:
448 self.values = values
449 else:
450 self.values = []
451 return
452
453 def pack(self):
454 packed = []
455 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
456 packed.append(struct.pack("!H", self.vlan_vid))
457 packed.append('\x00' * 4)
458 packed.append(loxi.generic_util.pack_list(self.values))
459 length = sum([len(x) for x in packed])
460 packed[0] = struct.pack("!H", length)
461 return ''.join(packed)
462
463 @staticmethod
464 def unpack(reader):
465 obj = bsn_vlan_counter_stats_entry()
466 _length = reader.read("!H")[0]
467 orig_reader = reader
468 reader = orig_reader.slice(_length - (0 + 2))
469 obj.vlan_vid = reader.read("!H")[0]
470 reader.skip(4)
471 obj.values = loxi.generic_util.unpack_list(reader, common.uint64.unpack)
472 return obj
473
474 def __eq__(self, other):
475 if type(self) != type(other): return False
476 if self.vlan_vid != other.vlan_vid: return False
477 if self.values != other.values: return False
478 return True
479
480 def pretty_print(self, q):
481 q.text("bsn_vlan_counter_stats_entry {")
482 with q.group():
483 with q.indent(2):
484 q.breakable()
485 q.text("vlan_vid = ");
486 q.text("%#x" % self.vlan_vid)
487 q.text(","); q.breakable()
488 q.text("values = ");
489 q.pp(self.values)
490 q.breakable()
491 q.text('}')
492
493
494class bucket(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700495
496 def __init__(self, weight=None, watch_port=None, watch_group=None, actions=None):
497 if weight != None:
498 self.weight = weight
499 else:
500 self.weight = 0
501 if watch_port != None:
502 self.watch_port = watch_port
503 else:
504 self.watch_port = 0
505 if watch_group != None:
506 self.watch_group = watch_group
507 else:
508 self.watch_group = 0
509 if actions != None:
510 self.actions = actions
511 else:
512 self.actions = []
513 return
514
515 def pack(self):
516 packed = []
517 packed.append(struct.pack("!H", 0)) # placeholder for len at index 0
518 packed.append(struct.pack("!H", self.weight))
Dan Talaycof6202252013-07-02 01:00:29 -0700519 packed.append(util.pack_port_no(self.watch_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700520 packed.append(struct.pack("!L", self.watch_group))
521 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -0800522 packed.append(loxi.generic_util.pack_list(self.actions))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700523 length = sum([len(x) for x in packed])
524 packed[0] = struct.pack("!H", length)
525 return ''.join(packed)
526
527 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800528 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700529 obj = bucket()
Dan Talaycof6202252013-07-02 01:00:29 -0700530 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800531 orig_reader = reader
532 reader = orig_reader.slice(_len - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700533 obj.weight = reader.read("!H")[0]
534 obj.watch_port = util.unpack_port_no(reader)
535 obj.watch_group = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700536 reader.skip(4)
Rich Lane7dcdf022013-12-11 14:45:27 -0800537 obj.actions = loxi.generic_util.unpack_list(reader, action.action.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700538 return obj
539
540 def __eq__(self, other):
541 if type(self) != type(other): return False
542 if self.weight != other.weight: return False
543 if self.watch_port != other.watch_port: return False
544 if self.watch_group != other.watch_group: return False
545 if self.actions != other.actions: return False
546 return True
547
Rich Lanec2ee4b82013-04-24 17:12:38 -0700548 def pretty_print(self, q):
549 q.text("bucket {")
550 with q.group():
551 with q.indent(2):
552 q.breakable()
553 q.text("weight = ");
554 q.text("%#x" % self.weight)
555 q.text(","); q.breakable()
556 q.text("watch_port = ");
557 q.text(util.pretty_port(self.watch_port))
558 q.text(","); q.breakable()
559 q.text("watch_group = ");
560 q.text("%#x" % self.watch_group)
561 q.text(","); q.breakable()
562 q.text("actions = ");
563 q.pp(self.actions)
564 q.breakable()
565 q.text('}')
566
Rich Lane7dcdf022013-12-11 14:45:27 -0800567
568class bucket_counter(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700569
570 def __init__(self, packet_count=None, byte_count=None):
571 if packet_count != None:
572 self.packet_count = packet_count
573 else:
574 self.packet_count = 0
575 if byte_count != None:
576 self.byte_count = byte_count
577 else:
578 self.byte_count = 0
579 return
580
581 def pack(self):
582 packed = []
583 packed.append(struct.pack("!Q", self.packet_count))
584 packed.append(struct.pack("!Q", self.byte_count))
585 return ''.join(packed)
586
587 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800588 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700589 obj = bucket_counter()
Dan Talaycof6202252013-07-02 01:00:29 -0700590 obj.packet_count = reader.read("!Q")[0]
591 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700592 return obj
593
594 def __eq__(self, other):
595 if type(self) != type(other): return False
596 if self.packet_count != other.packet_count: return False
597 if self.byte_count != other.byte_count: return False
598 return True
599
Rich Lanec2ee4b82013-04-24 17:12:38 -0700600 def pretty_print(self, q):
601 q.text("bucket_counter {")
602 with q.group():
603 with q.indent(2):
604 q.breakable()
605 q.text("packet_count = ");
606 q.text("%#x" % self.packet_count)
607 q.text(","); q.breakable()
608 q.text("byte_count = ");
609 q.text("%#x" % self.byte_count)
610 q.breakable()
611 q.text('}')
612
Rich Lane7dcdf022013-12-11 14:45:27 -0800613
614class experimenter_stats_header(loxi.OFObject):
615 subtypes = {}
616
617 @staticmethod
618 def unpack(reader):
619 subtype, = reader.peek('!L', 0)
620 try:
621 subclass = experimenter_stats_header.subtypes[subtype]
622 except KeyError:
623 raise loxi.ProtocolError("unknown experimenter_stats_header subtype %#x" % subtype)
624 return subclass.unpack(reader)
625
626
627class flow_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700628
Kiran Poolaae8fbf12013-09-19 16:32:32 -0700629 def __init__(self, table_id=None, duration_sec=None, duration_nsec=None, priority=None, idle_timeout=None, hard_timeout=None, flags=None, cookie=None, packet_count=None, byte_count=None, match=None, instructions=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700630 if table_id != None:
631 self.table_id = table_id
632 else:
633 self.table_id = 0
634 if duration_sec != None:
635 self.duration_sec = duration_sec
636 else:
637 self.duration_sec = 0
638 if duration_nsec != None:
639 self.duration_nsec = duration_nsec
640 else:
641 self.duration_nsec = 0
642 if priority != None:
643 self.priority = priority
644 else:
645 self.priority = 0
646 if idle_timeout != None:
647 self.idle_timeout = idle_timeout
648 else:
649 self.idle_timeout = 0
650 if hard_timeout != None:
651 self.hard_timeout = hard_timeout
652 else:
653 self.hard_timeout = 0
Kiran Poolaae8fbf12013-09-19 16:32:32 -0700654 if flags != None:
655 self.flags = flags
656 else:
657 self.flags = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700658 if cookie != None:
659 self.cookie = cookie
660 else:
661 self.cookie = 0
662 if packet_count != None:
663 self.packet_count = packet_count
664 else:
665 self.packet_count = 0
666 if byte_count != None:
667 self.byte_count = byte_count
668 else:
669 self.byte_count = 0
670 if match != None:
671 self.match = match
672 else:
673 self.match = common.match()
674 if instructions != None:
675 self.instructions = instructions
676 else:
677 self.instructions = []
678 return
679
680 def pack(self):
681 packed = []
682 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
683 packed.append(struct.pack("!B", self.table_id))
684 packed.append('\x00' * 1)
685 packed.append(struct.pack("!L", self.duration_sec))
686 packed.append(struct.pack("!L", self.duration_nsec))
687 packed.append(struct.pack("!H", self.priority))
688 packed.append(struct.pack("!H", self.idle_timeout))
689 packed.append(struct.pack("!H", self.hard_timeout))
Kiran Poolaae8fbf12013-09-19 16:32:32 -0700690 packed.append(struct.pack("!H", self.flags))
691 packed.append('\x00' * 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700692 packed.append(struct.pack("!Q", self.cookie))
693 packed.append(struct.pack("!Q", self.packet_count))
694 packed.append(struct.pack("!Q", self.byte_count))
695 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -0800696 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700697 length = sum([len(x) for x in packed])
698 packed[0] = struct.pack("!H", length)
699 return ''.join(packed)
700
701 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800702 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700703 obj = flow_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -0700704 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800705 orig_reader = reader
706 reader = orig_reader.slice(_length - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700707 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700708 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -0700709 obj.duration_sec = reader.read("!L")[0]
710 obj.duration_nsec = reader.read("!L")[0]
711 obj.priority = reader.read("!H")[0]
712 obj.idle_timeout = reader.read("!H")[0]
713 obj.hard_timeout = reader.read("!H")[0]
Kiran Poolaae8fbf12013-09-19 16:32:32 -0700714 obj.flags = reader.read("!H")[0]
715 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -0700716 obj.cookie = reader.read("!Q")[0]
717 obj.packet_count = reader.read("!Q")[0]
718 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700719 obj.match = common.match.unpack(reader)
Rich Lane7dcdf022013-12-11 14:45:27 -0800720 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700721 return obj
722
723 def __eq__(self, other):
724 if type(self) != type(other): return False
725 if self.table_id != other.table_id: return False
726 if self.duration_sec != other.duration_sec: return False
727 if self.duration_nsec != other.duration_nsec: return False
728 if self.priority != other.priority: return False
729 if self.idle_timeout != other.idle_timeout: return False
730 if self.hard_timeout != other.hard_timeout: return False
Kiran Poolaae8fbf12013-09-19 16:32:32 -0700731 if self.flags != other.flags: return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700732 if self.cookie != other.cookie: return False
733 if self.packet_count != other.packet_count: return False
734 if self.byte_count != other.byte_count: return False
735 if self.match != other.match: return False
736 if self.instructions != other.instructions: return False
737 return True
738
Rich Lanec2ee4b82013-04-24 17:12:38 -0700739 def pretty_print(self, q):
740 q.text("flow_stats_entry {")
741 with q.group():
742 with q.indent(2):
743 q.breakable()
744 q.text("table_id = ");
745 q.text("%#x" % self.table_id)
746 q.text(","); q.breakable()
747 q.text("duration_sec = ");
748 q.text("%#x" % self.duration_sec)
749 q.text(","); q.breakable()
750 q.text("duration_nsec = ");
751 q.text("%#x" % self.duration_nsec)
752 q.text(","); q.breakable()
753 q.text("priority = ");
754 q.text("%#x" % self.priority)
755 q.text(","); q.breakable()
756 q.text("idle_timeout = ");
757 q.text("%#x" % self.idle_timeout)
758 q.text(","); q.breakable()
759 q.text("hard_timeout = ");
760 q.text("%#x" % self.hard_timeout)
761 q.text(","); q.breakable()
Kiran Poolaae8fbf12013-09-19 16:32:32 -0700762 q.text("flags = ");
763 q.text("%#x" % self.flags)
764 q.text(","); q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700765 q.text("cookie = ");
766 q.text("%#x" % self.cookie)
767 q.text(","); q.breakable()
768 q.text("packet_count = ");
769 q.text("%#x" % self.packet_count)
770 q.text(","); q.breakable()
771 q.text("byte_count = ");
772 q.text("%#x" % self.byte_count)
773 q.text(","); q.breakable()
774 q.text("match = ");
775 q.pp(self.match)
776 q.text(","); q.breakable()
777 q.text("instructions = ");
778 q.pp(self.instructions)
779 q.breakable()
780 q.text('}')
781
Rich Lane7dcdf022013-12-11 14:45:27 -0800782
783class group_desc_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700784
Rich Lane6f4978c2013-10-20 21:33:52 -0700785 def __init__(self, group_type=None, group_id=None, buckets=None):
786 if group_type != None:
787 self.group_type = group_type
Rich Lanec2ee4b82013-04-24 17:12:38 -0700788 else:
Rich Lane6f4978c2013-10-20 21:33:52 -0700789 self.group_type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700790 if group_id != None:
791 self.group_id = group_id
792 else:
793 self.group_id = 0
794 if buckets != None:
795 self.buckets = buckets
796 else:
797 self.buckets = []
798 return
799
800 def pack(self):
801 packed = []
802 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
Rich Lane6f4978c2013-10-20 21:33:52 -0700803 packed.append(struct.pack("!B", self.group_type))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700804 packed.append('\x00' * 1)
805 packed.append(struct.pack("!L", self.group_id))
Rich Lane7dcdf022013-12-11 14:45:27 -0800806 packed.append(loxi.generic_util.pack_list(self.buckets))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700807 length = sum([len(x) for x in packed])
808 packed[0] = struct.pack("!H", length)
809 return ''.join(packed)
810
811 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800812 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700813 obj = group_desc_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -0700814 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800815 orig_reader = reader
816 reader = orig_reader.slice(_length - (0 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -0700817 obj.group_type = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700818 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -0700819 obj.group_id = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800820 obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700821 return obj
822
823 def __eq__(self, other):
824 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -0700825 if self.group_type != other.group_type: return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700826 if self.group_id != other.group_id: return False
827 if self.buckets != other.buckets: return False
828 return True
829
Rich Lanec2ee4b82013-04-24 17:12:38 -0700830 def pretty_print(self, q):
831 q.text("group_desc_stats_entry {")
832 with q.group():
833 with q.indent(2):
834 q.breakable()
Rich Lane6f4978c2013-10-20 21:33:52 -0700835 q.text("group_type = ");
836 q.text("%#x" % self.group_type)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700837 q.text(","); q.breakable()
838 q.text("group_id = ");
839 q.text("%#x" % self.group_id)
840 q.text(","); q.breakable()
841 q.text("buckets = ");
842 q.pp(self.buckets)
843 q.breakable()
844 q.text('}')
845
Rich Lane7dcdf022013-12-11 14:45:27 -0800846
847class group_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700848
849 def __init__(self, group_id=None, ref_count=None, packet_count=None, byte_count=None, duration_sec=None, duration_nsec=None, bucket_stats=None):
850 if group_id != None:
851 self.group_id = group_id
852 else:
853 self.group_id = 0
854 if ref_count != None:
855 self.ref_count = ref_count
856 else:
857 self.ref_count = 0
858 if packet_count != None:
859 self.packet_count = packet_count
860 else:
861 self.packet_count = 0
862 if byte_count != None:
863 self.byte_count = byte_count
864 else:
865 self.byte_count = 0
866 if duration_sec != None:
867 self.duration_sec = duration_sec
868 else:
869 self.duration_sec = 0
870 if duration_nsec != None:
871 self.duration_nsec = duration_nsec
872 else:
873 self.duration_nsec = 0
874 if bucket_stats != None:
875 self.bucket_stats = bucket_stats
876 else:
877 self.bucket_stats = []
878 return
879
880 def pack(self):
881 packed = []
882 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
883 packed.append('\x00' * 2)
884 packed.append(struct.pack("!L", self.group_id))
885 packed.append(struct.pack("!L", self.ref_count))
886 packed.append('\x00' * 4)
887 packed.append(struct.pack("!Q", self.packet_count))
888 packed.append(struct.pack("!Q", self.byte_count))
889 packed.append(struct.pack("!L", self.duration_sec))
890 packed.append(struct.pack("!L", self.duration_nsec))
Rich Lane7dcdf022013-12-11 14:45:27 -0800891 packed.append(loxi.generic_util.pack_list(self.bucket_stats))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700892 length = sum([len(x) for x in packed])
893 packed[0] = struct.pack("!H", length)
894 return ''.join(packed)
895
896 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800897 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700898 obj = group_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -0700899 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800900 orig_reader = reader
901 reader = orig_reader.slice(_length - (0 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700902 reader.skip(2)
Dan Talaycof6202252013-07-02 01:00:29 -0700903 obj.group_id = reader.read("!L")[0]
904 obj.ref_count = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700905 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -0700906 obj.packet_count = reader.read("!Q")[0]
907 obj.byte_count = reader.read("!Q")[0]
908 obj.duration_sec = reader.read("!L")[0]
909 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700910 obj.bucket_stats = loxi.generic_util.unpack_list(reader, common.bucket_counter.unpack)
911 return obj
912
913 def __eq__(self, other):
914 if type(self) != type(other): return False
915 if self.group_id != other.group_id: return False
916 if self.ref_count != other.ref_count: return False
917 if self.packet_count != other.packet_count: return False
918 if self.byte_count != other.byte_count: return False
919 if self.duration_sec != other.duration_sec: return False
920 if self.duration_nsec != other.duration_nsec: return False
921 if self.bucket_stats != other.bucket_stats: return False
922 return True
923
Rich Lanec2ee4b82013-04-24 17:12:38 -0700924 def pretty_print(self, q):
925 q.text("group_stats_entry {")
926 with q.group():
927 with q.indent(2):
928 q.breakable()
929 q.text("group_id = ");
930 q.text("%#x" % self.group_id)
931 q.text(","); q.breakable()
932 q.text("ref_count = ");
933 q.text("%#x" % self.ref_count)
934 q.text(","); q.breakable()
935 q.text("packet_count = ");
936 q.text("%#x" % self.packet_count)
937 q.text(","); q.breakable()
938 q.text("byte_count = ");
939 q.text("%#x" % self.byte_count)
940 q.text(","); q.breakable()
941 q.text("duration_sec = ");
942 q.text("%#x" % self.duration_sec)
943 q.text(","); q.breakable()
944 q.text("duration_nsec = ");
945 q.text("%#x" % self.duration_nsec)
946 q.text(","); q.breakable()
947 q.text("bucket_stats = ");
948 q.pp(self.bucket_stats)
949 q.breakable()
950 q.text('}')
951
Rich Lane7dcdf022013-12-11 14:45:27 -0800952
953class hello_elem(loxi.OFObject):
954 subtypes = {}
955
956 @staticmethod
957 def unpack(reader):
958 subtype, = reader.peek('!H', 0)
959 try:
960 subclass = hello_elem.subtypes[subtype]
961 except KeyError:
962 raise loxi.ProtocolError("unknown hello_elem subtype %#x" % subtype)
963 return subclass.unpack(reader)
964
965
966class hello_elem_versionbitmap(hello_elem):
Dan Talaycof6202252013-07-02 01:00:29 -0700967 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -0700968
969 def __init__(self, bitmaps=None):
970 if bitmaps != None:
971 self.bitmaps = bitmaps
972 else:
973 self.bitmaps = []
974 return
975
976 def pack(self):
977 packed = []
978 packed.append(struct.pack("!H", self.type))
979 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -0800980 packed.append(loxi.generic_util.pack_list(self.bitmaps))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700981 length = sum([len(x) for x in packed])
982 packed[1] = struct.pack("!H", length)
983 return ''.join(packed)
984
985 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800986 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700987 obj = hello_elem_versionbitmap()
Dan Talaycof6202252013-07-02 01:00:29 -0700988 _type = reader.read("!H")[0]
989 assert(_type == 1)
990 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800991 orig_reader = reader
992 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700993 obj.bitmaps = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
994 return obj
995
996 def __eq__(self, other):
997 if type(self) != type(other): return False
998 if self.bitmaps != other.bitmaps: return False
999 return True
1000
Rich Lanec2ee4b82013-04-24 17:12:38 -07001001 def pretty_print(self, q):
1002 q.text("hello_elem_versionbitmap {")
1003 with q.group():
1004 with q.indent(2):
1005 q.breakable()
1006 q.text("bitmaps = ");
1007 q.pp(self.bitmaps)
1008 q.breakable()
1009 q.text('}')
1010
Rich Lane7dcdf022013-12-11 14:45:27 -08001011hello_elem.subtypes[1] = hello_elem_versionbitmap
1012
1013class match_v3(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001014 type = 1
1015
1016 def __init__(self, oxm_list=None):
1017 if oxm_list != None:
1018 self.oxm_list = oxm_list
1019 else:
1020 self.oxm_list = []
1021 return
1022
1023 def pack(self):
1024 packed = []
1025 packed.append(struct.pack("!H", self.type))
1026 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08001027 packed.append(loxi.generic_util.pack_list(self.oxm_list))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001028 length = sum([len(x) for x in packed])
1029 packed[1] = struct.pack("!H", length)
Rich Laned53156a2013-08-05 17:17:33 -07001030 packed.append(loxi.generic_util.pad_to(8, length))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001031 return ''.join(packed)
1032
1033 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001034 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001035 obj = match_v3()
Dan Talaycof6202252013-07-02 01:00:29 -07001036 _type = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001037 assert(_type == 1)
Dan Talaycof6202252013-07-02 01:00:29 -07001038 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001039 orig_reader = reader
1040 reader = orig_reader.slice(_length - (2 + 2))
1041 obj.oxm_list = loxi.generic_util.unpack_list(reader, oxm.oxm.unpack)
1042 orig_reader.skip_align()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001043 return obj
1044
1045 def __eq__(self, other):
1046 if type(self) != type(other): return False
1047 if self.oxm_list != other.oxm_list: return False
1048 return True
1049
Rich Lanec2ee4b82013-04-24 17:12:38 -07001050 def pretty_print(self, q):
1051 q.text("match_v3 {")
1052 with q.group():
1053 with q.indent(2):
1054 q.breakable()
1055 q.text("oxm_list = ");
1056 q.pp(self.oxm_list)
1057 q.breakable()
1058 q.text('}')
1059
Rich Lane7dcdf022013-12-11 14:45:27 -08001060
1061class meter_band_stats(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001062
1063 def __init__(self, packet_band_count=None, byte_band_count=None):
1064 if packet_band_count != None:
1065 self.packet_band_count = packet_band_count
1066 else:
1067 self.packet_band_count = 0
1068 if byte_band_count != None:
1069 self.byte_band_count = byte_band_count
1070 else:
1071 self.byte_band_count = 0
1072 return
1073
1074 def pack(self):
1075 packed = []
1076 packed.append(struct.pack("!Q", self.packet_band_count))
1077 packed.append(struct.pack("!Q", self.byte_band_count))
1078 return ''.join(packed)
1079
1080 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001081 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001082 obj = meter_band_stats()
Dan Talaycof6202252013-07-02 01:00:29 -07001083 obj.packet_band_count = reader.read("!Q")[0]
1084 obj.byte_band_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001085 return obj
1086
1087 def __eq__(self, other):
1088 if type(self) != type(other): return False
1089 if self.packet_band_count != other.packet_band_count: return False
1090 if self.byte_band_count != other.byte_band_count: return False
1091 return True
1092
Rich Lanec2ee4b82013-04-24 17:12:38 -07001093 def pretty_print(self, q):
1094 q.text("meter_band_stats {")
1095 with q.group():
1096 with q.indent(2):
1097 q.breakable()
1098 q.text("packet_band_count = ");
1099 q.text("%#x" % self.packet_band_count)
1100 q.text(","); q.breakable()
1101 q.text("byte_band_count = ");
1102 q.text("%#x" % self.byte_band_count)
1103 q.breakable()
1104 q.text('}')
1105
Rich Lane7dcdf022013-12-11 14:45:27 -08001106
1107class meter_config(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001108
1109 def __init__(self, flags=None, meter_id=None, entries=None):
1110 if flags != None:
1111 self.flags = flags
1112 else:
1113 self.flags = 0
1114 if meter_id != None:
1115 self.meter_id = meter_id
1116 else:
1117 self.meter_id = 0
1118 if entries != None:
1119 self.entries = entries
1120 else:
1121 self.entries = []
1122 return
1123
1124 def pack(self):
1125 packed = []
1126 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
1127 packed.append(struct.pack("!H", self.flags))
1128 packed.append(struct.pack("!L", self.meter_id))
Rich Lane7dcdf022013-12-11 14:45:27 -08001129 packed.append(loxi.generic_util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001130 length = sum([len(x) for x in packed])
1131 packed[0] = struct.pack("!H", length)
1132 return ''.join(packed)
1133
1134 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001135 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001136 obj = meter_config()
Dan Talaycof6202252013-07-02 01:00:29 -07001137 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001138 orig_reader = reader
1139 reader = orig_reader.slice(_length - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001140 obj.flags = reader.read("!H")[0]
1141 obj.meter_id = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001142 obj.entries = loxi.generic_util.unpack_list(reader, meter_band.meter_band.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001143 return obj
1144
1145 def __eq__(self, other):
1146 if type(self) != type(other): return False
1147 if self.flags != other.flags: return False
1148 if self.meter_id != other.meter_id: return False
1149 if self.entries != other.entries: return False
1150 return True
1151
Rich Lanec2ee4b82013-04-24 17:12:38 -07001152 def pretty_print(self, q):
1153 q.text("meter_config {")
1154 with q.group():
1155 with q.indent(2):
1156 q.breakable()
1157 q.text("flags = ");
1158 q.text("%#x" % self.flags)
1159 q.text(","); q.breakable()
1160 q.text("meter_id = ");
1161 q.text("%#x" % self.meter_id)
1162 q.text(","); q.breakable()
1163 q.text("entries = ");
1164 q.pp(self.entries)
1165 q.breakable()
1166 q.text('}')
1167
Rich Lane7dcdf022013-12-11 14:45:27 -08001168
1169class meter_features(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001170
1171 def __init__(self, max_meter=None, band_types=None, capabilities=None, max_bands=None, max_color=None):
1172 if max_meter != None:
1173 self.max_meter = max_meter
1174 else:
1175 self.max_meter = 0
1176 if band_types != None:
1177 self.band_types = band_types
1178 else:
1179 self.band_types = 0
1180 if capabilities != None:
1181 self.capabilities = capabilities
1182 else:
1183 self.capabilities = 0
1184 if max_bands != None:
1185 self.max_bands = max_bands
1186 else:
1187 self.max_bands = 0
1188 if max_color != None:
1189 self.max_color = max_color
1190 else:
1191 self.max_color = 0
1192 return
1193
1194 def pack(self):
1195 packed = []
1196 packed.append(struct.pack("!L", self.max_meter))
1197 packed.append(struct.pack("!L", self.band_types))
1198 packed.append(struct.pack("!L", self.capabilities))
1199 packed.append(struct.pack("!B", self.max_bands))
1200 packed.append(struct.pack("!B", self.max_color))
1201 packed.append('\x00' * 2)
1202 return ''.join(packed)
1203
1204 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001205 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001206 obj = meter_features()
Dan Talaycof6202252013-07-02 01:00:29 -07001207 obj.max_meter = reader.read("!L")[0]
1208 obj.band_types = reader.read("!L")[0]
1209 obj.capabilities = reader.read("!L")[0]
1210 obj.max_bands = reader.read("!B")[0]
1211 obj.max_color = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001212 reader.skip(2)
1213 return obj
1214
1215 def __eq__(self, other):
1216 if type(self) != type(other): return False
1217 if self.max_meter != other.max_meter: return False
1218 if self.band_types != other.band_types: return False
1219 if self.capabilities != other.capabilities: return False
1220 if self.max_bands != other.max_bands: return False
1221 if self.max_color != other.max_color: return False
1222 return True
1223
Rich Lanec2ee4b82013-04-24 17:12:38 -07001224 def pretty_print(self, q):
1225 q.text("meter_features {")
1226 with q.group():
1227 with q.indent(2):
1228 q.breakable()
1229 q.text("max_meter = ");
1230 q.text("%#x" % self.max_meter)
1231 q.text(","); q.breakable()
1232 q.text("band_types = ");
1233 q.text("%#x" % self.band_types)
1234 q.text(","); q.breakable()
1235 q.text("capabilities = ");
1236 q.text("%#x" % self.capabilities)
1237 q.text(","); q.breakable()
1238 q.text("max_bands = ");
1239 q.text("%#x" % self.max_bands)
1240 q.text(","); q.breakable()
1241 q.text("max_color = ");
1242 q.text("%#x" % self.max_color)
1243 q.breakable()
1244 q.text('}')
1245
Rich Lane7dcdf022013-12-11 14:45:27 -08001246
1247class meter_stats(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001248
1249 def __init__(self, meter_id=None, flow_count=None, packet_in_count=None, byte_in_count=None, duration_sec=None, duration_nsec=None, band_stats=None):
1250 if meter_id != None:
1251 self.meter_id = meter_id
1252 else:
1253 self.meter_id = 0
1254 if flow_count != None:
1255 self.flow_count = flow_count
1256 else:
1257 self.flow_count = 0
1258 if packet_in_count != None:
1259 self.packet_in_count = packet_in_count
1260 else:
1261 self.packet_in_count = 0
1262 if byte_in_count != None:
1263 self.byte_in_count = byte_in_count
1264 else:
1265 self.byte_in_count = 0
1266 if duration_sec != None:
1267 self.duration_sec = duration_sec
1268 else:
1269 self.duration_sec = 0
1270 if duration_nsec != None:
1271 self.duration_nsec = duration_nsec
1272 else:
1273 self.duration_nsec = 0
1274 if band_stats != None:
1275 self.band_stats = band_stats
1276 else:
1277 self.band_stats = []
1278 return
1279
1280 def pack(self):
1281 packed = []
1282 packed.append(struct.pack("!L", self.meter_id))
1283 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1284 packed.append('\x00' * 6)
1285 packed.append(struct.pack("!L", self.flow_count))
1286 packed.append(struct.pack("!Q", self.packet_in_count))
1287 packed.append(struct.pack("!Q", self.byte_in_count))
1288 packed.append(struct.pack("!L", self.duration_sec))
1289 packed.append(struct.pack("!L", self.duration_nsec))
Rich Lane7dcdf022013-12-11 14:45:27 -08001290 packed.append(loxi.generic_util.pack_list(self.band_stats))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001291 length = sum([len(x) for x in packed])
1292 packed[1] = struct.pack("!H", length)
1293 return ''.join(packed)
1294
1295 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001296 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001297 obj = meter_stats()
Dan Talaycof6202252013-07-02 01:00:29 -07001298 obj.meter_id = reader.read("!L")[0]
1299 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001300 orig_reader = reader
1301 reader = orig_reader.slice(_len - (4 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001302 reader.skip(6)
Dan Talaycof6202252013-07-02 01:00:29 -07001303 obj.flow_count = reader.read("!L")[0]
1304 obj.packet_in_count = reader.read("!Q")[0]
1305 obj.byte_in_count = reader.read("!Q")[0]
1306 obj.duration_sec = reader.read("!L")[0]
1307 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001308 obj.band_stats = loxi.generic_util.unpack_list(reader, common.meter_band_stats.unpack)
1309 return obj
1310
1311 def __eq__(self, other):
1312 if type(self) != type(other): return False
1313 if self.meter_id != other.meter_id: return False
1314 if self.flow_count != other.flow_count: return False
1315 if self.packet_in_count != other.packet_in_count: return False
1316 if self.byte_in_count != other.byte_in_count: return False
1317 if self.duration_sec != other.duration_sec: return False
1318 if self.duration_nsec != other.duration_nsec: return False
1319 if self.band_stats != other.band_stats: return False
1320 return True
1321
Rich Lanec2ee4b82013-04-24 17:12:38 -07001322 def pretty_print(self, q):
1323 q.text("meter_stats {")
1324 with q.group():
1325 with q.indent(2):
1326 q.breakable()
1327 q.text("meter_id = ");
1328 q.text("%#x" % self.meter_id)
1329 q.text(","); q.breakable()
1330 q.text("flow_count = ");
1331 q.text("%#x" % self.flow_count)
1332 q.text(","); q.breakable()
1333 q.text("packet_in_count = ");
1334 q.text("%#x" % self.packet_in_count)
1335 q.text(","); q.breakable()
1336 q.text("byte_in_count = ");
1337 q.text("%#x" % self.byte_in_count)
1338 q.text(","); q.breakable()
1339 q.text("duration_sec = ");
1340 q.text("%#x" % self.duration_sec)
1341 q.text(","); q.breakable()
1342 q.text("duration_nsec = ");
1343 q.text("%#x" % self.duration_nsec)
1344 q.text(","); q.breakable()
1345 q.text("band_stats = ");
1346 q.pp(self.band_stats)
1347 q.breakable()
1348 q.text('}')
1349
Rich Lane7dcdf022013-12-11 14:45:27 -08001350
1351class packet_queue(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001352
1353 def __init__(self, queue_id=None, port=None, properties=None):
1354 if queue_id != None:
1355 self.queue_id = queue_id
1356 else:
1357 self.queue_id = 0
1358 if port != None:
1359 self.port = port
1360 else:
1361 self.port = 0
1362 if properties != None:
1363 self.properties = properties
1364 else:
1365 self.properties = []
1366 return
1367
1368 def pack(self):
1369 packed = []
1370 packed.append(struct.pack("!L", self.queue_id))
Dan Talaycof6202252013-07-02 01:00:29 -07001371 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001372 packed.append(struct.pack("!H", 0)) # placeholder for len at index 2
1373 packed.append('\x00' * 6)
Rich Lane7dcdf022013-12-11 14:45:27 -08001374 packed.append(loxi.generic_util.pack_list(self.properties))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001375 length = sum([len(x) for x in packed])
1376 packed[2] = struct.pack("!H", length)
1377 return ''.join(packed)
1378
1379 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001380 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001381 obj = packet_queue()
Dan Talaycof6202252013-07-02 01:00:29 -07001382 obj.queue_id = reader.read("!L")[0]
1383 obj.port = util.unpack_port_no(reader)
1384 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001385 orig_reader = reader
1386 reader = orig_reader.slice(_len - (8 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001387 reader.skip(6)
Rich Lane7dcdf022013-12-11 14:45:27 -08001388 obj.properties = loxi.generic_util.unpack_list(reader, common.queue_prop.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001389 return obj
1390
1391 def __eq__(self, other):
1392 if type(self) != type(other): return False
1393 if self.queue_id != other.queue_id: return False
1394 if self.port != other.port: return False
1395 if self.properties != other.properties: return False
1396 return True
1397
Rich Lanec2ee4b82013-04-24 17:12:38 -07001398 def pretty_print(self, q):
1399 q.text("packet_queue {")
1400 with q.group():
1401 with q.indent(2):
1402 q.breakable()
1403 q.text("queue_id = ");
1404 q.text("%#x" % self.queue_id)
1405 q.text(","); q.breakable()
1406 q.text("port = ");
1407 q.text(util.pretty_port(self.port))
1408 q.text(","); q.breakable()
1409 q.text("properties = ");
1410 q.pp(self.properties)
1411 q.breakable()
1412 q.text('}')
1413
Rich Lane7dcdf022013-12-11 14:45:27 -08001414
1415class port_desc(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001416
1417 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):
1418 if port_no != None:
1419 self.port_no = port_no
1420 else:
1421 self.port_no = 0
1422 if hw_addr != None:
1423 self.hw_addr = hw_addr
1424 else:
1425 self.hw_addr = [0,0,0,0,0,0]
1426 if name != None:
1427 self.name = name
1428 else:
1429 self.name = ""
1430 if config != None:
1431 self.config = config
1432 else:
1433 self.config = 0
1434 if state != None:
1435 self.state = state
1436 else:
1437 self.state = 0
1438 if curr != None:
1439 self.curr = curr
1440 else:
1441 self.curr = 0
1442 if advertised != None:
1443 self.advertised = advertised
1444 else:
1445 self.advertised = 0
1446 if supported != None:
1447 self.supported = supported
1448 else:
1449 self.supported = 0
1450 if peer != None:
1451 self.peer = peer
1452 else:
1453 self.peer = 0
1454 if curr_speed != None:
1455 self.curr_speed = curr_speed
1456 else:
1457 self.curr_speed = 0
1458 if max_speed != None:
1459 self.max_speed = max_speed
1460 else:
1461 self.max_speed = 0
1462 return
1463
1464 def pack(self):
1465 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07001466 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001467 packed.append('\x00' * 4)
1468 packed.append(struct.pack("!6B", *self.hw_addr))
1469 packed.append('\x00' * 2)
1470 packed.append(struct.pack("!16s", self.name))
1471 packed.append(struct.pack("!L", self.config))
1472 packed.append(struct.pack("!L", self.state))
1473 packed.append(struct.pack("!L", self.curr))
1474 packed.append(struct.pack("!L", self.advertised))
1475 packed.append(struct.pack("!L", self.supported))
1476 packed.append(struct.pack("!L", self.peer))
1477 packed.append(struct.pack("!L", self.curr_speed))
1478 packed.append(struct.pack("!L", self.max_speed))
1479 return ''.join(packed)
1480
1481 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001482 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001483 obj = port_desc()
Dan Talaycof6202252013-07-02 01:00:29 -07001484 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001485 reader.skip(4)
1486 obj.hw_addr = list(reader.read('!6B'))
1487 reader.skip(2)
1488 obj.name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -07001489 obj.config = reader.read("!L")[0]
1490 obj.state = reader.read("!L")[0]
1491 obj.curr = reader.read("!L")[0]
1492 obj.advertised = reader.read("!L")[0]
1493 obj.supported = reader.read("!L")[0]
1494 obj.peer = reader.read("!L")[0]
1495 obj.curr_speed = reader.read("!L")[0]
1496 obj.max_speed = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001497 return obj
1498
1499 def __eq__(self, other):
1500 if type(self) != type(other): return False
1501 if self.port_no != other.port_no: return False
1502 if self.hw_addr != other.hw_addr: return False
1503 if self.name != other.name: return False
1504 if self.config != other.config: return False
1505 if self.state != other.state: return False
1506 if self.curr != other.curr: return False
1507 if self.advertised != other.advertised: return False
1508 if self.supported != other.supported: return False
1509 if self.peer != other.peer: return False
1510 if self.curr_speed != other.curr_speed: return False
1511 if self.max_speed != other.max_speed: return False
1512 return True
1513
Rich Lanec2ee4b82013-04-24 17:12:38 -07001514 def pretty_print(self, q):
1515 q.text("port_desc {")
1516 with q.group():
1517 with q.indent(2):
1518 q.breakable()
1519 q.text("port_no = ");
1520 q.text(util.pretty_port(self.port_no))
1521 q.text(","); q.breakable()
1522 q.text("hw_addr = ");
1523 q.text(util.pretty_mac(self.hw_addr))
1524 q.text(","); q.breakable()
1525 q.text("name = ");
1526 q.pp(self.name)
1527 q.text(","); q.breakable()
1528 q.text("config = ");
1529 q.text("%#x" % self.config)
1530 q.text(","); q.breakable()
1531 q.text("state = ");
1532 q.text("%#x" % self.state)
1533 q.text(","); q.breakable()
1534 q.text("curr = ");
1535 q.text("%#x" % self.curr)
1536 q.text(","); q.breakable()
1537 q.text("advertised = ");
1538 q.text("%#x" % self.advertised)
1539 q.text(","); q.breakable()
1540 q.text("supported = ");
1541 q.text("%#x" % self.supported)
1542 q.text(","); q.breakable()
1543 q.text("peer = ");
1544 q.text("%#x" % self.peer)
1545 q.text(","); q.breakable()
1546 q.text("curr_speed = ");
1547 q.text("%#x" % self.curr_speed)
1548 q.text(","); q.breakable()
1549 q.text("max_speed = ");
1550 q.text("%#x" % self.max_speed)
1551 q.breakable()
1552 q.text('}')
1553
Rich Lane7dcdf022013-12-11 14:45:27 -08001554
1555class port_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001556
1557 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, duration_sec=None, duration_nsec=None):
1558 if port_no != None:
1559 self.port_no = port_no
1560 else:
1561 self.port_no = 0
1562 if rx_packets != None:
1563 self.rx_packets = rx_packets
1564 else:
1565 self.rx_packets = 0
1566 if tx_packets != None:
1567 self.tx_packets = tx_packets
1568 else:
1569 self.tx_packets = 0
1570 if rx_bytes != None:
1571 self.rx_bytes = rx_bytes
1572 else:
1573 self.rx_bytes = 0
1574 if tx_bytes != None:
1575 self.tx_bytes = tx_bytes
1576 else:
1577 self.tx_bytes = 0
1578 if rx_dropped != None:
1579 self.rx_dropped = rx_dropped
1580 else:
1581 self.rx_dropped = 0
1582 if tx_dropped != None:
1583 self.tx_dropped = tx_dropped
1584 else:
1585 self.tx_dropped = 0
1586 if rx_errors != None:
1587 self.rx_errors = rx_errors
1588 else:
1589 self.rx_errors = 0
1590 if tx_errors != None:
1591 self.tx_errors = tx_errors
1592 else:
1593 self.tx_errors = 0
1594 if rx_frame_err != None:
1595 self.rx_frame_err = rx_frame_err
1596 else:
1597 self.rx_frame_err = 0
1598 if rx_over_err != None:
1599 self.rx_over_err = rx_over_err
1600 else:
1601 self.rx_over_err = 0
1602 if rx_crc_err != None:
1603 self.rx_crc_err = rx_crc_err
1604 else:
1605 self.rx_crc_err = 0
1606 if collisions != None:
1607 self.collisions = collisions
1608 else:
1609 self.collisions = 0
1610 if duration_sec != None:
1611 self.duration_sec = duration_sec
1612 else:
1613 self.duration_sec = 0
1614 if duration_nsec != None:
1615 self.duration_nsec = duration_nsec
1616 else:
1617 self.duration_nsec = 0
1618 return
1619
1620 def pack(self):
1621 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07001622 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001623 packed.append('\x00' * 4)
1624 packed.append(struct.pack("!Q", self.rx_packets))
1625 packed.append(struct.pack("!Q", self.tx_packets))
1626 packed.append(struct.pack("!Q", self.rx_bytes))
1627 packed.append(struct.pack("!Q", self.tx_bytes))
1628 packed.append(struct.pack("!Q", self.rx_dropped))
1629 packed.append(struct.pack("!Q", self.tx_dropped))
1630 packed.append(struct.pack("!Q", self.rx_errors))
1631 packed.append(struct.pack("!Q", self.tx_errors))
1632 packed.append(struct.pack("!Q", self.rx_frame_err))
1633 packed.append(struct.pack("!Q", self.rx_over_err))
1634 packed.append(struct.pack("!Q", self.rx_crc_err))
1635 packed.append(struct.pack("!Q", self.collisions))
1636 packed.append(struct.pack("!L", self.duration_sec))
1637 packed.append(struct.pack("!L", self.duration_nsec))
1638 return ''.join(packed)
1639
1640 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001641 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001642 obj = port_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001643 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001644 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001645 obj.rx_packets = reader.read("!Q")[0]
1646 obj.tx_packets = reader.read("!Q")[0]
1647 obj.rx_bytes = reader.read("!Q")[0]
1648 obj.tx_bytes = reader.read("!Q")[0]
1649 obj.rx_dropped = reader.read("!Q")[0]
1650 obj.tx_dropped = reader.read("!Q")[0]
1651 obj.rx_errors = reader.read("!Q")[0]
1652 obj.tx_errors = reader.read("!Q")[0]
1653 obj.rx_frame_err = reader.read("!Q")[0]
1654 obj.rx_over_err = reader.read("!Q")[0]
1655 obj.rx_crc_err = reader.read("!Q")[0]
1656 obj.collisions = reader.read("!Q")[0]
1657 obj.duration_sec = reader.read("!L")[0]
1658 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001659 return obj
1660
1661 def __eq__(self, other):
1662 if type(self) != type(other): return False
1663 if self.port_no != other.port_no: return False
1664 if self.rx_packets != other.rx_packets: return False
1665 if self.tx_packets != other.tx_packets: return False
1666 if self.rx_bytes != other.rx_bytes: return False
1667 if self.tx_bytes != other.tx_bytes: return False
1668 if self.rx_dropped != other.rx_dropped: return False
1669 if self.tx_dropped != other.tx_dropped: return False
1670 if self.rx_errors != other.rx_errors: return False
1671 if self.tx_errors != other.tx_errors: return False
1672 if self.rx_frame_err != other.rx_frame_err: return False
1673 if self.rx_over_err != other.rx_over_err: return False
1674 if self.rx_crc_err != other.rx_crc_err: return False
1675 if self.collisions != other.collisions: return False
1676 if self.duration_sec != other.duration_sec: return False
1677 if self.duration_nsec != other.duration_nsec: return False
1678 return True
1679
Rich Lanec2ee4b82013-04-24 17:12:38 -07001680 def pretty_print(self, q):
1681 q.text("port_stats_entry {")
1682 with q.group():
1683 with q.indent(2):
1684 q.breakable()
1685 q.text("port_no = ");
1686 q.text(util.pretty_port(self.port_no))
1687 q.text(","); q.breakable()
1688 q.text("rx_packets = ");
1689 q.text("%#x" % self.rx_packets)
1690 q.text(","); q.breakable()
1691 q.text("tx_packets = ");
1692 q.text("%#x" % self.tx_packets)
1693 q.text(","); q.breakable()
1694 q.text("rx_bytes = ");
1695 q.text("%#x" % self.rx_bytes)
1696 q.text(","); q.breakable()
1697 q.text("tx_bytes = ");
1698 q.text("%#x" % self.tx_bytes)
1699 q.text(","); q.breakable()
1700 q.text("rx_dropped = ");
1701 q.text("%#x" % self.rx_dropped)
1702 q.text(","); q.breakable()
1703 q.text("tx_dropped = ");
1704 q.text("%#x" % self.tx_dropped)
1705 q.text(","); q.breakable()
1706 q.text("rx_errors = ");
1707 q.text("%#x" % self.rx_errors)
1708 q.text(","); q.breakable()
1709 q.text("tx_errors = ");
1710 q.text("%#x" % self.tx_errors)
1711 q.text(","); q.breakable()
1712 q.text("rx_frame_err = ");
1713 q.text("%#x" % self.rx_frame_err)
1714 q.text(","); q.breakable()
1715 q.text("rx_over_err = ");
1716 q.text("%#x" % self.rx_over_err)
1717 q.text(","); q.breakable()
1718 q.text("rx_crc_err = ");
1719 q.text("%#x" % self.rx_crc_err)
1720 q.text(","); q.breakable()
1721 q.text("collisions = ");
1722 q.text("%#x" % self.collisions)
1723 q.text(","); q.breakable()
1724 q.text("duration_sec = ");
1725 q.text("%#x" % self.duration_sec)
1726 q.text(","); q.breakable()
1727 q.text("duration_nsec = ");
1728 q.text("%#x" % self.duration_nsec)
1729 q.breakable()
1730 q.text('}')
1731
Rich Lane7dcdf022013-12-11 14:45:27 -08001732
1733class queue_prop(loxi.OFObject):
1734 subtypes = {}
1735
1736 @staticmethod
1737 def unpack(reader):
1738 subtype, = reader.peek('!H', 0)
1739 try:
1740 subclass = queue_prop.subtypes[subtype]
1741 except KeyError:
1742 raise loxi.ProtocolError("unknown queue_prop subtype %#x" % subtype)
1743 return subclass.unpack(reader)
1744
1745
1746class queue_prop_experimenter(queue_prop):
1747 subtypes = {}
1748
1749 @staticmethod
1750 def unpack(reader):
1751 subtype, = reader.peek('!L', 8)
1752 try:
1753 subclass = queue_prop_experimenter.subtypes[subtype]
1754 except KeyError:
1755 raise loxi.ProtocolError("unknown queue_prop_experimenter queue_prop subtype %#x" % subtype)
1756 return subclass.unpack(reader)
1757
1758queue_prop.subtypes[65535] = queue_prop_experimenter
1759
1760class queue_prop_max_rate(queue_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07001761 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07001762
1763 def __init__(self, rate=None):
1764 if rate != None:
1765 self.rate = rate
1766 else:
1767 self.rate = 0
1768 return
1769
1770 def pack(self):
1771 packed = []
1772 packed.append(struct.pack("!H", self.type))
1773 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1774 packed.append('\x00' * 4)
1775 packed.append(struct.pack("!H", self.rate))
1776 packed.append('\x00' * 6)
1777 length = sum([len(x) for x in packed])
1778 packed[1] = struct.pack("!H", length)
1779 return ''.join(packed)
1780
1781 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001782 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001783 obj = queue_prop_max_rate()
Dan Talaycof6202252013-07-02 01:00:29 -07001784 _type = reader.read("!H")[0]
1785 assert(_type == 2)
1786 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001787 orig_reader = reader
1788 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001789 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001790 obj.rate = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001791 reader.skip(6)
1792 return obj
1793
1794 def __eq__(self, other):
1795 if type(self) != type(other): return False
1796 if self.rate != other.rate: return False
1797 return True
1798
Rich Lanec2ee4b82013-04-24 17:12:38 -07001799 def pretty_print(self, q):
1800 q.text("queue_prop_max_rate {")
1801 with q.group():
1802 with q.indent(2):
1803 q.breakable()
1804 q.text("rate = ");
1805 q.text("%#x" % self.rate)
1806 q.breakable()
1807 q.text('}')
1808
Rich Lane7dcdf022013-12-11 14:45:27 -08001809queue_prop.subtypes[2] = queue_prop_max_rate
1810
1811class queue_prop_min_rate(queue_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07001812 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07001813
1814 def __init__(self, rate=None):
1815 if rate != None:
1816 self.rate = rate
1817 else:
1818 self.rate = 0
1819 return
1820
1821 def pack(self):
1822 packed = []
1823 packed.append(struct.pack("!H", self.type))
1824 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1825 packed.append('\x00' * 4)
1826 packed.append(struct.pack("!H", self.rate))
1827 packed.append('\x00' * 6)
1828 length = sum([len(x) for x in packed])
1829 packed[1] = struct.pack("!H", length)
1830 return ''.join(packed)
1831
1832 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001833 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001834 obj = queue_prop_min_rate()
Dan Talaycof6202252013-07-02 01:00:29 -07001835 _type = reader.read("!H")[0]
1836 assert(_type == 1)
1837 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001838 orig_reader = reader
1839 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001840 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001841 obj.rate = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001842 reader.skip(6)
1843 return obj
1844
1845 def __eq__(self, other):
1846 if type(self) != type(other): return False
1847 if self.rate != other.rate: return False
1848 return True
1849
Rich Lanec2ee4b82013-04-24 17:12:38 -07001850 def pretty_print(self, q):
1851 q.text("queue_prop_min_rate {")
1852 with q.group():
1853 with q.indent(2):
1854 q.breakable()
1855 q.text("rate = ");
1856 q.text("%#x" % self.rate)
1857 q.breakable()
1858 q.text('}')
1859
Rich Lane7dcdf022013-12-11 14:45:27 -08001860queue_prop.subtypes[1] = queue_prop_min_rate
1861
1862class queue_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001863
1864 def __init__(self, port_no=None, queue_id=None, tx_bytes=None, tx_packets=None, tx_errors=None, duration_sec=None, duration_nsec=None):
1865 if port_no != None:
1866 self.port_no = port_no
1867 else:
1868 self.port_no = 0
1869 if queue_id != None:
1870 self.queue_id = queue_id
1871 else:
1872 self.queue_id = 0
1873 if tx_bytes != None:
1874 self.tx_bytes = tx_bytes
1875 else:
1876 self.tx_bytes = 0
1877 if tx_packets != None:
1878 self.tx_packets = tx_packets
1879 else:
1880 self.tx_packets = 0
1881 if tx_errors != None:
1882 self.tx_errors = tx_errors
1883 else:
1884 self.tx_errors = 0
1885 if duration_sec != None:
1886 self.duration_sec = duration_sec
1887 else:
1888 self.duration_sec = 0
1889 if duration_nsec != None:
1890 self.duration_nsec = duration_nsec
1891 else:
1892 self.duration_nsec = 0
1893 return
1894
1895 def pack(self):
1896 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07001897 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001898 packed.append(struct.pack("!L", self.queue_id))
1899 packed.append(struct.pack("!Q", self.tx_bytes))
1900 packed.append(struct.pack("!Q", self.tx_packets))
1901 packed.append(struct.pack("!Q", self.tx_errors))
1902 packed.append(struct.pack("!L", self.duration_sec))
1903 packed.append(struct.pack("!L", self.duration_nsec))
1904 return ''.join(packed)
1905
1906 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001907 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001908 obj = queue_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001909 obj.port_no = util.unpack_port_no(reader)
1910 obj.queue_id = reader.read("!L")[0]
1911 obj.tx_bytes = reader.read("!Q")[0]
1912 obj.tx_packets = reader.read("!Q")[0]
1913 obj.tx_errors = reader.read("!Q")[0]
1914 obj.duration_sec = reader.read("!L")[0]
1915 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001916 return obj
1917
1918 def __eq__(self, other):
1919 if type(self) != type(other): return False
1920 if self.port_no != other.port_no: return False
1921 if self.queue_id != other.queue_id: return False
1922 if self.tx_bytes != other.tx_bytes: return False
1923 if self.tx_packets != other.tx_packets: return False
1924 if self.tx_errors != other.tx_errors: return False
1925 if self.duration_sec != other.duration_sec: return False
1926 if self.duration_nsec != other.duration_nsec: return False
1927 return True
1928
Rich Lanec2ee4b82013-04-24 17:12:38 -07001929 def pretty_print(self, q):
1930 q.text("queue_stats_entry {")
1931 with q.group():
1932 with q.indent(2):
1933 q.breakable()
1934 q.text("port_no = ");
1935 q.text(util.pretty_port(self.port_no))
1936 q.text(","); q.breakable()
1937 q.text("queue_id = ");
1938 q.text("%#x" % self.queue_id)
1939 q.text(","); q.breakable()
1940 q.text("tx_bytes = ");
1941 q.text("%#x" % self.tx_bytes)
1942 q.text(","); q.breakable()
1943 q.text("tx_packets = ");
1944 q.text("%#x" % self.tx_packets)
1945 q.text(","); q.breakable()
1946 q.text("tx_errors = ");
1947 q.text("%#x" % self.tx_errors)
1948 q.text(","); q.breakable()
1949 q.text("duration_sec = ");
1950 q.text("%#x" % self.duration_sec)
1951 q.text(","); q.breakable()
1952 q.text("duration_nsec = ");
1953 q.text("%#x" % self.duration_nsec)
1954 q.breakable()
1955 q.text('}')
1956
Rich Lane7dcdf022013-12-11 14:45:27 -08001957
1958class table_feature_prop(loxi.OFObject):
1959 subtypes = {}
1960
1961 @staticmethod
1962 def unpack(reader):
1963 subtype, = reader.peek('!H', 0)
1964 try:
1965 subclass = table_feature_prop.subtypes[subtype]
1966 except KeyError:
1967 raise loxi.ProtocolError("unknown table_feature_prop subtype %#x" % subtype)
1968 return subclass.unpack(reader)
1969
1970
1971class table_feature_prop_apply_actions(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07001972 type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07001973
Dan Talaycof6202252013-07-02 01:00:29 -07001974 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001975 if action_ids != None:
1976 self.action_ids = action_ids
1977 else:
1978 self.action_ids = []
1979 return
1980
1981 def pack(self):
1982 packed = []
1983 packed.append(struct.pack("!H", self.type))
1984 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08001985 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001986 length = sum([len(x) for x in packed])
1987 packed[1] = struct.pack("!H", length)
1988 return ''.join(packed)
1989
1990 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001991 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001992 obj = table_feature_prop_apply_actions()
Dan Talaycof6202252013-07-02 01:00:29 -07001993 _type = reader.read("!H")[0]
1994 assert(_type == 6)
1995 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001996 orig_reader = reader
1997 reader = orig_reader.slice(_length - (2 + 2))
1998 obj.action_ids = loxi.generic_util.unpack_list(reader, action_id.action_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001999 return obj
2000
2001 def __eq__(self, other):
2002 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002003 if self.action_ids != other.action_ids: return False
2004 return True
2005
Rich Lanec2ee4b82013-04-24 17:12:38 -07002006 def pretty_print(self, q):
2007 q.text("table_feature_prop_apply_actions {")
2008 with q.group():
2009 with q.indent(2):
2010 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002011 q.text("action_ids = ");
2012 q.pp(self.action_ids)
2013 q.breakable()
2014 q.text('}')
2015
Rich Lane7dcdf022013-12-11 14:45:27 -08002016table_feature_prop.subtypes[6] = table_feature_prop_apply_actions
2017
2018class table_feature_prop_apply_actions_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002019 type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07002020
Dan Talaycof6202252013-07-02 01:00:29 -07002021 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002022 if action_ids != None:
2023 self.action_ids = action_ids
2024 else:
2025 self.action_ids = []
2026 return
2027
2028 def pack(self):
2029 packed = []
2030 packed.append(struct.pack("!H", self.type))
2031 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002032 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002033 length = sum([len(x) for x in packed])
2034 packed[1] = struct.pack("!H", length)
2035 return ''.join(packed)
2036
2037 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002038 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002039 obj = table_feature_prop_apply_actions_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07002040 _type = reader.read("!H")[0]
2041 assert(_type == 7)
2042 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002043 orig_reader = reader
2044 reader = orig_reader.slice(_length - (2 + 2))
2045 obj.action_ids = loxi.generic_util.unpack_list(reader, action_id.action_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002046 return obj
2047
2048 def __eq__(self, other):
2049 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002050 if self.action_ids != other.action_ids: return False
2051 return True
2052
Rich Lanec2ee4b82013-04-24 17:12:38 -07002053 def pretty_print(self, q):
2054 q.text("table_feature_prop_apply_actions_miss {")
2055 with q.group():
2056 with q.indent(2):
2057 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002058 q.text("action_ids = ");
2059 q.pp(self.action_ids)
2060 q.breakable()
2061 q.text('}')
2062
Rich Lane7dcdf022013-12-11 14:45:27 -08002063table_feature_prop.subtypes[7] = table_feature_prop_apply_actions_miss
2064
2065class table_feature_prop_apply_setfield(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002066 type = 14
Rich Lanec2ee4b82013-04-24 17:12:38 -07002067
Dan Talaycof6202252013-07-02 01:00:29 -07002068 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002069 if oxm_ids != None:
2070 self.oxm_ids = oxm_ids
2071 else:
2072 self.oxm_ids = []
2073 return
2074
2075 def pack(self):
2076 packed = []
2077 packed.append(struct.pack("!H", self.type))
2078 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002079 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002080 length = sum([len(x) for x in packed])
2081 packed[1] = struct.pack("!H", length)
2082 return ''.join(packed)
2083
2084 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002085 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002086 obj = table_feature_prop_apply_setfield()
Dan Talaycof6202252013-07-02 01:00:29 -07002087 _type = reader.read("!H")[0]
2088 assert(_type == 14)
2089 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002090 orig_reader = reader
2091 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002092 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
2093 return obj
2094
2095 def __eq__(self, other):
2096 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002097 if self.oxm_ids != other.oxm_ids: return False
2098 return True
2099
Rich Lanec2ee4b82013-04-24 17:12:38 -07002100 def pretty_print(self, q):
2101 q.text("table_feature_prop_apply_setfield {")
2102 with q.group():
2103 with q.indent(2):
2104 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002105 q.text("oxm_ids = ");
2106 q.pp(self.oxm_ids)
2107 q.breakable()
2108 q.text('}')
2109
Rich Lane7dcdf022013-12-11 14:45:27 -08002110table_feature_prop.subtypes[14] = table_feature_prop_apply_setfield
2111
2112class table_feature_prop_apply_setfield_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002113 type = 15
Rich Lanec2ee4b82013-04-24 17:12:38 -07002114
Dan Talaycof6202252013-07-02 01:00:29 -07002115 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002116 if oxm_ids != None:
2117 self.oxm_ids = oxm_ids
2118 else:
2119 self.oxm_ids = []
2120 return
2121
2122 def pack(self):
2123 packed = []
2124 packed.append(struct.pack("!H", self.type))
2125 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002126 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002127 length = sum([len(x) for x in packed])
2128 packed[1] = struct.pack("!H", length)
2129 return ''.join(packed)
2130
2131 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002132 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002133 obj = table_feature_prop_apply_setfield_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07002134 _type = reader.read("!H")[0]
2135 assert(_type == 15)
2136 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002137 orig_reader = reader
2138 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002139 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
2140 return obj
2141
2142 def __eq__(self, other):
2143 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002144 if self.oxm_ids != other.oxm_ids: return False
2145 return True
2146
Rich Lanec2ee4b82013-04-24 17:12:38 -07002147 def pretty_print(self, q):
2148 q.text("table_feature_prop_apply_setfield_miss {")
2149 with q.group():
2150 with q.indent(2):
2151 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002152 q.text("oxm_ids = ");
2153 q.pp(self.oxm_ids)
2154 q.breakable()
2155 q.text('}')
2156
Rich Lane7dcdf022013-12-11 14:45:27 -08002157table_feature_prop.subtypes[15] = table_feature_prop_apply_setfield_miss
2158
2159class table_feature_prop_experimenter(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002160 type = 65535
Rich Lanec2ee4b82013-04-24 17:12:38 -07002161
Dan Talaycof6202252013-07-02 01:00:29 -07002162 def __init__(self, experimenter=None, subtype=None, experimenter_data=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002163 if experimenter != None:
2164 self.experimenter = experimenter
2165 else:
2166 self.experimenter = 0
2167 if subtype != None:
2168 self.subtype = subtype
2169 else:
2170 self.subtype = 0
2171 if experimenter_data != None:
2172 self.experimenter_data = experimenter_data
2173 else:
Dan Talaycof6202252013-07-02 01:00:29 -07002174 self.experimenter_data = ''
Rich Lanec2ee4b82013-04-24 17:12:38 -07002175 return
2176
2177 def pack(self):
2178 packed = []
2179 packed.append(struct.pack("!H", self.type))
2180 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
2181 packed.append(struct.pack("!L", self.experimenter))
2182 packed.append(struct.pack("!L", self.subtype))
2183 packed.append(self.experimenter_data)
2184 length = sum([len(x) for x in packed])
2185 packed[1] = struct.pack("!H", length)
2186 return ''.join(packed)
2187
2188 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002189 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002190 obj = table_feature_prop_experimenter()
Dan Talaycof6202252013-07-02 01:00:29 -07002191 _type = reader.read("!H")[0]
2192 assert(_type == 65535)
2193 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002194 orig_reader = reader
2195 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002196 obj.experimenter = reader.read("!L")[0]
2197 obj.subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002198 obj.experimenter_data = str(reader.read_all())
2199 return obj
2200
2201 def __eq__(self, other):
2202 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002203 if self.experimenter != other.experimenter: return False
2204 if self.subtype != other.subtype: return False
2205 if self.experimenter_data != other.experimenter_data: return False
2206 return True
2207
Rich Lanec2ee4b82013-04-24 17:12:38 -07002208 def pretty_print(self, q):
2209 q.text("table_feature_prop_experimenter {")
2210 with q.group():
2211 with q.indent(2):
2212 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002213 q.text("experimenter = ");
2214 q.text("%#x" % self.experimenter)
2215 q.text(","); q.breakable()
2216 q.text("subtype = ");
2217 q.text("%#x" % self.subtype)
2218 q.text(","); q.breakable()
2219 q.text("experimenter_data = ");
2220 q.pp(self.experimenter_data)
2221 q.breakable()
2222 q.text('}')
2223
Rich Lane7dcdf022013-12-11 14:45:27 -08002224table_feature_prop.subtypes[65535] = table_feature_prop_experimenter
2225
2226class table_feature_prop_instructions(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002227 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07002228
Dan Talaycof6202252013-07-02 01:00:29 -07002229 def __init__(self, instruction_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002230 if instruction_ids != None:
2231 self.instruction_ids = instruction_ids
2232 else:
2233 self.instruction_ids = []
2234 return
2235
2236 def pack(self):
2237 packed = []
2238 packed.append(struct.pack("!H", self.type))
2239 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002240 packed.append(loxi.generic_util.pack_list(self.instruction_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002241 length = sum([len(x) for x in packed])
2242 packed[1] = struct.pack("!H", length)
2243 return ''.join(packed)
2244
2245 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002246 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002247 obj = table_feature_prop_instructions()
Dan Talaycof6202252013-07-02 01:00:29 -07002248 _type = reader.read("!H")[0]
2249 assert(_type == 0)
2250 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002251 orig_reader = reader
2252 reader = orig_reader.slice(_length - (2 + 2))
2253 obj.instruction_ids = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002254 return obj
2255
2256 def __eq__(self, other):
2257 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002258 if self.instruction_ids != other.instruction_ids: return False
2259 return True
2260
Rich Lanec2ee4b82013-04-24 17:12:38 -07002261 def pretty_print(self, q):
2262 q.text("table_feature_prop_instructions {")
2263 with q.group():
2264 with q.indent(2):
2265 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002266 q.text("instruction_ids = ");
2267 q.pp(self.instruction_ids)
2268 q.breakable()
2269 q.text('}')
2270
Rich Lane7dcdf022013-12-11 14:45:27 -08002271table_feature_prop.subtypes[0] = table_feature_prop_instructions
2272
2273class table_feature_prop_instructions_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002274 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07002275
Dan Talaycof6202252013-07-02 01:00:29 -07002276 def __init__(self, instruction_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002277 if instruction_ids != None:
2278 self.instruction_ids = instruction_ids
2279 else:
2280 self.instruction_ids = []
2281 return
2282
2283 def pack(self):
2284 packed = []
2285 packed.append(struct.pack("!H", self.type))
2286 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002287 packed.append(loxi.generic_util.pack_list(self.instruction_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002288 length = sum([len(x) for x in packed])
2289 packed[1] = struct.pack("!H", length)
2290 return ''.join(packed)
2291
2292 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002293 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002294 obj = table_feature_prop_instructions_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07002295 _type = reader.read("!H")[0]
2296 assert(_type == 1)
2297 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002298 orig_reader = reader
2299 reader = orig_reader.slice(_length - (2 + 2))
2300 obj.instruction_ids = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002301 return obj
2302
2303 def __eq__(self, other):
2304 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002305 if self.instruction_ids != other.instruction_ids: return False
2306 return True
2307
Rich Lanec2ee4b82013-04-24 17:12:38 -07002308 def pretty_print(self, q):
2309 q.text("table_feature_prop_instructions_miss {")
2310 with q.group():
2311 with q.indent(2):
2312 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002313 q.text("instruction_ids = ");
2314 q.pp(self.instruction_ids)
2315 q.breakable()
2316 q.text('}')
2317
Rich Lane7dcdf022013-12-11 14:45:27 -08002318table_feature_prop.subtypes[1] = table_feature_prop_instructions_miss
2319
2320class table_feature_prop_match(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002321 type = 8
Rich Lanec2ee4b82013-04-24 17:12:38 -07002322
Dan Talaycof6202252013-07-02 01:00:29 -07002323 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002324 if oxm_ids != None:
2325 self.oxm_ids = oxm_ids
2326 else:
2327 self.oxm_ids = []
2328 return
2329
2330 def pack(self):
2331 packed = []
2332 packed.append(struct.pack("!H", self.type))
2333 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002334 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002335 length = sum([len(x) for x in packed])
2336 packed[1] = struct.pack("!H", length)
2337 return ''.join(packed)
2338
2339 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002340 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002341 obj = table_feature_prop_match()
Dan Talaycof6202252013-07-02 01:00:29 -07002342 _type = reader.read("!H")[0]
2343 assert(_type == 8)
2344 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002345 orig_reader = reader
2346 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002347 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
2348 return obj
2349
2350 def __eq__(self, other):
2351 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002352 if self.oxm_ids != other.oxm_ids: return False
2353 return True
2354
Rich Lanec2ee4b82013-04-24 17:12:38 -07002355 def pretty_print(self, q):
2356 q.text("table_feature_prop_match {")
2357 with q.group():
2358 with q.indent(2):
2359 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002360 q.text("oxm_ids = ");
2361 q.pp(self.oxm_ids)
2362 q.breakable()
2363 q.text('}')
2364
Rich Lane7dcdf022013-12-11 14:45:27 -08002365table_feature_prop.subtypes[8] = table_feature_prop_match
2366
2367class table_feature_prop_next_tables(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002368 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07002369
Dan Talaycof6202252013-07-02 01:00:29 -07002370 def __init__(self, next_table_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002371 if next_table_ids != None:
2372 self.next_table_ids = next_table_ids
2373 else:
2374 self.next_table_ids = []
2375 return
2376
2377 def pack(self):
2378 packed = []
2379 packed.append(struct.pack("!H", self.type))
2380 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002381 packed.append(loxi.generic_util.pack_list(self.next_table_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002382 length = sum([len(x) for x in packed])
2383 packed[1] = struct.pack("!H", length)
2384 return ''.join(packed)
2385
2386 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002387 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002388 obj = table_feature_prop_next_tables()
Dan Talaycof6202252013-07-02 01:00:29 -07002389 _type = reader.read("!H")[0]
2390 assert(_type == 2)
2391 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002392 orig_reader = reader
2393 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002394 obj.next_table_ids = loxi.generic_util.unpack_list(reader, common.uint8.unpack)
2395 return obj
2396
2397 def __eq__(self, other):
2398 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002399 if self.next_table_ids != other.next_table_ids: return False
2400 return True
2401
Rich Lanec2ee4b82013-04-24 17:12:38 -07002402 def pretty_print(self, q):
2403 q.text("table_feature_prop_next_tables {")
2404 with q.group():
2405 with q.indent(2):
2406 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002407 q.text("next_table_ids = ");
2408 q.pp(self.next_table_ids)
2409 q.breakable()
2410 q.text('}')
2411
Rich Lane7dcdf022013-12-11 14:45:27 -08002412table_feature_prop.subtypes[2] = table_feature_prop_next_tables
2413
2414class table_feature_prop_next_tables_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002415 type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07002416
Dan Talaycof6202252013-07-02 01:00:29 -07002417 def __init__(self, next_table_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002418 if next_table_ids != None:
2419 self.next_table_ids = next_table_ids
2420 else:
2421 self.next_table_ids = []
2422 return
2423
2424 def pack(self):
2425 packed = []
2426 packed.append(struct.pack("!H", self.type))
2427 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002428 packed.append(loxi.generic_util.pack_list(self.next_table_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002429 length = sum([len(x) for x in packed])
2430 packed[1] = struct.pack("!H", length)
2431 return ''.join(packed)
2432
2433 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002434 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002435 obj = table_feature_prop_next_tables_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07002436 _type = reader.read("!H")[0]
2437 assert(_type == 3)
2438 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002439 orig_reader = reader
2440 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002441 obj.next_table_ids = loxi.generic_util.unpack_list(reader, common.uint8.unpack)
2442 return obj
2443
2444 def __eq__(self, other):
2445 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002446 if self.next_table_ids != other.next_table_ids: return False
2447 return True
2448
Rich Lanec2ee4b82013-04-24 17:12:38 -07002449 def pretty_print(self, q):
2450 q.text("table_feature_prop_next_tables_miss {")
2451 with q.group():
2452 with q.indent(2):
2453 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002454 q.text("next_table_ids = ");
2455 q.pp(self.next_table_ids)
2456 q.breakable()
2457 q.text('}')
2458
Rich Lane7dcdf022013-12-11 14:45:27 -08002459table_feature_prop.subtypes[3] = table_feature_prop_next_tables_miss
2460
2461class table_feature_prop_wildcards(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002462 type = 10
Rich Lanec2ee4b82013-04-24 17:12:38 -07002463
Dan Talaycof6202252013-07-02 01:00:29 -07002464 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002465 if oxm_ids != None:
2466 self.oxm_ids = oxm_ids
2467 else:
2468 self.oxm_ids = []
2469 return
2470
2471 def pack(self):
2472 packed = []
2473 packed.append(struct.pack("!H", self.type))
2474 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002475 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002476 length = sum([len(x) for x in packed])
2477 packed[1] = struct.pack("!H", length)
2478 return ''.join(packed)
2479
2480 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002481 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002482 obj = table_feature_prop_wildcards()
Dan Talaycof6202252013-07-02 01:00:29 -07002483 _type = reader.read("!H")[0]
2484 assert(_type == 10)
2485 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002486 orig_reader = reader
2487 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002488 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
2489 return obj
2490
2491 def __eq__(self, other):
2492 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002493 if self.oxm_ids != other.oxm_ids: return False
2494 return True
2495
Rich Lanec2ee4b82013-04-24 17:12:38 -07002496 def pretty_print(self, q):
2497 q.text("table_feature_prop_wildcards {")
2498 with q.group():
2499 with q.indent(2):
2500 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002501 q.text("oxm_ids = ");
2502 q.pp(self.oxm_ids)
2503 q.breakable()
2504 q.text('}')
2505
Rich Lane7dcdf022013-12-11 14:45:27 -08002506table_feature_prop.subtypes[10] = table_feature_prop_wildcards
2507
2508class table_feature_prop_write_actions(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002509 type = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07002510
Dan Talaycof6202252013-07-02 01:00:29 -07002511 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002512 if action_ids != None:
2513 self.action_ids = action_ids
2514 else:
2515 self.action_ids = []
2516 return
2517
2518 def pack(self):
2519 packed = []
2520 packed.append(struct.pack("!H", self.type))
2521 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002522 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002523 length = sum([len(x) for x in packed])
2524 packed[1] = struct.pack("!H", length)
2525 return ''.join(packed)
2526
2527 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002528 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002529 obj = table_feature_prop_write_actions()
Dan Talaycof6202252013-07-02 01:00:29 -07002530 _type = reader.read("!H")[0]
2531 assert(_type == 4)
2532 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002533 orig_reader = reader
2534 reader = orig_reader.slice(_length - (2 + 2))
2535 obj.action_ids = loxi.generic_util.unpack_list(reader, action_id.action_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002536 return obj
2537
2538 def __eq__(self, other):
2539 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002540 if self.action_ids != other.action_ids: return False
2541 return True
2542
Rich Lanec2ee4b82013-04-24 17:12:38 -07002543 def pretty_print(self, q):
2544 q.text("table_feature_prop_write_actions {")
2545 with q.group():
2546 with q.indent(2):
2547 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002548 q.text("action_ids = ");
2549 q.pp(self.action_ids)
2550 q.breakable()
2551 q.text('}')
2552
Rich Lane7dcdf022013-12-11 14:45:27 -08002553table_feature_prop.subtypes[4] = table_feature_prop_write_actions
2554
2555class table_feature_prop_write_actions_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002556 type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07002557
Dan Talaycof6202252013-07-02 01:00:29 -07002558 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002559 if action_ids != None:
2560 self.action_ids = action_ids
2561 else:
2562 self.action_ids = []
2563 return
2564
2565 def pack(self):
2566 packed = []
2567 packed.append(struct.pack("!H", self.type))
2568 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002569 packed.append(loxi.generic_util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002570 length = sum([len(x) for x in packed])
2571 packed[1] = struct.pack("!H", length)
2572 return ''.join(packed)
2573
2574 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002575 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002576 obj = table_feature_prop_write_actions_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07002577 _type = reader.read("!H")[0]
2578 assert(_type == 5)
2579 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002580 orig_reader = reader
2581 reader = orig_reader.slice(_length - (2 + 2))
2582 obj.action_ids = loxi.generic_util.unpack_list(reader, action_id.action_id.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002583 return obj
2584
2585 def __eq__(self, other):
2586 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002587 if self.action_ids != other.action_ids: return False
2588 return True
2589
Rich Lanec2ee4b82013-04-24 17:12:38 -07002590 def pretty_print(self, q):
2591 q.text("table_feature_prop_write_actions_miss {")
2592 with q.group():
2593 with q.indent(2):
2594 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002595 q.text("action_ids = ");
2596 q.pp(self.action_ids)
2597 q.breakable()
2598 q.text('}')
2599
Rich Lane7dcdf022013-12-11 14:45:27 -08002600table_feature_prop.subtypes[5] = table_feature_prop_write_actions_miss
2601
2602class table_feature_prop_write_setfield(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002603 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -07002604
Dan Talaycof6202252013-07-02 01:00:29 -07002605 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002606 if oxm_ids != None:
2607 self.oxm_ids = oxm_ids
2608 else:
2609 self.oxm_ids = []
2610 return
2611
2612 def pack(self):
2613 packed = []
2614 packed.append(struct.pack("!H", self.type))
2615 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002616 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002617 length = sum([len(x) for x in packed])
2618 packed[1] = struct.pack("!H", length)
2619 return ''.join(packed)
2620
2621 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002622 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002623 obj = table_feature_prop_write_setfield()
Dan Talaycof6202252013-07-02 01:00:29 -07002624 _type = reader.read("!H")[0]
2625 assert(_type == 12)
2626 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002627 orig_reader = reader
2628 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002629 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
2630 return obj
2631
2632 def __eq__(self, other):
2633 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002634 if self.oxm_ids != other.oxm_ids: return False
2635 return True
2636
Rich Lanec2ee4b82013-04-24 17:12:38 -07002637 def pretty_print(self, q):
2638 q.text("table_feature_prop_write_setfield {")
2639 with q.group():
2640 with q.indent(2):
2641 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002642 q.text("oxm_ids = ");
2643 q.pp(self.oxm_ids)
2644 q.breakable()
2645 q.text('}')
2646
Rich Lane7dcdf022013-12-11 14:45:27 -08002647table_feature_prop.subtypes[12] = table_feature_prop_write_setfield
2648
2649class table_feature_prop_write_setfield_miss(table_feature_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07002650 type = 13
Rich Lanec2ee4b82013-04-24 17:12:38 -07002651
Dan Talaycof6202252013-07-02 01:00:29 -07002652 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002653 if oxm_ids != None:
2654 self.oxm_ids = oxm_ids
2655 else:
2656 self.oxm_ids = []
2657 return
2658
2659 def pack(self):
2660 packed = []
2661 packed.append(struct.pack("!H", self.type))
2662 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -08002663 packed.append(loxi.generic_util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002664 length = sum([len(x) for x in packed])
2665 packed[1] = struct.pack("!H", length)
2666 return ''.join(packed)
2667
2668 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002669 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002670 obj = table_feature_prop_write_setfield_miss()
Dan Talaycof6202252013-07-02 01:00:29 -07002671 _type = reader.read("!H")[0]
2672 assert(_type == 13)
2673 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002674 orig_reader = reader
2675 reader = orig_reader.slice(_length - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002676 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
2677 return obj
2678
2679 def __eq__(self, other):
2680 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002681 if self.oxm_ids != other.oxm_ids: return False
2682 return True
2683
Rich Lanec2ee4b82013-04-24 17:12:38 -07002684 def pretty_print(self, q):
2685 q.text("table_feature_prop_write_setfield_miss {")
2686 with q.group():
2687 with q.indent(2):
2688 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002689 q.text("oxm_ids = ");
2690 q.pp(self.oxm_ids)
2691 q.breakable()
2692 q.text('}')
2693
Rich Lane7dcdf022013-12-11 14:45:27 -08002694table_feature_prop.subtypes[13] = table_feature_prop_write_setfield_miss
2695
2696class table_features(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002697
2698 def __init__(self, table_id=None, name=None, metadata_match=None, metadata_write=None, config=None, max_entries=None, properties=None):
2699 if table_id != None:
2700 self.table_id = table_id
2701 else:
2702 self.table_id = 0
2703 if name != None:
2704 self.name = name
2705 else:
2706 self.name = ""
2707 if metadata_match != None:
2708 self.metadata_match = metadata_match
2709 else:
2710 self.metadata_match = 0
2711 if metadata_write != None:
2712 self.metadata_write = metadata_write
2713 else:
2714 self.metadata_write = 0
2715 if config != None:
2716 self.config = config
2717 else:
2718 self.config = 0
2719 if max_entries != None:
2720 self.max_entries = max_entries
2721 else:
2722 self.max_entries = 0
2723 if properties != None:
2724 self.properties = properties
2725 else:
2726 self.properties = []
2727 return
2728
2729 def pack(self):
2730 packed = []
2731 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
2732 packed.append(struct.pack("!B", self.table_id))
2733 packed.append('\x00' * 5)
2734 packed.append(struct.pack("!32s", self.name))
2735 packed.append(struct.pack("!Q", self.metadata_match))
2736 packed.append(struct.pack("!Q", self.metadata_write))
2737 packed.append(struct.pack("!L", self.config))
2738 packed.append(struct.pack("!L", self.max_entries))
Rich Lane7dcdf022013-12-11 14:45:27 -08002739 packed.append(loxi.generic_util.pack_list(self.properties))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002740 length = sum([len(x) for x in packed])
2741 packed[0] = struct.pack("!H", length)
2742 return ''.join(packed)
2743
2744 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002745 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002746 obj = table_features()
Dan Talaycof6202252013-07-02 01:00:29 -07002747 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002748 orig_reader = reader
2749 reader = orig_reader.slice(_length - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07002750 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002751 reader.skip(5)
2752 obj.name = reader.read("!32s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -07002753 obj.metadata_match = reader.read("!Q")[0]
2754 obj.metadata_write = reader.read("!Q")[0]
2755 obj.config = reader.read("!L")[0]
2756 obj.max_entries = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08002757 obj.properties = loxi.generic_util.unpack_list(reader, common.table_feature_prop.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -07002758 return obj
2759
2760 def __eq__(self, other):
2761 if type(self) != type(other): return False
2762 if self.table_id != other.table_id: return False
2763 if self.name != other.name: return False
2764 if self.metadata_match != other.metadata_match: return False
2765 if self.metadata_write != other.metadata_write: return False
2766 if self.config != other.config: return False
2767 if self.max_entries != other.max_entries: return False
2768 if self.properties != other.properties: return False
2769 return True
2770
Rich Lanec2ee4b82013-04-24 17:12:38 -07002771 def pretty_print(self, q):
2772 q.text("table_features {")
2773 with q.group():
2774 with q.indent(2):
2775 q.breakable()
2776 q.text("table_id = ");
2777 q.text("%#x" % self.table_id)
2778 q.text(","); q.breakable()
2779 q.text("name = ");
2780 q.pp(self.name)
2781 q.text(","); q.breakable()
2782 q.text("metadata_match = ");
2783 q.text("%#x" % self.metadata_match)
2784 q.text(","); q.breakable()
2785 q.text("metadata_write = ");
2786 q.text("%#x" % self.metadata_write)
2787 q.text(","); q.breakable()
2788 q.text("config = ");
2789 q.text("%#x" % self.config)
2790 q.text(","); q.breakable()
2791 q.text("max_entries = ");
2792 q.text("%#x" % self.max_entries)
2793 q.text(","); q.breakable()
2794 q.text("properties = ");
2795 q.pp(self.properties)
2796 q.breakable()
2797 q.text('}')
2798
Rich Lane7dcdf022013-12-11 14:45:27 -08002799
2800class table_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002801
2802 def __init__(self, table_id=None, active_count=None, lookup_count=None, matched_count=None):
2803 if table_id != None:
2804 self.table_id = table_id
2805 else:
2806 self.table_id = 0
2807 if active_count != None:
2808 self.active_count = active_count
2809 else:
2810 self.active_count = 0
2811 if lookup_count != None:
2812 self.lookup_count = lookup_count
2813 else:
2814 self.lookup_count = 0
2815 if matched_count != None:
2816 self.matched_count = matched_count
2817 else:
2818 self.matched_count = 0
2819 return
2820
2821 def pack(self):
2822 packed = []
2823 packed.append(struct.pack("!B", self.table_id))
2824 packed.append('\x00' * 3)
2825 packed.append(struct.pack("!L", self.active_count))
2826 packed.append(struct.pack("!Q", self.lookup_count))
2827 packed.append(struct.pack("!Q", self.matched_count))
2828 return ''.join(packed)
2829
2830 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002831 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002832 obj = table_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07002833 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002834 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07002835 obj.active_count = reader.read("!L")[0]
2836 obj.lookup_count = reader.read("!Q")[0]
2837 obj.matched_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002838 return obj
2839
2840 def __eq__(self, other):
2841 if type(self) != type(other): return False
2842 if self.table_id != other.table_id: return False
2843 if self.active_count != other.active_count: return False
2844 if self.lookup_count != other.lookup_count: return False
2845 if self.matched_count != other.matched_count: return False
2846 return True
2847
Rich Lanec2ee4b82013-04-24 17:12:38 -07002848 def pretty_print(self, q):
2849 q.text("table_stats_entry {")
2850 with q.group():
2851 with q.indent(2):
2852 q.breakable()
2853 q.text("table_id = ");
2854 q.text("%#x" % self.table_id)
2855 q.text(","); q.breakable()
2856 q.text("active_count = ");
2857 q.text("%#x" % self.active_count)
2858 q.text(","); q.breakable()
2859 q.text("lookup_count = ");
2860 q.text("%#x" % self.lookup_count)
2861 q.text(","); q.breakable()
2862 q.text("matched_count = ");
2863 q.text("%#x" % self.matched_count)
2864 q.breakable()
2865 q.text('}')
2866
Rich Lane7dcdf022013-12-11 14:45:27 -08002867
2868class uint32(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002869
2870 def __init__(self, value=None):
2871 if value != None:
2872 self.value = value
2873 else:
2874 self.value = 0
2875 return
2876
2877 def pack(self):
2878 packed = []
2879 packed.append(struct.pack("!L", self.value))
2880 return ''.join(packed)
2881
2882 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002883 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002884 obj = uint32()
Dan Talaycof6202252013-07-02 01:00:29 -07002885 obj.value = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002886 return obj
2887
2888 def __eq__(self, other):
2889 if type(self) != type(other): return False
2890 if self.value != other.value: return False
2891 return True
2892
Rich Lanec2ee4b82013-04-24 17:12:38 -07002893 def pretty_print(self, q):
2894 q.text("uint32 {")
2895 with q.group():
2896 with q.indent(2):
2897 q.breakable()
2898 q.text("value = ");
2899 q.text("%#x" % self.value)
2900 q.breakable()
2901 q.text('}')
2902
Rich Lane7dcdf022013-12-11 14:45:27 -08002903
2904class uint64(loxi.OFObject):
2905
2906 def __init__(self, value=None):
2907 if value != None:
2908 self.value = value
2909 else:
2910 self.value = 0
2911 return
2912
2913 def pack(self):
2914 packed = []
2915 packed.append(struct.pack("!Q", self.value))
2916 return ''.join(packed)
2917
2918 @staticmethod
2919 def unpack(reader):
2920 obj = uint64()
2921 obj.value = reader.read("!Q")[0]
2922 return obj
2923
2924 def __eq__(self, other):
2925 if type(self) != type(other): return False
2926 if self.value != other.value: return False
2927 return True
2928
2929 def pretty_print(self, q):
2930 q.text("uint64 {")
2931 with q.group():
2932 with q.indent(2):
2933 q.breakable()
2934 q.text("value = ");
2935 q.text("%#x" % self.value)
2936 q.breakable()
2937 q.text('}')
2938
2939
2940class uint8(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002941
2942 def __init__(self, value=None):
2943 if value != None:
2944 self.value = value
2945 else:
2946 self.value = 0
2947 return
2948
2949 def pack(self):
2950 packed = []
2951 packed.append(struct.pack("!B", self.value))
2952 return ''.join(packed)
2953
2954 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08002955 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002956 obj = uint8()
Dan Talaycof6202252013-07-02 01:00:29 -07002957 obj.value = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002958 return obj
2959
2960 def __eq__(self, other):
2961 if type(self) != type(other): return False
2962 if self.value != other.value: return False
2963 return True
2964
Rich Lanec2ee4b82013-04-24 17:12:38 -07002965 def pretty_print(self, q):
2966 q.text("uint8 {")
2967 with q.group():
2968 with q.indent(2):
2969 q.breakable()
2970 q.text("value = ");
2971 q.text("%#x" % self.value)
2972 q.breakable()
2973 q.text('}')
2974
2975
Rich Lane7dcdf022013-12-11 14:45:27 -08002976
Rich Lanec2ee4b82013-04-24 17:12:38 -07002977match = match_v3