blob: ac984414546f41dbf2cd8fda170e8f8b520d2666 [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 Lanec2ee4b82013-04-24 17:12:38 -07005
6# Automatically generated by LOXI from template common.py
7# Do not modify
8
9import sys
10import struct
11import action
12import instruction # for unpack_list
13import meter_band # for unpack_list
14import const
15import util
16import loxi.generic_util
17
18import oxm
19
20# HACK make this module visible as 'common' to simplify code generation
21common = sys.modules[__name__]
22
23def unpack_list_flow_stats_entry(reader):
24 return loxi.generic_util.unpack_list_lv16(reader, flow_stats_entry.unpack)
25
26def unpack_list_queue_prop(reader):
27 def deserializer(reader, typ):
28 if typ == const.OFPQT_MIN_RATE:
29 return queue_prop_min_rate.unpack(reader)
30 else:
31 raise loxi.ProtocolError("unknown queue prop %d" % typ)
32 return loxi.generic_util.unpack_list_tlv16(reader, deserializer)
33
34def unpack_list_packet_queue(reader):
35 def wrapper(reader):
36 length, = reader.peek('!4xH')
37 return packet_queue.unpack(reader.slice(length))
38 return loxi.generic_util.unpack_list(reader, wrapper)
39
40def unpack_list_hello_elem(reader):
41 def deserializer(reader, typ):
42 if typ == const.OFPHET_VERSIONBITMAP:
43 return hello_elem_versionbitmap.unpack(reader)
44 else:
45 return None
46 return [x for x in loxi.generic_util.unpack_list_tlv16(reader, deserializer) if x != None]
47
48def unpack_list_bucket(reader):
49 return loxi.generic_util.unpack_list_lv16(reader, bucket.unpack)
50
51def unpack_list_group_desc_stats_entry(reader):
52 return loxi.generic_util.unpack_list_lv16(reader, group_desc_stats_entry.unpack)
53
54def unpack_list_group_stats_entry(reader):
55 return loxi.generic_util.unpack_list_lv16(reader, group_stats_entry.unpack)
56
57def unpack_list_meter_stats(reader):
58 def wrapper(reader):
59 length, = reader.peek('!4xH')
60 return meter_stats.unpack(reader.slice(length))
61 return loxi.generic_util.unpack_list(reader, wrapper)
62
Kiran Poolaae8fbf12013-09-19 16:32:32 -070063class action_id(object):
64
65 def __init__(self, type=None):
66 if type != None:
67 self.type = type
68 else:
69 self.type = 0
70 return
71
72 def pack(self):
73 packed = []
74 packed.append(struct.pack("!H", self.type))
75 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
76 packed.append('\x00' * 4)
77 length = sum([len(x) for x in packed])
78 packed[1] = struct.pack("!H", length)
79 return ''.join(packed)
80
81 @staticmethod
82 def unpack(buf):
83 obj = action_id()
84 if type(buf) == loxi.generic_util.OFReader:
85 reader = buf
86 else:
87 reader = loxi.generic_util.OFReader(buf)
88 obj.type = reader.read("!H")[0]
89 _len = reader.read("!H")[0]
90 reader.skip(4)
91 return obj
92
93 def __eq__(self, other):
94 if type(self) != type(other): return False
95 if self.type != other.type: return False
96 return True
97
98 def __ne__(self, other):
99 return not self.__eq__(other)
100
101 def show(self):
102 import loxi.pp
103 return loxi.pp.pp(self)
104
105 def pretty_print(self, q):
106 q.text("action_id {")
107 with q.group():
108 with q.indent(2):
109 q.breakable()
110 q.text("type = ");
111 q.text("%#x" % self.type)
112 q.breakable()
113 q.text('}')
114
Rich Lanec2ee4b82013-04-24 17:12:38 -0700115class bsn_interface(object):
116
117 def __init__(self, hw_addr=None, name=None, ipv4_addr=None, ipv4_netmask=None):
118 if hw_addr != None:
119 self.hw_addr = hw_addr
120 else:
121 self.hw_addr = [0,0,0,0,0,0]
122 if name != None:
123 self.name = name
124 else:
125 self.name = ""
126 if ipv4_addr != None:
127 self.ipv4_addr = ipv4_addr
128 else:
129 self.ipv4_addr = 0
130 if ipv4_netmask != None:
131 self.ipv4_netmask = ipv4_netmask
132 else:
133 self.ipv4_netmask = 0
134 return
135
136 def pack(self):
137 packed = []
138 packed.append(struct.pack("!6B", *self.hw_addr))
139 packed.append('\x00' * 2)
140 packed.append(struct.pack("!16s", self.name))
141 packed.append(struct.pack("!L", self.ipv4_addr))
142 packed.append(struct.pack("!L", self.ipv4_netmask))
143 return ''.join(packed)
144
145 @staticmethod
146 def unpack(buf):
147 obj = bsn_interface()
148 if type(buf) == loxi.generic_util.OFReader:
149 reader = buf
150 else:
151 reader = loxi.generic_util.OFReader(buf)
152 obj.hw_addr = list(reader.read('!6B'))
153 reader.skip(2)
154 obj.name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -0700155 obj.ipv4_addr = reader.read("!L")[0]
156 obj.ipv4_netmask = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700157 return obj
158
159 def __eq__(self, other):
160 if type(self) != type(other): return False
161 if self.hw_addr != other.hw_addr: return False
162 if self.name != other.name: return False
163 if self.ipv4_addr != other.ipv4_addr: return False
164 if self.ipv4_netmask != other.ipv4_netmask: return False
165 return True
166
167 def __ne__(self, other):
168 return not self.__eq__(other)
169
170 def show(self):
171 import loxi.pp
172 return loxi.pp.pp(self)
173
174 def pretty_print(self, q):
175 q.text("bsn_interface {")
176 with q.group():
177 with q.indent(2):
178 q.breakable()
179 q.text("hw_addr = ");
180 q.text(util.pretty_mac(self.hw_addr))
181 q.text(","); q.breakable()
182 q.text("name = ");
183 q.pp(self.name)
184 q.text(","); q.breakable()
185 q.text("ipv4_addr = ");
186 q.text(util.pretty_ipv4(self.ipv4_addr))
187 q.text(","); q.breakable()
188 q.text("ipv4_netmask = ");
189 q.text(util.pretty_ipv4(self.ipv4_netmask))
190 q.breakable()
191 q.text('}')
192
Dan Talaycof6202252013-07-02 01:00:29 -0700193class bsn_vport_q_in_q(object):
194 type = 0
195
Kiran Poolaae8fbf12013-09-19 16:32:32 -0700196 def __init__(self, if_name=None, port_no=None, ingress_tpid=None, ingress_vlan_id=None, egress_tpid=None, egress_vlan_id=None):
197 if if_name != None:
198 self.if_name = if_name
199 else:
200 self.if_name = ""
Dan Talaycof6202252013-07-02 01:00:29 -0700201 if port_no != None:
202 self.port_no = port_no
203 else:
204 self.port_no = 0
205 if ingress_tpid != None:
206 self.ingress_tpid = ingress_tpid
207 else:
208 self.ingress_tpid = 0
209 if ingress_vlan_id != None:
210 self.ingress_vlan_id = ingress_vlan_id
211 else:
212 self.ingress_vlan_id = 0
213 if egress_tpid != None:
214 self.egress_tpid = egress_tpid
215 else:
216 self.egress_tpid = 0
217 if egress_vlan_id != None:
218 self.egress_vlan_id = egress_vlan_id
219 else:
220 self.egress_vlan_id = 0
221 return
222
223 def pack(self):
224 packed = []
225 packed.append(struct.pack("!H", self.type))
Kiran Poolaae8fbf12013-09-19 16:32:32 -0700226 packed.append(struct.pack("!16s", self.if_name))
227 packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
Dan Talaycof6202252013-07-02 01:00:29 -0700228 packed.append(struct.pack("!L", self.port_no))
229 packed.append(struct.pack("!H", self.ingress_tpid))
230 packed.append(struct.pack("!H", self.ingress_vlan_id))
231 packed.append(struct.pack("!H", self.egress_tpid))
232 packed.append(struct.pack("!H", self.egress_vlan_id))
233 length = sum([len(x) for x in packed])
Kiran Poolaae8fbf12013-09-19 16:32:32 -0700234 packed[2] = struct.pack("!H", length)
Dan Talaycof6202252013-07-02 01:00:29 -0700235 return ''.join(packed)
236
237 @staticmethod
238 def unpack(buf):
239 obj = bsn_vport_q_in_q()
240 if type(buf) == loxi.generic_util.OFReader:
241 reader = buf
242 else:
243 reader = loxi.generic_util.OFReader(buf)
244 _type = reader.read("!H")[0]
245 assert(_type == 0)
Kiran Poolaae8fbf12013-09-19 16:32:32 -0700246 obj.if_name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -0700247 _length = reader.read("!H")[0]
248 obj.port_no = reader.read("!L")[0]
249 obj.ingress_tpid = reader.read("!H")[0]
250 obj.ingress_vlan_id = reader.read("!H")[0]
251 obj.egress_tpid = reader.read("!H")[0]
252 obj.egress_vlan_id = reader.read("!H")[0]
253 return obj
254
255 def __eq__(self, other):
256 if type(self) != type(other): return False
Kiran Poolaae8fbf12013-09-19 16:32:32 -0700257 if self.if_name != other.if_name: return False
Dan Talaycof6202252013-07-02 01:00:29 -0700258 if self.port_no != other.port_no: return False
259 if self.ingress_tpid != other.ingress_tpid: return False
260 if self.ingress_vlan_id != other.ingress_vlan_id: return False
261 if self.egress_tpid != other.egress_tpid: return False
262 if self.egress_vlan_id != other.egress_vlan_id: return False
263 return True
264
265 def __ne__(self, other):
266 return not self.__eq__(other)
267
268 def show(self):
269 import loxi.pp
270 return loxi.pp.pp(self)
271
272 def pretty_print(self, q):
273 q.text("bsn_vport_q_in_q {")
274 with q.group():
275 with q.indent(2):
276 q.breakable()
Kiran Poolaae8fbf12013-09-19 16:32:32 -0700277 q.text("if_name = ");
278 q.pp(self.if_name)
279 q.text(","); q.breakable()
Dan Talaycof6202252013-07-02 01:00:29 -0700280 q.text("port_no = ");
281 q.text("%#x" % self.port_no)
282 q.text(","); q.breakable()
283 q.text("ingress_tpid = ");
284 q.text("%#x" % self.ingress_tpid)
285 q.text(","); q.breakable()
286 q.text("ingress_vlan_id = ");
287 q.text("%#x" % self.ingress_vlan_id)
288 q.text(","); q.breakable()
289 q.text("egress_tpid = ");
290 q.text("%#x" % self.egress_tpid)
291 q.text(","); q.breakable()
292 q.text("egress_vlan_id = ");
293 q.text("%#x" % self.egress_vlan_id)
294 q.breakable()
295 q.text('}')
296
Rich Lanec2ee4b82013-04-24 17:12:38 -0700297class bucket(object):
298
299 def __init__(self, weight=None, watch_port=None, watch_group=None, actions=None):
300 if weight != None:
301 self.weight = weight
302 else:
303 self.weight = 0
304 if watch_port != None:
305 self.watch_port = watch_port
306 else:
307 self.watch_port = 0
308 if watch_group != None:
309 self.watch_group = watch_group
310 else:
311 self.watch_group = 0
312 if actions != None:
313 self.actions = actions
314 else:
315 self.actions = []
316 return
317
318 def pack(self):
319 packed = []
320 packed.append(struct.pack("!H", 0)) # placeholder for len at index 0
321 packed.append(struct.pack("!H", self.weight))
Dan Talaycof6202252013-07-02 01:00:29 -0700322 packed.append(util.pack_port_no(self.watch_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700323 packed.append(struct.pack("!L", self.watch_group))
324 packed.append('\x00' * 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700325 packed.append(util.pack_list(self.actions))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700326 length = sum([len(x) for x in packed])
327 packed[0] = struct.pack("!H", length)
328 return ''.join(packed)
329
330 @staticmethod
331 def unpack(buf):
332 obj = bucket()
333 if type(buf) == loxi.generic_util.OFReader:
334 reader = buf
335 else:
336 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -0700337 _len = reader.read("!H")[0]
338 obj.weight = reader.read("!H")[0]
339 obj.watch_port = util.unpack_port_no(reader)
340 obj.watch_group = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700341 reader.skip(4)
342 obj.actions = action.unpack_list(reader)
343 return obj
344
345 def __eq__(self, other):
346 if type(self) != type(other): return False
347 if self.weight != other.weight: return False
348 if self.watch_port != other.watch_port: return False
349 if self.watch_group != other.watch_group: return False
350 if self.actions != other.actions: return False
351 return True
352
353 def __ne__(self, other):
354 return not self.__eq__(other)
355
356 def show(self):
357 import loxi.pp
358 return loxi.pp.pp(self)
359
360 def pretty_print(self, q):
361 q.text("bucket {")
362 with q.group():
363 with q.indent(2):
364 q.breakable()
365 q.text("weight = ");
366 q.text("%#x" % self.weight)
367 q.text(","); q.breakable()
368 q.text("watch_port = ");
369 q.text(util.pretty_port(self.watch_port))
370 q.text(","); q.breakable()
371 q.text("watch_group = ");
372 q.text("%#x" % self.watch_group)
373 q.text(","); q.breakable()
374 q.text("actions = ");
375 q.pp(self.actions)
376 q.breakable()
377 q.text('}')
378
379class bucket_counter(object):
380
381 def __init__(self, packet_count=None, byte_count=None):
382 if packet_count != None:
383 self.packet_count = packet_count
384 else:
385 self.packet_count = 0
386 if byte_count != None:
387 self.byte_count = byte_count
388 else:
389 self.byte_count = 0
390 return
391
392 def pack(self):
393 packed = []
394 packed.append(struct.pack("!Q", self.packet_count))
395 packed.append(struct.pack("!Q", self.byte_count))
396 return ''.join(packed)
397
398 @staticmethod
399 def unpack(buf):
400 obj = bucket_counter()
401 if type(buf) == loxi.generic_util.OFReader:
402 reader = buf
403 else:
404 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -0700405 obj.packet_count = reader.read("!Q")[0]
406 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700407 return obj
408
409 def __eq__(self, other):
410 if type(self) != type(other): return False
411 if self.packet_count != other.packet_count: return False
412 if self.byte_count != other.byte_count: return False
413 return True
414
415 def __ne__(self, other):
416 return not self.__eq__(other)
417
418 def show(self):
419 import loxi.pp
420 return loxi.pp.pp(self)
421
422 def pretty_print(self, q):
423 q.text("bucket_counter {")
424 with q.group():
425 with q.indent(2):
426 q.breakable()
427 q.text("packet_count = ");
428 q.text("%#x" % self.packet_count)
429 q.text(","); q.breakable()
430 q.text("byte_count = ");
431 q.text("%#x" % self.byte_count)
432 q.breakable()
433 q.text('}')
434
435class flow_stats_entry(object):
436
Kiran Poolaae8fbf12013-09-19 16:32:32 -0700437 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 -0700438 if table_id != None:
439 self.table_id = table_id
440 else:
441 self.table_id = 0
442 if duration_sec != None:
443 self.duration_sec = duration_sec
444 else:
445 self.duration_sec = 0
446 if duration_nsec != None:
447 self.duration_nsec = duration_nsec
448 else:
449 self.duration_nsec = 0
450 if priority != None:
451 self.priority = priority
452 else:
453 self.priority = 0
454 if idle_timeout != None:
455 self.idle_timeout = idle_timeout
456 else:
457 self.idle_timeout = 0
458 if hard_timeout != None:
459 self.hard_timeout = hard_timeout
460 else:
461 self.hard_timeout = 0
Kiran Poolaae8fbf12013-09-19 16:32:32 -0700462 if flags != None:
463 self.flags = flags
464 else:
465 self.flags = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700466 if cookie != None:
467 self.cookie = cookie
468 else:
469 self.cookie = 0
470 if packet_count != None:
471 self.packet_count = packet_count
472 else:
473 self.packet_count = 0
474 if byte_count != None:
475 self.byte_count = byte_count
476 else:
477 self.byte_count = 0
478 if match != None:
479 self.match = match
480 else:
481 self.match = common.match()
482 if instructions != None:
483 self.instructions = instructions
484 else:
485 self.instructions = []
486 return
487
488 def pack(self):
489 packed = []
490 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
491 packed.append(struct.pack("!B", self.table_id))
492 packed.append('\x00' * 1)
493 packed.append(struct.pack("!L", self.duration_sec))
494 packed.append(struct.pack("!L", self.duration_nsec))
495 packed.append(struct.pack("!H", self.priority))
496 packed.append(struct.pack("!H", self.idle_timeout))
497 packed.append(struct.pack("!H", self.hard_timeout))
Kiran Poolaae8fbf12013-09-19 16:32:32 -0700498 packed.append(struct.pack("!H", self.flags))
499 packed.append('\x00' * 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700500 packed.append(struct.pack("!Q", self.cookie))
501 packed.append(struct.pack("!Q", self.packet_count))
502 packed.append(struct.pack("!Q", self.byte_count))
503 packed.append(self.match.pack())
Dan Talaycof6202252013-07-02 01:00:29 -0700504 packed.append(util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700505 length = sum([len(x) for x in packed])
506 packed[0] = struct.pack("!H", length)
507 return ''.join(packed)
508
509 @staticmethod
510 def unpack(buf):
511 obj = flow_stats_entry()
512 if type(buf) == loxi.generic_util.OFReader:
513 reader = buf
514 else:
515 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -0700516 _length = reader.read("!H")[0]
517 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700518 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -0700519 obj.duration_sec = reader.read("!L")[0]
520 obj.duration_nsec = reader.read("!L")[0]
521 obj.priority = reader.read("!H")[0]
522 obj.idle_timeout = reader.read("!H")[0]
523 obj.hard_timeout = reader.read("!H")[0]
Kiran Poolaae8fbf12013-09-19 16:32:32 -0700524 obj.flags = reader.read("!H")[0]
525 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -0700526 obj.cookie = reader.read("!Q")[0]
527 obj.packet_count = reader.read("!Q")[0]
528 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700529 obj.match = common.match.unpack(reader)
530 obj.instructions = instruction.unpack_list(reader)
531 return obj
532
533 def __eq__(self, other):
534 if type(self) != type(other): return False
535 if self.table_id != other.table_id: return False
536 if self.duration_sec != other.duration_sec: return False
537 if self.duration_nsec != other.duration_nsec: return False
538 if self.priority != other.priority: return False
539 if self.idle_timeout != other.idle_timeout: return False
540 if self.hard_timeout != other.hard_timeout: return False
Kiran Poolaae8fbf12013-09-19 16:32:32 -0700541 if self.flags != other.flags: return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700542 if self.cookie != other.cookie: return False
543 if self.packet_count != other.packet_count: return False
544 if self.byte_count != other.byte_count: return False
545 if self.match != other.match: return False
546 if self.instructions != other.instructions: return False
547 return True
548
549 def __ne__(self, other):
550 return not self.__eq__(other)
551
552 def show(self):
553 import loxi.pp
554 return loxi.pp.pp(self)
555
556 def pretty_print(self, q):
557 q.text("flow_stats_entry {")
558 with q.group():
559 with q.indent(2):
560 q.breakable()
561 q.text("table_id = ");
562 q.text("%#x" % self.table_id)
563 q.text(","); q.breakable()
564 q.text("duration_sec = ");
565 q.text("%#x" % self.duration_sec)
566 q.text(","); q.breakable()
567 q.text("duration_nsec = ");
568 q.text("%#x" % self.duration_nsec)
569 q.text(","); q.breakable()
570 q.text("priority = ");
571 q.text("%#x" % self.priority)
572 q.text(","); q.breakable()
573 q.text("idle_timeout = ");
574 q.text("%#x" % self.idle_timeout)
575 q.text(","); q.breakable()
576 q.text("hard_timeout = ");
577 q.text("%#x" % self.hard_timeout)
578 q.text(","); q.breakable()
Kiran Poolaae8fbf12013-09-19 16:32:32 -0700579 q.text("flags = ");
580 q.text("%#x" % self.flags)
581 q.text(","); q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700582 q.text("cookie = ");
583 q.text("%#x" % self.cookie)
584 q.text(","); q.breakable()
585 q.text("packet_count = ");
586 q.text("%#x" % self.packet_count)
587 q.text(","); q.breakable()
588 q.text("byte_count = ");
589 q.text("%#x" % self.byte_count)
590 q.text(","); q.breakable()
591 q.text("match = ");
592 q.pp(self.match)
593 q.text(","); q.breakable()
594 q.text("instructions = ");
595 q.pp(self.instructions)
596 q.breakable()
597 q.text('}')
598
599class group_desc_stats_entry(object):
600
601 def __init__(self, type=None, group_id=None, buckets=None):
602 if type != None:
603 self.type = type
604 else:
605 self.type = 0
606 if group_id != None:
607 self.group_id = group_id
608 else:
609 self.group_id = 0
610 if buckets != None:
611 self.buckets = buckets
612 else:
613 self.buckets = []
614 return
615
616 def pack(self):
617 packed = []
618 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
619 packed.append(struct.pack("!B", self.type))
620 packed.append('\x00' * 1)
621 packed.append(struct.pack("!L", self.group_id))
Dan Talaycof6202252013-07-02 01:00:29 -0700622 packed.append(util.pack_list(self.buckets))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700623 length = sum([len(x) for x in packed])
624 packed[0] = struct.pack("!H", length)
625 return ''.join(packed)
626
627 @staticmethod
628 def unpack(buf):
629 obj = group_desc_stats_entry()
630 if type(buf) == loxi.generic_util.OFReader:
631 reader = buf
632 else:
633 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -0700634 _length = reader.read("!H")[0]
635 obj.type = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700636 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -0700637 obj.group_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700638 obj.buckets = common.unpack_list_bucket(reader)
639 return obj
640
641 def __eq__(self, other):
642 if type(self) != type(other): return False
643 if self.type != other.type: return False
644 if self.group_id != other.group_id: return False
645 if self.buckets != other.buckets: return False
646 return True
647
648 def __ne__(self, other):
649 return not self.__eq__(other)
650
651 def show(self):
652 import loxi.pp
653 return loxi.pp.pp(self)
654
655 def pretty_print(self, q):
656 q.text("group_desc_stats_entry {")
657 with q.group():
658 with q.indent(2):
659 q.breakable()
660 q.text("type = ");
661 q.text("%#x" % self.type)
662 q.text(","); q.breakable()
663 q.text("group_id = ");
664 q.text("%#x" % self.group_id)
665 q.text(","); q.breakable()
666 q.text("buckets = ");
667 q.pp(self.buckets)
668 q.breakable()
669 q.text('}')
670
671class group_stats_entry(object):
672
673 def __init__(self, group_id=None, ref_count=None, packet_count=None, byte_count=None, duration_sec=None, duration_nsec=None, bucket_stats=None):
674 if group_id != None:
675 self.group_id = group_id
676 else:
677 self.group_id = 0
678 if ref_count != None:
679 self.ref_count = ref_count
680 else:
681 self.ref_count = 0
682 if packet_count != None:
683 self.packet_count = packet_count
684 else:
685 self.packet_count = 0
686 if byte_count != None:
687 self.byte_count = byte_count
688 else:
689 self.byte_count = 0
690 if duration_sec != None:
691 self.duration_sec = duration_sec
692 else:
693 self.duration_sec = 0
694 if duration_nsec != None:
695 self.duration_nsec = duration_nsec
696 else:
697 self.duration_nsec = 0
698 if bucket_stats != None:
699 self.bucket_stats = bucket_stats
700 else:
701 self.bucket_stats = []
702 return
703
704 def pack(self):
705 packed = []
706 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
707 packed.append('\x00' * 2)
708 packed.append(struct.pack("!L", self.group_id))
709 packed.append(struct.pack("!L", self.ref_count))
710 packed.append('\x00' * 4)
711 packed.append(struct.pack("!Q", self.packet_count))
712 packed.append(struct.pack("!Q", self.byte_count))
713 packed.append(struct.pack("!L", self.duration_sec))
714 packed.append(struct.pack("!L", self.duration_nsec))
Dan Talaycof6202252013-07-02 01:00:29 -0700715 packed.append(util.pack_list(self.bucket_stats))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700716 length = sum([len(x) for x in packed])
717 packed[0] = struct.pack("!H", length)
718 return ''.join(packed)
719
720 @staticmethod
721 def unpack(buf):
722 obj = group_stats_entry()
723 if type(buf) == loxi.generic_util.OFReader:
724 reader = buf
725 else:
726 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -0700727 _length = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700728 reader.skip(2)
Dan Talaycof6202252013-07-02 01:00:29 -0700729 obj.group_id = reader.read("!L")[0]
730 obj.ref_count = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700731 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -0700732 obj.packet_count = reader.read("!Q")[0]
733 obj.byte_count = reader.read("!Q")[0]
734 obj.duration_sec = reader.read("!L")[0]
735 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700736 obj.bucket_stats = loxi.generic_util.unpack_list(reader, common.bucket_counter.unpack)
737 return obj
738
739 def __eq__(self, other):
740 if type(self) != type(other): return False
741 if self.group_id != other.group_id: return False
742 if self.ref_count != other.ref_count: return False
743 if self.packet_count != other.packet_count: return False
744 if self.byte_count != other.byte_count: return False
745 if self.duration_sec != other.duration_sec: return False
746 if self.duration_nsec != other.duration_nsec: return False
747 if self.bucket_stats != other.bucket_stats: return False
748 return True
749
750 def __ne__(self, other):
751 return not self.__eq__(other)
752
753 def show(self):
754 import loxi.pp
755 return loxi.pp.pp(self)
756
757 def pretty_print(self, q):
758 q.text("group_stats_entry {")
759 with q.group():
760 with q.indent(2):
761 q.breakable()
762 q.text("group_id = ");
763 q.text("%#x" % self.group_id)
764 q.text(","); q.breakable()
765 q.text("ref_count = ");
766 q.text("%#x" % self.ref_count)
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("duration_sec = ");
775 q.text("%#x" % self.duration_sec)
776 q.text(","); q.breakable()
777 q.text("duration_nsec = ");
778 q.text("%#x" % self.duration_nsec)
779 q.text(","); q.breakable()
780 q.text("bucket_stats = ");
781 q.pp(self.bucket_stats)
782 q.breakable()
783 q.text('}')
784
785class hello_elem_versionbitmap(object):
Dan Talaycof6202252013-07-02 01:00:29 -0700786 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -0700787
788 def __init__(self, bitmaps=None):
789 if bitmaps != None:
790 self.bitmaps = bitmaps
791 else:
792 self.bitmaps = []
793 return
794
795 def pack(self):
796 packed = []
797 packed.append(struct.pack("!H", self.type))
798 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700799 packed.append(util.pack_list(self.bitmaps))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700800 length = sum([len(x) for x in packed])
801 packed[1] = struct.pack("!H", length)
802 return ''.join(packed)
803
804 @staticmethod
805 def unpack(buf):
806 obj = hello_elem_versionbitmap()
807 if type(buf) == loxi.generic_util.OFReader:
808 reader = buf
809 else:
810 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -0700811 _type = reader.read("!H")[0]
812 assert(_type == 1)
813 _length = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700814 obj.bitmaps = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
815 return obj
816
817 def __eq__(self, other):
818 if type(self) != type(other): return False
819 if self.bitmaps != other.bitmaps: return False
820 return True
821
822 def __ne__(self, other):
823 return not self.__eq__(other)
824
825 def show(self):
826 import loxi.pp
827 return loxi.pp.pp(self)
828
829 def pretty_print(self, q):
830 q.text("hello_elem_versionbitmap {")
831 with q.group():
832 with q.indent(2):
833 q.breakable()
834 q.text("bitmaps = ");
835 q.pp(self.bitmaps)
836 q.breakable()
837 q.text('}')
838
839class match_v3(object):
840 type = 1
841
842 def __init__(self, oxm_list=None):
843 if oxm_list != None:
844 self.oxm_list = oxm_list
845 else:
846 self.oxm_list = []
847 return
848
849 def pack(self):
850 packed = []
851 packed.append(struct.pack("!H", self.type))
852 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700853 packed.append(util.pack_list(self.oxm_list))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700854 length = sum([len(x) for x in packed])
855 packed[1] = struct.pack("!H", length)
Rich Laned53156a2013-08-05 17:17:33 -0700856 packed.append(loxi.generic_util.pad_to(8, length))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700857 return ''.join(packed)
858
859 @staticmethod
860 def unpack(buf):
861 obj = match_v3()
862 if type(buf) == loxi.generic_util.OFReader:
863 reader = buf
864 else:
865 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -0700866 _type = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700867 assert(_type == 1)
Dan Talaycof6202252013-07-02 01:00:29 -0700868 _length = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700869 obj.oxm_list = oxm.unpack_list(reader.slice(_length-4))
Rich Laned53156a2013-08-05 17:17:33 -0700870 reader.skip_align()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700871 return obj
872
873 def __eq__(self, other):
874 if type(self) != type(other): return False
875 if self.oxm_list != other.oxm_list: return False
876 return True
877
878 def __ne__(self, other):
879 return not self.__eq__(other)
880
881 def show(self):
882 import loxi.pp
883 return loxi.pp.pp(self)
884
885 def pretty_print(self, q):
886 q.text("match_v3 {")
887 with q.group():
888 with q.indent(2):
889 q.breakable()
890 q.text("oxm_list = ");
891 q.pp(self.oxm_list)
892 q.breakable()
893 q.text('}')
894
895class meter_band_stats(object):
896
897 def __init__(self, packet_band_count=None, byte_band_count=None):
898 if packet_band_count != None:
899 self.packet_band_count = packet_band_count
900 else:
901 self.packet_band_count = 0
902 if byte_band_count != None:
903 self.byte_band_count = byte_band_count
904 else:
905 self.byte_band_count = 0
906 return
907
908 def pack(self):
909 packed = []
910 packed.append(struct.pack("!Q", self.packet_band_count))
911 packed.append(struct.pack("!Q", self.byte_band_count))
912 return ''.join(packed)
913
914 @staticmethod
915 def unpack(buf):
916 obj = meter_band_stats()
917 if type(buf) == loxi.generic_util.OFReader:
918 reader = buf
919 else:
920 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -0700921 obj.packet_band_count = reader.read("!Q")[0]
922 obj.byte_band_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700923 return obj
924
925 def __eq__(self, other):
926 if type(self) != type(other): return False
927 if self.packet_band_count != other.packet_band_count: return False
928 if self.byte_band_count != other.byte_band_count: return False
929 return True
930
931 def __ne__(self, other):
932 return not self.__eq__(other)
933
934 def show(self):
935 import loxi.pp
936 return loxi.pp.pp(self)
937
938 def pretty_print(self, q):
939 q.text("meter_band_stats {")
940 with q.group():
941 with q.indent(2):
942 q.breakable()
943 q.text("packet_band_count = ");
944 q.text("%#x" % self.packet_band_count)
945 q.text(","); q.breakable()
946 q.text("byte_band_count = ");
947 q.text("%#x" % self.byte_band_count)
948 q.breakable()
949 q.text('}')
950
951class meter_config(object):
952
953 def __init__(self, flags=None, meter_id=None, entries=None):
954 if flags != None:
955 self.flags = flags
956 else:
957 self.flags = 0
958 if meter_id != None:
959 self.meter_id = meter_id
960 else:
961 self.meter_id = 0
962 if entries != None:
963 self.entries = entries
964 else:
965 self.entries = []
966 return
967
968 def pack(self):
969 packed = []
970 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
971 packed.append(struct.pack("!H", self.flags))
972 packed.append(struct.pack("!L", self.meter_id))
Dan Talaycof6202252013-07-02 01:00:29 -0700973 packed.append(util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700974 length = sum([len(x) for x in packed])
975 packed[0] = struct.pack("!H", length)
976 return ''.join(packed)
977
978 @staticmethod
979 def unpack(buf):
980 obj = meter_config()
981 if type(buf) == loxi.generic_util.OFReader:
982 reader = buf
983 else:
984 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -0700985 _length = reader.read("!H")[0]
986 obj.flags = reader.read("!H")[0]
987 obj.meter_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700988 obj.entries = meter_band.unpack_list(reader)
989 return obj
990
991 def __eq__(self, other):
992 if type(self) != type(other): return False
993 if self.flags != other.flags: return False
994 if self.meter_id != other.meter_id: return False
995 if self.entries != other.entries: return False
996 return True
997
998 def __ne__(self, other):
999 return not self.__eq__(other)
1000
1001 def show(self):
1002 import loxi.pp
1003 return loxi.pp.pp(self)
1004
1005 def pretty_print(self, q):
1006 q.text("meter_config {")
1007 with q.group():
1008 with q.indent(2):
1009 q.breakable()
1010 q.text("flags = ");
1011 q.text("%#x" % self.flags)
1012 q.text(","); q.breakable()
1013 q.text("meter_id = ");
1014 q.text("%#x" % self.meter_id)
1015 q.text(","); q.breakable()
1016 q.text("entries = ");
1017 q.pp(self.entries)
1018 q.breakable()
1019 q.text('}')
1020
1021class meter_features(object):
1022
1023 def __init__(self, max_meter=None, band_types=None, capabilities=None, max_bands=None, max_color=None):
1024 if max_meter != None:
1025 self.max_meter = max_meter
1026 else:
1027 self.max_meter = 0
1028 if band_types != None:
1029 self.band_types = band_types
1030 else:
1031 self.band_types = 0
1032 if capabilities != None:
1033 self.capabilities = capabilities
1034 else:
1035 self.capabilities = 0
1036 if max_bands != None:
1037 self.max_bands = max_bands
1038 else:
1039 self.max_bands = 0
1040 if max_color != None:
1041 self.max_color = max_color
1042 else:
1043 self.max_color = 0
1044 return
1045
1046 def pack(self):
1047 packed = []
1048 packed.append(struct.pack("!L", self.max_meter))
1049 packed.append(struct.pack("!L", self.band_types))
1050 packed.append(struct.pack("!L", self.capabilities))
1051 packed.append(struct.pack("!B", self.max_bands))
1052 packed.append(struct.pack("!B", self.max_color))
1053 packed.append('\x00' * 2)
1054 return ''.join(packed)
1055
1056 @staticmethod
1057 def unpack(buf):
1058 obj = meter_features()
1059 if type(buf) == loxi.generic_util.OFReader:
1060 reader = buf
1061 else:
1062 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001063 obj.max_meter = reader.read("!L")[0]
1064 obj.band_types = reader.read("!L")[0]
1065 obj.capabilities = reader.read("!L")[0]
1066 obj.max_bands = reader.read("!B")[0]
1067 obj.max_color = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001068 reader.skip(2)
1069 return obj
1070
1071 def __eq__(self, other):
1072 if type(self) != type(other): return False
1073 if self.max_meter != other.max_meter: return False
1074 if self.band_types != other.band_types: return False
1075 if self.capabilities != other.capabilities: return False
1076 if self.max_bands != other.max_bands: return False
1077 if self.max_color != other.max_color: return False
1078 return True
1079
1080 def __ne__(self, other):
1081 return not self.__eq__(other)
1082
1083 def show(self):
1084 import loxi.pp
1085 return loxi.pp.pp(self)
1086
1087 def pretty_print(self, q):
1088 q.text("meter_features {")
1089 with q.group():
1090 with q.indent(2):
1091 q.breakable()
1092 q.text("max_meter = ");
1093 q.text("%#x" % self.max_meter)
1094 q.text(","); q.breakable()
1095 q.text("band_types = ");
1096 q.text("%#x" % self.band_types)
1097 q.text(","); q.breakable()
1098 q.text("capabilities = ");
1099 q.text("%#x" % self.capabilities)
1100 q.text(","); q.breakable()
1101 q.text("max_bands = ");
1102 q.text("%#x" % self.max_bands)
1103 q.text(","); q.breakable()
1104 q.text("max_color = ");
1105 q.text("%#x" % self.max_color)
1106 q.breakable()
1107 q.text('}')
1108
1109class meter_stats(object):
1110
1111 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):
1112 if meter_id != None:
1113 self.meter_id = meter_id
1114 else:
1115 self.meter_id = 0
1116 if flow_count != None:
1117 self.flow_count = flow_count
1118 else:
1119 self.flow_count = 0
1120 if packet_in_count != None:
1121 self.packet_in_count = packet_in_count
1122 else:
1123 self.packet_in_count = 0
1124 if byte_in_count != None:
1125 self.byte_in_count = byte_in_count
1126 else:
1127 self.byte_in_count = 0
1128 if duration_sec != None:
1129 self.duration_sec = duration_sec
1130 else:
1131 self.duration_sec = 0
1132 if duration_nsec != None:
1133 self.duration_nsec = duration_nsec
1134 else:
1135 self.duration_nsec = 0
1136 if band_stats != None:
1137 self.band_stats = band_stats
1138 else:
1139 self.band_stats = []
1140 return
1141
1142 def pack(self):
1143 packed = []
1144 packed.append(struct.pack("!L", self.meter_id))
1145 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1146 packed.append('\x00' * 6)
1147 packed.append(struct.pack("!L", self.flow_count))
1148 packed.append(struct.pack("!Q", self.packet_in_count))
1149 packed.append(struct.pack("!Q", self.byte_in_count))
1150 packed.append(struct.pack("!L", self.duration_sec))
1151 packed.append(struct.pack("!L", self.duration_nsec))
Dan Talaycof6202252013-07-02 01:00:29 -07001152 packed.append(util.pack_list(self.band_stats))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001153 length = sum([len(x) for x in packed])
1154 packed[1] = struct.pack("!H", length)
1155 return ''.join(packed)
1156
1157 @staticmethod
1158 def unpack(buf):
1159 obj = meter_stats()
1160 if type(buf) == loxi.generic_util.OFReader:
1161 reader = buf
1162 else:
1163 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001164 obj.meter_id = reader.read("!L")[0]
1165 _len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001166 reader.skip(6)
Dan Talaycof6202252013-07-02 01:00:29 -07001167 obj.flow_count = reader.read("!L")[0]
1168 obj.packet_in_count = reader.read("!Q")[0]
1169 obj.byte_in_count = reader.read("!Q")[0]
1170 obj.duration_sec = reader.read("!L")[0]
1171 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001172 obj.band_stats = loxi.generic_util.unpack_list(reader, common.meter_band_stats.unpack)
1173 return obj
1174
1175 def __eq__(self, other):
1176 if type(self) != type(other): return False
1177 if self.meter_id != other.meter_id: return False
1178 if self.flow_count != other.flow_count: return False
1179 if self.packet_in_count != other.packet_in_count: return False
1180 if self.byte_in_count != other.byte_in_count: return False
1181 if self.duration_sec != other.duration_sec: return False
1182 if self.duration_nsec != other.duration_nsec: return False
1183 if self.band_stats != other.band_stats: return False
1184 return True
1185
1186 def __ne__(self, other):
1187 return not self.__eq__(other)
1188
1189 def show(self):
1190 import loxi.pp
1191 return loxi.pp.pp(self)
1192
1193 def pretty_print(self, q):
1194 q.text("meter_stats {")
1195 with q.group():
1196 with q.indent(2):
1197 q.breakable()
1198 q.text("meter_id = ");
1199 q.text("%#x" % self.meter_id)
1200 q.text(","); q.breakable()
1201 q.text("flow_count = ");
1202 q.text("%#x" % self.flow_count)
1203 q.text(","); q.breakable()
1204 q.text("packet_in_count = ");
1205 q.text("%#x" % self.packet_in_count)
1206 q.text(","); q.breakable()
1207 q.text("byte_in_count = ");
1208 q.text("%#x" % self.byte_in_count)
1209 q.text(","); q.breakable()
1210 q.text("duration_sec = ");
1211 q.text("%#x" % self.duration_sec)
1212 q.text(","); q.breakable()
1213 q.text("duration_nsec = ");
1214 q.text("%#x" % self.duration_nsec)
1215 q.text(","); q.breakable()
1216 q.text("band_stats = ");
1217 q.pp(self.band_stats)
1218 q.breakable()
1219 q.text('}')
1220
1221class packet_queue(object):
1222
1223 def __init__(self, queue_id=None, port=None, properties=None):
1224 if queue_id != None:
1225 self.queue_id = queue_id
1226 else:
1227 self.queue_id = 0
1228 if port != None:
1229 self.port = port
1230 else:
1231 self.port = 0
1232 if properties != None:
1233 self.properties = properties
1234 else:
1235 self.properties = []
1236 return
1237
1238 def pack(self):
1239 packed = []
1240 packed.append(struct.pack("!L", self.queue_id))
Dan Talaycof6202252013-07-02 01:00:29 -07001241 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001242 packed.append(struct.pack("!H", 0)) # placeholder for len at index 2
1243 packed.append('\x00' * 6)
Dan Talaycof6202252013-07-02 01:00:29 -07001244 packed.append(util.pack_list(self.properties))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001245 length = sum([len(x) for x in packed])
1246 packed[2] = struct.pack("!H", length)
1247 return ''.join(packed)
1248
1249 @staticmethod
1250 def unpack(buf):
1251 obj = packet_queue()
1252 if type(buf) == loxi.generic_util.OFReader:
1253 reader = buf
1254 else:
1255 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001256 obj.queue_id = reader.read("!L")[0]
1257 obj.port = util.unpack_port_no(reader)
1258 _len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001259 reader.skip(6)
1260 obj.properties = common.unpack_list_queue_prop(reader)
1261 return obj
1262
1263 def __eq__(self, other):
1264 if type(self) != type(other): return False
1265 if self.queue_id != other.queue_id: return False
1266 if self.port != other.port: return False
1267 if self.properties != other.properties: return False
1268 return True
1269
1270 def __ne__(self, other):
1271 return not self.__eq__(other)
1272
1273 def show(self):
1274 import loxi.pp
1275 return loxi.pp.pp(self)
1276
1277 def pretty_print(self, q):
1278 q.text("packet_queue {")
1279 with q.group():
1280 with q.indent(2):
1281 q.breakable()
1282 q.text("queue_id = ");
1283 q.text("%#x" % self.queue_id)
1284 q.text(","); q.breakable()
1285 q.text("port = ");
1286 q.text(util.pretty_port(self.port))
1287 q.text(","); q.breakable()
1288 q.text("properties = ");
1289 q.pp(self.properties)
1290 q.breakable()
1291 q.text('}')
1292
1293class port_desc(object):
1294
1295 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):
1296 if port_no != None:
1297 self.port_no = port_no
1298 else:
1299 self.port_no = 0
1300 if hw_addr != None:
1301 self.hw_addr = hw_addr
1302 else:
1303 self.hw_addr = [0,0,0,0,0,0]
1304 if name != None:
1305 self.name = name
1306 else:
1307 self.name = ""
1308 if config != None:
1309 self.config = config
1310 else:
1311 self.config = 0
1312 if state != None:
1313 self.state = state
1314 else:
1315 self.state = 0
1316 if curr != None:
1317 self.curr = curr
1318 else:
1319 self.curr = 0
1320 if advertised != None:
1321 self.advertised = advertised
1322 else:
1323 self.advertised = 0
1324 if supported != None:
1325 self.supported = supported
1326 else:
1327 self.supported = 0
1328 if peer != None:
1329 self.peer = peer
1330 else:
1331 self.peer = 0
1332 if curr_speed != None:
1333 self.curr_speed = curr_speed
1334 else:
1335 self.curr_speed = 0
1336 if max_speed != None:
1337 self.max_speed = max_speed
1338 else:
1339 self.max_speed = 0
1340 return
1341
1342 def pack(self):
1343 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07001344 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001345 packed.append('\x00' * 4)
1346 packed.append(struct.pack("!6B", *self.hw_addr))
1347 packed.append('\x00' * 2)
1348 packed.append(struct.pack("!16s", self.name))
1349 packed.append(struct.pack("!L", self.config))
1350 packed.append(struct.pack("!L", self.state))
1351 packed.append(struct.pack("!L", self.curr))
1352 packed.append(struct.pack("!L", self.advertised))
1353 packed.append(struct.pack("!L", self.supported))
1354 packed.append(struct.pack("!L", self.peer))
1355 packed.append(struct.pack("!L", self.curr_speed))
1356 packed.append(struct.pack("!L", self.max_speed))
1357 return ''.join(packed)
1358
1359 @staticmethod
1360 def unpack(buf):
1361 obj = port_desc()
1362 if type(buf) == loxi.generic_util.OFReader:
1363 reader = buf
1364 else:
1365 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001366 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001367 reader.skip(4)
1368 obj.hw_addr = list(reader.read('!6B'))
1369 reader.skip(2)
1370 obj.name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -07001371 obj.config = reader.read("!L")[0]
1372 obj.state = reader.read("!L")[0]
1373 obj.curr = reader.read("!L")[0]
1374 obj.advertised = reader.read("!L")[0]
1375 obj.supported = reader.read("!L")[0]
1376 obj.peer = reader.read("!L")[0]
1377 obj.curr_speed = reader.read("!L")[0]
1378 obj.max_speed = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001379 return obj
1380
1381 def __eq__(self, other):
1382 if type(self) != type(other): return False
1383 if self.port_no != other.port_no: return False
1384 if self.hw_addr != other.hw_addr: return False
1385 if self.name != other.name: return False
1386 if self.config != other.config: return False
1387 if self.state != other.state: return False
1388 if self.curr != other.curr: return False
1389 if self.advertised != other.advertised: return False
1390 if self.supported != other.supported: return False
1391 if self.peer != other.peer: return False
1392 if self.curr_speed != other.curr_speed: return False
1393 if self.max_speed != other.max_speed: return False
1394 return True
1395
1396 def __ne__(self, other):
1397 return not self.__eq__(other)
1398
1399 def show(self):
1400 import loxi.pp
1401 return loxi.pp.pp(self)
1402
1403 def pretty_print(self, q):
1404 q.text("port_desc {")
1405 with q.group():
1406 with q.indent(2):
1407 q.breakable()
1408 q.text("port_no = ");
1409 q.text(util.pretty_port(self.port_no))
1410 q.text(","); q.breakable()
1411 q.text("hw_addr = ");
1412 q.text(util.pretty_mac(self.hw_addr))
1413 q.text(","); q.breakable()
1414 q.text("name = ");
1415 q.pp(self.name)
1416 q.text(","); q.breakable()
1417 q.text("config = ");
1418 q.text("%#x" % self.config)
1419 q.text(","); q.breakable()
1420 q.text("state = ");
1421 q.text("%#x" % self.state)
1422 q.text(","); q.breakable()
1423 q.text("curr = ");
1424 q.text("%#x" % self.curr)
1425 q.text(","); q.breakable()
1426 q.text("advertised = ");
1427 q.text("%#x" % self.advertised)
1428 q.text(","); q.breakable()
1429 q.text("supported = ");
1430 q.text("%#x" % self.supported)
1431 q.text(","); q.breakable()
1432 q.text("peer = ");
1433 q.text("%#x" % self.peer)
1434 q.text(","); q.breakable()
1435 q.text("curr_speed = ");
1436 q.text("%#x" % self.curr_speed)
1437 q.text(","); q.breakable()
1438 q.text("max_speed = ");
1439 q.text("%#x" % self.max_speed)
1440 q.breakable()
1441 q.text('}')
1442
1443class port_stats_entry(object):
1444
1445 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):
1446 if port_no != None:
1447 self.port_no = port_no
1448 else:
1449 self.port_no = 0
1450 if rx_packets != None:
1451 self.rx_packets = rx_packets
1452 else:
1453 self.rx_packets = 0
1454 if tx_packets != None:
1455 self.tx_packets = tx_packets
1456 else:
1457 self.tx_packets = 0
1458 if rx_bytes != None:
1459 self.rx_bytes = rx_bytes
1460 else:
1461 self.rx_bytes = 0
1462 if tx_bytes != None:
1463 self.tx_bytes = tx_bytes
1464 else:
1465 self.tx_bytes = 0
1466 if rx_dropped != None:
1467 self.rx_dropped = rx_dropped
1468 else:
1469 self.rx_dropped = 0
1470 if tx_dropped != None:
1471 self.tx_dropped = tx_dropped
1472 else:
1473 self.tx_dropped = 0
1474 if rx_errors != None:
1475 self.rx_errors = rx_errors
1476 else:
1477 self.rx_errors = 0
1478 if tx_errors != None:
1479 self.tx_errors = tx_errors
1480 else:
1481 self.tx_errors = 0
1482 if rx_frame_err != None:
1483 self.rx_frame_err = rx_frame_err
1484 else:
1485 self.rx_frame_err = 0
1486 if rx_over_err != None:
1487 self.rx_over_err = rx_over_err
1488 else:
1489 self.rx_over_err = 0
1490 if rx_crc_err != None:
1491 self.rx_crc_err = rx_crc_err
1492 else:
1493 self.rx_crc_err = 0
1494 if collisions != None:
1495 self.collisions = collisions
1496 else:
1497 self.collisions = 0
1498 if duration_sec != None:
1499 self.duration_sec = duration_sec
1500 else:
1501 self.duration_sec = 0
1502 if duration_nsec != None:
1503 self.duration_nsec = duration_nsec
1504 else:
1505 self.duration_nsec = 0
1506 return
1507
1508 def pack(self):
1509 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07001510 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001511 packed.append('\x00' * 4)
1512 packed.append(struct.pack("!Q", self.rx_packets))
1513 packed.append(struct.pack("!Q", self.tx_packets))
1514 packed.append(struct.pack("!Q", self.rx_bytes))
1515 packed.append(struct.pack("!Q", self.tx_bytes))
1516 packed.append(struct.pack("!Q", self.rx_dropped))
1517 packed.append(struct.pack("!Q", self.tx_dropped))
1518 packed.append(struct.pack("!Q", self.rx_errors))
1519 packed.append(struct.pack("!Q", self.tx_errors))
1520 packed.append(struct.pack("!Q", self.rx_frame_err))
1521 packed.append(struct.pack("!Q", self.rx_over_err))
1522 packed.append(struct.pack("!Q", self.rx_crc_err))
1523 packed.append(struct.pack("!Q", self.collisions))
1524 packed.append(struct.pack("!L", self.duration_sec))
1525 packed.append(struct.pack("!L", self.duration_nsec))
1526 return ''.join(packed)
1527
1528 @staticmethod
1529 def unpack(buf):
1530 obj = port_stats_entry()
1531 if type(buf) == loxi.generic_util.OFReader:
1532 reader = buf
1533 else:
1534 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001535 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001536 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001537 obj.rx_packets = reader.read("!Q")[0]
1538 obj.tx_packets = reader.read("!Q")[0]
1539 obj.rx_bytes = reader.read("!Q")[0]
1540 obj.tx_bytes = reader.read("!Q")[0]
1541 obj.rx_dropped = reader.read("!Q")[0]
1542 obj.tx_dropped = reader.read("!Q")[0]
1543 obj.rx_errors = reader.read("!Q")[0]
1544 obj.tx_errors = reader.read("!Q")[0]
1545 obj.rx_frame_err = reader.read("!Q")[0]
1546 obj.rx_over_err = reader.read("!Q")[0]
1547 obj.rx_crc_err = reader.read("!Q")[0]
1548 obj.collisions = reader.read("!Q")[0]
1549 obj.duration_sec = reader.read("!L")[0]
1550 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001551 return obj
1552
1553 def __eq__(self, other):
1554 if type(self) != type(other): return False
1555 if self.port_no != other.port_no: return False
1556 if self.rx_packets != other.rx_packets: return False
1557 if self.tx_packets != other.tx_packets: return False
1558 if self.rx_bytes != other.rx_bytes: return False
1559 if self.tx_bytes != other.tx_bytes: return False
1560 if self.rx_dropped != other.rx_dropped: return False
1561 if self.tx_dropped != other.tx_dropped: return False
1562 if self.rx_errors != other.rx_errors: return False
1563 if self.tx_errors != other.tx_errors: return False
1564 if self.rx_frame_err != other.rx_frame_err: return False
1565 if self.rx_over_err != other.rx_over_err: return False
1566 if self.rx_crc_err != other.rx_crc_err: return False
1567 if self.collisions != other.collisions: return False
1568 if self.duration_sec != other.duration_sec: return False
1569 if self.duration_nsec != other.duration_nsec: return False
1570 return True
1571
1572 def __ne__(self, other):
1573 return not self.__eq__(other)
1574
1575 def show(self):
1576 import loxi.pp
1577 return loxi.pp.pp(self)
1578
1579 def pretty_print(self, q):
1580 q.text("port_stats_entry {")
1581 with q.group():
1582 with q.indent(2):
1583 q.breakable()
1584 q.text("port_no = ");
1585 q.text(util.pretty_port(self.port_no))
1586 q.text(","); q.breakable()
1587 q.text("rx_packets = ");
1588 q.text("%#x" % self.rx_packets)
1589 q.text(","); q.breakable()
1590 q.text("tx_packets = ");
1591 q.text("%#x" % self.tx_packets)
1592 q.text(","); q.breakable()
1593 q.text("rx_bytes = ");
1594 q.text("%#x" % self.rx_bytes)
1595 q.text(","); q.breakable()
1596 q.text("tx_bytes = ");
1597 q.text("%#x" % self.tx_bytes)
1598 q.text(","); q.breakable()
1599 q.text("rx_dropped = ");
1600 q.text("%#x" % self.rx_dropped)
1601 q.text(","); q.breakable()
1602 q.text("tx_dropped = ");
1603 q.text("%#x" % self.tx_dropped)
1604 q.text(","); q.breakable()
1605 q.text("rx_errors = ");
1606 q.text("%#x" % self.rx_errors)
1607 q.text(","); q.breakable()
1608 q.text("tx_errors = ");
1609 q.text("%#x" % self.tx_errors)
1610 q.text(","); q.breakable()
1611 q.text("rx_frame_err = ");
1612 q.text("%#x" % self.rx_frame_err)
1613 q.text(","); q.breakable()
1614 q.text("rx_over_err = ");
1615 q.text("%#x" % self.rx_over_err)
1616 q.text(","); q.breakable()
1617 q.text("rx_crc_err = ");
1618 q.text("%#x" % self.rx_crc_err)
1619 q.text(","); q.breakable()
1620 q.text("collisions = ");
1621 q.text("%#x" % self.collisions)
1622 q.text(","); q.breakable()
1623 q.text("duration_sec = ");
1624 q.text("%#x" % self.duration_sec)
1625 q.text(","); q.breakable()
1626 q.text("duration_nsec = ");
1627 q.text("%#x" % self.duration_nsec)
1628 q.breakable()
1629 q.text('}')
1630
Rich Lanec2ee4b82013-04-24 17:12:38 -07001631class queue_prop_max_rate(object):
Dan Talaycof6202252013-07-02 01:00:29 -07001632 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07001633
1634 def __init__(self, rate=None):
1635 if rate != None:
1636 self.rate = rate
1637 else:
1638 self.rate = 0
1639 return
1640
1641 def pack(self):
1642 packed = []
1643 packed.append(struct.pack("!H", self.type))
1644 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1645 packed.append('\x00' * 4)
1646 packed.append(struct.pack("!H", self.rate))
1647 packed.append('\x00' * 6)
1648 length = sum([len(x) for x in packed])
1649 packed[1] = struct.pack("!H", length)
1650 return ''.join(packed)
1651
1652 @staticmethod
1653 def unpack(buf):
1654 obj = queue_prop_max_rate()
1655 if type(buf) == loxi.generic_util.OFReader:
1656 reader = buf
1657 else:
1658 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001659 _type = reader.read("!H")[0]
1660 assert(_type == 2)
1661 _len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001662 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001663 obj.rate = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001664 reader.skip(6)
1665 return obj
1666
1667 def __eq__(self, other):
1668 if type(self) != type(other): return False
1669 if self.rate != other.rate: return False
1670 return True
1671
1672 def __ne__(self, other):
1673 return not self.__eq__(other)
1674
1675 def show(self):
1676 import loxi.pp
1677 return loxi.pp.pp(self)
1678
1679 def pretty_print(self, q):
1680 q.text("queue_prop_max_rate {")
1681 with q.group():
1682 with q.indent(2):
1683 q.breakable()
1684 q.text("rate = ");
1685 q.text("%#x" % self.rate)
1686 q.breakable()
1687 q.text('}')
1688
1689class queue_prop_min_rate(object):
Dan Talaycof6202252013-07-02 01:00:29 -07001690 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07001691
1692 def __init__(self, rate=None):
1693 if rate != None:
1694 self.rate = rate
1695 else:
1696 self.rate = 0
1697 return
1698
1699 def pack(self):
1700 packed = []
1701 packed.append(struct.pack("!H", self.type))
1702 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1703 packed.append('\x00' * 4)
1704 packed.append(struct.pack("!H", self.rate))
1705 packed.append('\x00' * 6)
1706 length = sum([len(x) for x in packed])
1707 packed[1] = struct.pack("!H", length)
1708 return ''.join(packed)
1709
1710 @staticmethod
1711 def unpack(buf):
1712 obj = queue_prop_min_rate()
1713 if type(buf) == loxi.generic_util.OFReader:
1714 reader = buf
1715 else:
1716 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001717 _type = reader.read("!H")[0]
1718 assert(_type == 1)
1719 _len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001720 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001721 obj.rate = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001722 reader.skip(6)
1723 return obj
1724
1725 def __eq__(self, other):
1726 if type(self) != type(other): return False
1727 if self.rate != other.rate: return False
1728 return True
1729
1730 def __ne__(self, other):
1731 return not self.__eq__(other)
1732
1733 def show(self):
1734 import loxi.pp
1735 return loxi.pp.pp(self)
1736
1737 def pretty_print(self, q):
1738 q.text("queue_prop_min_rate {")
1739 with q.group():
1740 with q.indent(2):
1741 q.breakable()
1742 q.text("rate = ");
1743 q.text("%#x" % self.rate)
1744 q.breakable()
1745 q.text('}')
1746
1747class queue_stats_entry(object):
1748
1749 def __init__(self, port_no=None, queue_id=None, tx_bytes=None, tx_packets=None, tx_errors=None, duration_sec=None, duration_nsec=None):
1750 if port_no != None:
1751 self.port_no = port_no
1752 else:
1753 self.port_no = 0
1754 if queue_id != None:
1755 self.queue_id = queue_id
1756 else:
1757 self.queue_id = 0
1758 if tx_bytes != None:
1759 self.tx_bytes = tx_bytes
1760 else:
1761 self.tx_bytes = 0
1762 if tx_packets != None:
1763 self.tx_packets = tx_packets
1764 else:
1765 self.tx_packets = 0
1766 if tx_errors != None:
1767 self.tx_errors = tx_errors
1768 else:
1769 self.tx_errors = 0
1770 if duration_sec != None:
1771 self.duration_sec = duration_sec
1772 else:
1773 self.duration_sec = 0
1774 if duration_nsec != None:
1775 self.duration_nsec = duration_nsec
1776 else:
1777 self.duration_nsec = 0
1778 return
1779
1780 def pack(self):
1781 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07001782 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001783 packed.append(struct.pack("!L", self.queue_id))
1784 packed.append(struct.pack("!Q", self.tx_bytes))
1785 packed.append(struct.pack("!Q", self.tx_packets))
1786 packed.append(struct.pack("!Q", self.tx_errors))
1787 packed.append(struct.pack("!L", self.duration_sec))
1788 packed.append(struct.pack("!L", self.duration_nsec))
1789 return ''.join(packed)
1790
1791 @staticmethod
1792 def unpack(buf):
1793 obj = queue_stats_entry()
1794 if type(buf) == loxi.generic_util.OFReader:
1795 reader = buf
1796 else:
1797 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001798 obj.port_no = util.unpack_port_no(reader)
1799 obj.queue_id = reader.read("!L")[0]
1800 obj.tx_bytes = reader.read("!Q")[0]
1801 obj.tx_packets = reader.read("!Q")[0]
1802 obj.tx_errors = reader.read("!Q")[0]
1803 obj.duration_sec = reader.read("!L")[0]
1804 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001805 return obj
1806
1807 def __eq__(self, other):
1808 if type(self) != type(other): return False
1809 if self.port_no != other.port_no: return False
1810 if self.queue_id != other.queue_id: return False
1811 if self.tx_bytes != other.tx_bytes: return False
1812 if self.tx_packets != other.tx_packets: return False
1813 if self.tx_errors != other.tx_errors: return False
1814 if self.duration_sec != other.duration_sec: return False
1815 if self.duration_nsec != other.duration_nsec: return False
1816 return True
1817
1818 def __ne__(self, other):
1819 return not self.__eq__(other)
1820
1821 def show(self):
1822 import loxi.pp
1823 return loxi.pp.pp(self)
1824
1825 def pretty_print(self, q):
1826 q.text("queue_stats_entry {")
1827 with q.group():
1828 with q.indent(2):
1829 q.breakable()
1830 q.text("port_no = ");
1831 q.text(util.pretty_port(self.port_no))
1832 q.text(","); q.breakable()
1833 q.text("queue_id = ");
1834 q.text("%#x" % self.queue_id)
1835 q.text(","); q.breakable()
1836 q.text("tx_bytes = ");
1837 q.text("%#x" % self.tx_bytes)
1838 q.text(","); q.breakable()
1839 q.text("tx_packets = ");
1840 q.text("%#x" % self.tx_packets)
1841 q.text(","); q.breakable()
1842 q.text("tx_errors = ");
1843 q.text("%#x" % self.tx_errors)
1844 q.text(","); q.breakable()
1845 q.text("duration_sec = ");
1846 q.text("%#x" % self.duration_sec)
1847 q.text(","); q.breakable()
1848 q.text("duration_nsec = ");
1849 q.text("%#x" % self.duration_nsec)
1850 q.breakable()
1851 q.text('}')
1852
Kiran Poolaae8fbf12013-09-19 16:32:32 -07001853class table_feature_prop(object):
1854
1855 def __init__(self, type=None):
1856 if type != None:
1857 self.type = type
1858 else:
1859 self.type = 0
1860 return
1861
1862 def pack(self):
1863 packed = []
1864 packed.append(struct.pack("!H", self.type))
1865 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
1866 length = sum([len(x) for x in packed])
1867 packed[1] = struct.pack("!H", length)
1868 return ''.join(packed)
1869
1870 @staticmethod
1871 def unpack(buf):
1872 obj = table_feature_prop()
1873 if type(buf) == loxi.generic_util.OFReader:
1874 reader = buf
1875 else:
1876 reader = loxi.generic_util.OFReader(buf)
1877 obj.type = reader.read("!H")[0]
1878 _length = reader.read("!H")[0]
1879 return obj
1880
1881 def __eq__(self, other):
1882 if type(self) != type(other): return False
1883 if self.type != other.type: return False
1884 return True
1885
1886 def __ne__(self, other):
1887 return not self.__eq__(other)
1888
1889 def show(self):
1890 import loxi.pp
1891 return loxi.pp.pp(self)
1892
1893 def pretty_print(self, q):
1894 q.text("table_feature_prop {")
1895 with q.group():
1896 with q.indent(2):
1897 q.breakable()
1898 q.text("type = ");
1899 q.text("%#x" % self.type)
1900 q.breakable()
1901 q.text('}')
1902
Rich Lanec2ee4b82013-04-24 17:12:38 -07001903class table_feature_prop_apply_actions(object):
Dan Talaycof6202252013-07-02 01:00:29 -07001904 type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07001905
Dan Talaycof6202252013-07-02 01:00:29 -07001906 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001907 if action_ids != None:
1908 self.action_ids = action_ids
1909 else:
1910 self.action_ids = []
1911 return
1912
1913 def pack(self):
1914 packed = []
1915 packed.append(struct.pack("!H", self.type))
1916 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -07001917 packed.append(util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001918 length = sum([len(x) for x in packed])
1919 packed[1] = struct.pack("!H", length)
1920 return ''.join(packed)
1921
1922 @staticmethod
1923 def unpack(buf):
1924 obj = table_feature_prop_apply_actions()
1925 if type(buf) == loxi.generic_util.OFReader:
1926 reader = buf
1927 else:
1928 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001929 _type = reader.read("!H")[0]
1930 assert(_type == 6)
1931 _length = reader.read("!H")[0]
1932 obj.action_ids = loxi.unimplemented('unpack list(of_action_id_t)')
Rich Lanec2ee4b82013-04-24 17:12:38 -07001933 return obj
1934
1935 def __eq__(self, other):
1936 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001937 if self.action_ids != other.action_ids: return False
1938 return True
1939
1940 def __ne__(self, other):
1941 return not self.__eq__(other)
1942
1943 def show(self):
1944 import loxi.pp
1945 return loxi.pp.pp(self)
1946
1947 def pretty_print(self, q):
1948 q.text("table_feature_prop_apply_actions {")
1949 with q.group():
1950 with q.indent(2):
1951 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001952 q.text("action_ids = ");
1953 q.pp(self.action_ids)
1954 q.breakable()
1955 q.text('}')
1956
1957class table_feature_prop_apply_actions_miss(object):
Dan Talaycof6202252013-07-02 01:00:29 -07001958 type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07001959
Dan Talaycof6202252013-07-02 01:00:29 -07001960 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001961 if action_ids != None:
1962 self.action_ids = action_ids
1963 else:
1964 self.action_ids = []
1965 return
1966
1967 def pack(self):
1968 packed = []
1969 packed.append(struct.pack("!H", self.type))
1970 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -07001971 packed.append(util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001972 length = sum([len(x) for x in packed])
1973 packed[1] = struct.pack("!H", length)
1974 return ''.join(packed)
1975
1976 @staticmethod
1977 def unpack(buf):
1978 obj = table_feature_prop_apply_actions_miss()
1979 if type(buf) == loxi.generic_util.OFReader:
1980 reader = buf
1981 else:
1982 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001983 _type = reader.read("!H")[0]
1984 assert(_type == 7)
1985 _length = reader.read("!H")[0]
1986 obj.action_ids = loxi.unimplemented('unpack list(of_action_id_t)')
Rich Lanec2ee4b82013-04-24 17:12:38 -07001987 return obj
1988
1989 def __eq__(self, other):
1990 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001991 if self.action_ids != other.action_ids: return False
1992 return True
1993
1994 def __ne__(self, other):
1995 return not self.__eq__(other)
1996
1997 def show(self):
1998 import loxi.pp
1999 return loxi.pp.pp(self)
2000
2001 def pretty_print(self, q):
2002 q.text("table_feature_prop_apply_actions_miss {")
2003 with q.group():
2004 with q.indent(2):
2005 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002006 q.text("action_ids = ");
2007 q.pp(self.action_ids)
2008 q.breakable()
2009 q.text('}')
2010
2011class table_feature_prop_apply_setfield(object):
Dan Talaycof6202252013-07-02 01:00:29 -07002012 type = 14
Rich Lanec2ee4b82013-04-24 17:12:38 -07002013
Dan Talaycof6202252013-07-02 01:00:29 -07002014 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002015 if oxm_ids != None:
2016 self.oxm_ids = oxm_ids
2017 else:
2018 self.oxm_ids = []
2019 return
2020
2021 def pack(self):
2022 packed = []
2023 packed.append(struct.pack("!H", self.type))
2024 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -07002025 packed.append(util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002026 length = sum([len(x) for x in packed])
2027 packed[1] = struct.pack("!H", length)
2028 return ''.join(packed)
2029
2030 @staticmethod
2031 def unpack(buf):
2032 obj = table_feature_prop_apply_setfield()
2033 if type(buf) == loxi.generic_util.OFReader:
2034 reader = buf
2035 else:
2036 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002037 _type = reader.read("!H")[0]
2038 assert(_type == 14)
2039 _length = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002040 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
2041 return obj
2042
2043 def __eq__(self, other):
2044 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002045 if self.oxm_ids != other.oxm_ids: return False
2046 return True
2047
2048 def __ne__(self, other):
2049 return not self.__eq__(other)
2050
2051 def show(self):
2052 import loxi.pp
2053 return loxi.pp.pp(self)
2054
2055 def pretty_print(self, q):
2056 q.text("table_feature_prop_apply_setfield {")
2057 with q.group():
2058 with q.indent(2):
2059 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002060 q.text("oxm_ids = ");
2061 q.pp(self.oxm_ids)
2062 q.breakable()
2063 q.text('}')
2064
2065class table_feature_prop_apply_setfield_miss(object):
Dan Talaycof6202252013-07-02 01:00:29 -07002066 type = 15
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
Dan Talaycof6202252013-07-02 01:00:29 -07002079 packed.append(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
2085 def unpack(buf):
2086 obj = table_feature_prop_apply_setfield_miss()
2087 if type(buf) == loxi.generic_util.OFReader:
2088 reader = buf
2089 else:
2090 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002091 _type = reader.read("!H")[0]
2092 assert(_type == 15)
2093 _length = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002094 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
2095 return obj
2096
2097 def __eq__(self, other):
2098 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002099 if self.oxm_ids != other.oxm_ids: return False
2100 return True
2101
2102 def __ne__(self, other):
2103 return not self.__eq__(other)
2104
2105 def show(self):
2106 import loxi.pp
2107 return loxi.pp.pp(self)
2108
2109 def pretty_print(self, q):
2110 q.text("table_feature_prop_apply_setfield_miss {")
2111 with q.group():
2112 with q.indent(2):
2113 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002114 q.text("oxm_ids = ");
2115 q.pp(self.oxm_ids)
2116 q.breakable()
2117 q.text('}')
2118
2119class table_feature_prop_experimenter(object):
Dan Talaycof6202252013-07-02 01:00:29 -07002120 type = 65535
Rich Lanec2ee4b82013-04-24 17:12:38 -07002121
Dan Talaycof6202252013-07-02 01:00:29 -07002122 def __init__(self, experimenter=None, subtype=None, experimenter_data=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002123 if experimenter != None:
2124 self.experimenter = experimenter
2125 else:
2126 self.experimenter = 0
2127 if subtype != None:
2128 self.subtype = subtype
2129 else:
2130 self.subtype = 0
2131 if experimenter_data != None:
2132 self.experimenter_data = experimenter_data
2133 else:
Dan Talaycof6202252013-07-02 01:00:29 -07002134 self.experimenter_data = ''
Rich Lanec2ee4b82013-04-24 17:12:38 -07002135 return
2136
2137 def pack(self):
2138 packed = []
2139 packed.append(struct.pack("!H", self.type))
2140 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
2141 packed.append(struct.pack("!L", self.experimenter))
2142 packed.append(struct.pack("!L", self.subtype))
2143 packed.append(self.experimenter_data)
2144 length = sum([len(x) for x in packed])
2145 packed[1] = struct.pack("!H", length)
2146 return ''.join(packed)
2147
2148 @staticmethod
2149 def unpack(buf):
2150 obj = table_feature_prop_experimenter()
2151 if type(buf) == loxi.generic_util.OFReader:
2152 reader = buf
2153 else:
2154 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002155 _type = reader.read("!H")[0]
2156 assert(_type == 65535)
2157 _length = reader.read("!H")[0]
2158 obj.experimenter = reader.read("!L")[0]
2159 obj.subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002160 obj.experimenter_data = str(reader.read_all())
2161 return obj
2162
2163 def __eq__(self, other):
2164 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002165 if self.experimenter != other.experimenter: return False
2166 if self.subtype != other.subtype: return False
2167 if self.experimenter_data != other.experimenter_data: return False
2168 return True
2169
2170 def __ne__(self, other):
2171 return not self.__eq__(other)
2172
2173 def show(self):
2174 import loxi.pp
2175 return loxi.pp.pp(self)
2176
2177 def pretty_print(self, q):
2178 q.text("table_feature_prop_experimenter {")
2179 with q.group():
2180 with q.indent(2):
2181 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002182 q.text("experimenter = ");
2183 q.text("%#x" % self.experimenter)
2184 q.text(","); q.breakable()
2185 q.text("subtype = ");
2186 q.text("%#x" % self.subtype)
2187 q.text(","); q.breakable()
2188 q.text("experimenter_data = ");
2189 q.pp(self.experimenter_data)
2190 q.breakable()
2191 q.text('}')
2192
2193class table_feature_prop_instructions(object):
Dan Talaycof6202252013-07-02 01:00:29 -07002194 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07002195
Dan Talaycof6202252013-07-02 01:00:29 -07002196 def __init__(self, instruction_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002197 if instruction_ids != None:
2198 self.instruction_ids = instruction_ids
2199 else:
2200 self.instruction_ids = []
2201 return
2202
2203 def pack(self):
2204 packed = []
2205 packed.append(struct.pack("!H", self.type))
2206 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -07002207 packed.append(util.pack_list(self.instruction_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002208 length = sum([len(x) for x in packed])
2209 packed[1] = struct.pack("!H", length)
2210 return ''.join(packed)
2211
2212 @staticmethod
2213 def unpack(buf):
2214 obj = table_feature_prop_instructions()
2215 if type(buf) == loxi.generic_util.OFReader:
2216 reader = buf
2217 else:
2218 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002219 _type = reader.read("!H")[0]
2220 assert(_type == 0)
2221 _length = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002222 obj.instruction_ids = instruction.unpack_list(reader)
2223 return obj
2224
2225 def __eq__(self, other):
2226 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002227 if self.instruction_ids != other.instruction_ids: return False
2228 return True
2229
2230 def __ne__(self, other):
2231 return not self.__eq__(other)
2232
2233 def show(self):
2234 import loxi.pp
2235 return loxi.pp.pp(self)
2236
2237 def pretty_print(self, q):
2238 q.text("table_feature_prop_instructions {")
2239 with q.group():
2240 with q.indent(2):
2241 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002242 q.text("instruction_ids = ");
2243 q.pp(self.instruction_ids)
2244 q.breakable()
2245 q.text('}')
2246
2247class table_feature_prop_instructions_miss(object):
Dan Talaycof6202252013-07-02 01:00:29 -07002248 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07002249
Dan Talaycof6202252013-07-02 01:00:29 -07002250 def __init__(self, instruction_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002251 if instruction_ids != None:
2252 self.instruction_ids = instruction_ids
2253 else:
2254 self.instruction_ids = []
2255 return
2256
2257 def pack(self):
2258 packed = []
2259 packed.append(struct.pack("!H", self.type))
2260 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -07002261 packed.append(util.pack_list(self.instruction_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002262 length = sum([len(x) for x in packed])
2263 packed[1] = struct.pack("!H", length)
2264 return ''.join(packed)
2265
2266 @staticmethod
2267 def unpack(buf):
2268 obj = table_feature_prop_instructions_miss()
2269 if type(buf) == loxi.generic_util.OFReader:
2270 reader = buf
2271 else:
2272 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002273 _type = reader.read("!H")[0]
2274 assert(_type == 1)
2275 _length = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002276 obj.instruction_ids = instruction.unpack_list(reader)
2277 return obj
2278
2279 def __eq__(self, other):
2280 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002281 if self.instruction_ids != other.instruction_ids: return False
2282 return True
2283
2284 def __ne__(self, other):
2285 return not self.__eq__(other)
2286
2287 def show(self):
2288 import loxi.pp
2289 return loxi.pp.pp(self)
2290
2291 def pretty_print(self, q):
2292 q.text("table_feature_prop_instructions_miss {")
2293 with q.group():
2294 with q.indent(2):
2295 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002296 q.text("instruction_ids = ");
2297 q.pp(self.instruction_ids)
2298 q.breakable()
2299 q.text('}')
2300
2301class table_feature_prop_match(object):
Dan Talaycof6202252013-07-02 01:00:29 -07002302 type = 8
Rich Lanec2ee4b82013-04-24 17:12:38 -07002303
Dan Talaycof6202252013-07-02 01:00:29 -07002304 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002305 if oxm_ids != None:
2306 self.oxm_ids = oxm_ids
2307 else:
2308 self.oxm_ids = []
2309 return
2310
2311 def pack(self):
2312 packed = []
2313 packed.append(struct.pack("!H", self.type))
2314 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -07002315 packed.append(util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002316 length = sum([len(x) for x in packed])
2317 packed[1] = struct.pack("!H", length)
2318 return ''.join(packed)
2319
2320 @staticmethod
2321 def unpack(buf):
2322 obj = table_feature_prop_match()
2323 if type(buf) == loxi.generic_util.OFReader:
2324 reader = buf
2325 else:
2326 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002327 _type = reader.read("!H")[0]
2328 assert(_type == 8)
2329 _length = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002330 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
2331 return obj
2332
2333 def __eq__(self, other):
2334 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002335 if self.oxm_ids != other.oxm_ids: return False
2336 return True
2337
2338 def __ne__(self, other):
2339 return not self.__eq__(other)
2340
2341 def show(self):
2342 import loxi.pp
2343 return loxi.pp.pp(self)
2344
2345 def pretty_print(self, q):
2346 q.text("table_feature_prop_match {")
2347 with q.group():
2348 with q.indent(2):
2349 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002350 q.text("oxm_ids = ");
2351 q.pp(self.oxm_ids)
2352 q.breakable()
2353 q.text('}')
2354
2355class table_feature_prop_next_tables(object):
Dan Talaycof6202252013-07-02 01:00:29 -07002356 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07002357
Dan Talaycof6202252013-07-02 01:00:29 -07002358 def __init__(self, next_table_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002359 if next_table_ids != None:
2360 self.next_table_ids = next_table_ids
2361 else:
2362 self.next_table_ids = []
2363 return
2364
2365 def pack(self):
2366 packed = []
2367 packed.append(struct.pack("!H", self.type))
2368 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -07002369 packed.append(util.pack_list(self.next_table_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002370 length = sum([len(x) for x in packed])
2371 packed[1] = struct.pack("!H", length)
2372 return ''.join(packed)
2373
2374 @staticmethod
2375 def unpack(buf):
2376 obj = table_feature_prop_next_tables()
2377 if type(buf) == loxi.generic_util.OFReader:
2378 reader = buf
2379 else:
2380 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002381 _type = reader.read("!H")[0]
2382 assert(_type == 2)
2383 _length = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002384 obj.next_table_ids = loxi.generic_util.unpack_list(reader, common.uint8.unpack)
2385 return obj
2386
2387 def __eq__(self, other):
2388 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002389 if self.next_table_ids != other.next_table_ids: return False
2390 return True
2391
2392 def __ne__(self, other):
2393 return not self.__eq__(other)
2394
2395 def show(self):
2396 import loxi.pp
2397 return loxi.pp.pp(self)
2398
2399 def pretty_print(self, q):
2400 q.text("table_feature_prop_next_tables {")
2401 with q.group():
2402 with q.indent(2):
2403 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002404 q.text("next_table_ids = ");
2405 q.pp(self.next_table_ids)
2406 q.breakable()
2407 q.text('}')
2408
2409class table_feature_prop_next_tables_miss(object):
Dan Talaycof6202252013-07-02 01:00:29 -07002410 type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07002411
Dan Talaycof6202252013-07-02 01:00:29 -07002412 def __init__(self, next_table_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002413 if next_table_ids != None:
2414 self.next_table_ids = next_table_ids
2415 else:
2416 self.next_table_ids = []
2417 return
2418
2419 def pack(self):
2420 packed = []
2421 packed.append(struct.pack("!H", self.type))
2422 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -07002423 packed.append(util.pack_list(self.next_table_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002424 length = sum([len(x) for x in packed])
2425 packed[1] = struct.pack("!H", length)
2426 return ''.join(packed)
2427
2428 @staticmethod
2429 def unpack(buf):
2430 obj = table_feature_prop_next_tables_miss()
2431 if type(buf) == loxi.generic_util.OFReader:
2432 reader = buf
2433 else:
2434 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002435 _type = reader.read("!H")[0]
2436 assert(_type == 3)
2437 _length = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002438 obj.next_table_ids = loxi.generic_util.unpack_list(reader, common.uint8.unpack)
2439 return obj
2440
2441 def __eq__(self, other):
2442 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002443 if self.next_table_ids != other.next_table_ids: return False
2444 return True
2445
2446 def __ne__(self, other):
2447 return not self.__eq__(other)
2448
2449 def show(self):
2450 import loxi.pp
2451 return loxi.pp.pp(self)
2452
2453 def pretty_print(self, q):
2454 q.text("table_feature_prop_next_tables_miss {")
2455 with q.group():
2456 with q.indent(2):
2457 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002458 q.text("next_table_ids = ");
2459 q.pp(self.next_table_ids)
2460 q.breakable()
2461 q.text('}')
2462
2463class table_feature_prop_wildcards(object):
Dan Talaycof6202252013-07-02 01:00:29 -07002464 type = 10
Rich Lanec2ee4b82013-04-24 17:12:38 -07002465
Dan Talaycof6202252013-07-02 01:00:29 -07002466 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002467 if oxm_ids != None:
2468 self.oxm_ids = oxm_ids
2469 else:
2470 self.oxm_ids = []
2471 return
2472
2473 def pack(self):
2474 packed = []
2475 packed.append(struct.pack("!H", self.type))
2476 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -07002477 packed.append(util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002478 length = sum([len(x) for x in packed])
2479 packed[1] = struct.pack("!H", length)
2480 return ''.join(packed)
2481
2482 @staticmethod
2483 def unpack(buf):
2484 obj = table_feature_prop_wildcards()
2485 if type(buf) == loxi.generic_util.OFReader:
2486 reader = buf
2487 else:
2488 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002489 _type = reader.read("!H")[0]
2490 assert(_type == 10)
2491 _length = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002492 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
2493 return obj
2494
2495 def __eq__(self, other):
2496 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002497 if self.oxm_ids != other.oxm_ids: return False
2498 return True
2499
2500 def __ne__(self, other):
2501 return not self.__eq__(other)
2502
2503 def show(self):
2504 import loxi.pp
2505 return loxi.pp.pp(self)
2506
2507 def pretty_print(self, q):
2508 q.text("table_feature_prop_wildcards {")
2509 with q.group():
2510 with q.indent(2):
2511 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002512 q.text("oxm_ids = ");
2513 q.pp(self.oxm_ids)
2514 q.breakable()
2515 q.text('}')
2516
2517class table_feature_prop_write_actions(object):
Dan Talaycof6202252013-07-02 01:00:29 -07002518 type = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07002519
Dan Talaycof6202252013-07-02 01:00:29 -07002520 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002521 if action_ids != None:
2522 self.action_ids = action_ids
2523 else:
2524 self.action_ids = []
2525 return
2526
2527 def pack(self):
2528 packed = []
2529 packed.append(struct.pack("!H", self.type))
2530 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -07002531 packed.append(util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002532 length = sum([len(x) for x in packed])
2533 packed[1] = struct.pack("!H", length)
2534 return ''.join(packed)
2535
2536 @staticmethod
2537 def unpack(buf):
2538 obj = table_feature_prop_write_actions()
2539 if type(buf) == loxi.generic_util.OFReader:
2540 reader = buf
2541 else:
2542 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002543 _type = reader.read("!H")[0]
2544 assert(_type == 4)
2545 _length = reader.read("!H")[0]
2546 obj.action_ids = loxi.unimplemented('unpack list(of_action_id_t)')
Rich Lanec2ee4b82013-04-24 17:12:38 -07002547 return obj
2548
2549 def __eq__(self, other):
2550 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002551 if self.action_ids != other.action_ids: return False
2552 return True
2553
2554 def __ne__(self, other):
2555 return not self.__eq__(other)
2556
2557 def show(self):
2558 import loxi.pp
2559 return loxi.pp.pp(self)
2560
2561 def pretty_print(self, q):
2562 q.text("table_feature_prop_write_actions {")
2563 with q.group():
2564 with q.indent(2):
2565 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002566 q.text("action_ids = ");
2567 q.pp(self.action_ids)
2568 q.breakable()
2569 q.text('}')
2570
2571class table_feature_prop_write_actions_miss(object):
Dan Talaycof6202252013-07-02 01:00:29 -07002572 type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07002573
Dan Talaycof6202252013-07-02 01:00:29 -07002574 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002575 if action_ids != None:
2576 self.action_ids = action_ids
2577 else:
2578 self.action_ids = []
2579 return
2580
2581 def pack(self):
2582 packed = []
2583 packed.append(struct.pack("!H", self.type))
2584 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -07002585 packed.append(util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002586 length = sum([len(x) for x in packed])
2587 packed[1] = struct.pack("!H", length)
2588 return ''.join(packed)
2589
2590 @staticmethod
2591 def unpack(buf):
2592 obj = table_feature_prop_write_actions_miss()
2593 if type(buf) == loxi.generic_util.OFReader:
2594 reader = buf
2595 else:
2596 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002597 _type = reader.read("!H")[0]
2598 assert(_type == 5)
2599 _length = reader.read("!H")[0]
2600 obj.action_ids = loxi.unimplemented('unpack list(of_action_id_t)')
Rich Lanec2ee4b82013-04-24 17:12:38 -07002601 return obj
2602
2603 def __eq__(self, other):
2604 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002605 if self.action_ids != other.action_ids: return False
2606 return True
2607
2608 def __ne__(self, other):
2609 return not self.__eq__(other)
2610
2611 def show(self):
2612 import loxi.pp
2613 return loxi.pp.pp(self)
2614
2615 def pretty_print(self, q):
2616 q.text("table_feature_prop_write_actions_miss {")
2617 with q.group():
2618 with q.indent(2):
2619 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002620 q.text("action_ids = ");
2621 q.pp(self.action_ids)
2622 q.breakable()
2623 q.text('}')
2624
2625class table_feature_prop_write_setfield(object):
Dan Talaycof6202252013-07-02 01:00:29 -07002626 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -07002627
Dan Talaycof6202252013-07-02 01:00:29 -07002628 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002629 if oxm_ids != None:
2630 self.oxm_ids = oxm_ids
2631 else:
2632 self.oxm_ids = []
2633 return
2634
2635 def pack(self):
2636 packed = []
2637 packed.append(struct.pack("!H", self.type))
2638 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -07002639 packed.append(util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002640 length = sum([len(x) for x in packed])
2641 packed[1] = struct.pack("!H", length)
2642 return ''.join(packed)
2643
2644 @staticmethod
2645 def unpack(buf):
2646 obj = table_feature_prop_write_setfield()
2647 if type(buf) == loxi.generic_util.OFReader:
2648 reader = buf
2649 else:
2650 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002651 _type = reader.read("!H")[0]
2652 assert(_type == 12)
2653 _length = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002654 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
2655 return obj
2656
2657 def __eq__(self, other):
2658 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002659 if self.oxm_ids != other.oxm_ids: return False
2660 return True
2661
2662 def __ne__(self, other):
2663 return not self.__eq__(other)
2664
2665 def show(self):
2666 import loxi.pp
2667 return loxi.pp.pp(self)
2668
2669 def pretty_print(self, q):
2670 q.text("table_feature_prop_write_setfield {")
2671 with q.group():
2672 with q.indent(2):
2673 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002674 q.text("oxm_ids = ");
2675 q.pp(self.oxm_ids)
2676 q.breakable()
2677 q.text('}')
2678
2679class table_feature_prop_write_setfield_miss(object):
Dan Talaycof6202252013-07-02 01:00:29 -07002680 type = 13
Rich Lanec2ee4b82013-04-24 17:12:38 -07002681
Dan Talaycof6202252013-07-02 01:00:29 -07002682 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002683 if oxm_ids != None:
2684 self.oxm_ids = oxm_ids
2685 else:
2686 self.oxm_ids = []
2687 return
2688
2689 def pack(self):
2690 packed = []
2691 packed.append(struct.pack("!H", self.type))
2692 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -07002693 packed.append(util.pack_list(self.oxm_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002694 length = sum([len(x) for x in packed])
2695 packed[1] = struct.pack("!H", length)
2696 return ''.join(packed)
2697
2698 @staticmethod
2699 def unpack(buf):
2700 obj = table_feature_prop_write_setfield_miss()
2701 if type(buf) == loxi.generic_util.OFReader:
2702 reader = buf
2703 else:
2704 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002705 _type = reader.read("!H")[0]
2706 assert(_type == 13)
2707 _length = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002708 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
2709 return obj
2710
2711 def __eq__(self, other):
2712 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002713 if self.oxm_ids != other.oxm_ids: return False
2714 return True
2715
2716 def __ne__(self, other):
2717 return not self.__eq__(other)
2718
2719 def show(self):
2720 import loxi.pp
2721 return loxi.pp.pp(self)
2722
2723 def pretty_print(self, q):
2724 q.text("table_feature_prop_write_setfield_miss {")
2725 with q.group():
2726 with q.indent(2):
2727 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002728 q.text("oxm_ids = ");
2729 q.pp(self.oxm_ids)
2730 q.breakable()
2731 q.text('}')
2732
2733class table_features(object):
2734
2735 def __init__(self, table_id=None, name=None, metadata_match=None, metadata_write=None, config=None, max_entries=None, properties=None):
2736 if table_id != None:
2737 self.table_id = table_id
2738 else:
2739 self.table_id = 0
2740 if name != None:
2741 self.name = name
2742 else:
2743 self.name = ""
2744 if metadata_match != None:
2745 self.metadata_match = metadata_match
2746 else:
2747 self.metadata_match = 0
2748 if metadata_write != None:
2749 self.metadata_write = metadata_write
2750 else:
2751 self.metadata_write = 0
2752 if config != None:
2753 self.config = config
2754 else:
2755 self.config = 0
2756 if max_entries != None:
2757 self.max_entries = max_entries
2758 else:
2759 self.max_entries = 0
2760 if properties != None:
2761 self.properties = properties
2762 else:
2763 self.properties = []
2764 return
2765
2766 def pack(self):
2767 packed = []
2768 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
2769 packed.append(struct.pack("!B", self.table_id))
2770 packed.append('\x00' * 5)
2771 packed.append(struct.pack("!32s", self.name))
2772 packed.append(struct.pack("!Q", self.metadata_match))
2773 packed.append(struct.pack("!Q", self.metadata_write))
2774 packed.append(struct.pack("!L", self.config))
2775 packed.append(struct.pack("!L", self.max_entries))
Dan Talaycof6202252013-07-02 01:00:29 -07002776 packed.append(util.pack_list(self.properties))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002777 length = sum([len(x) for x in packed])
2778 packed[0] = struct.pack("!H", length)
2779 return ''.join(packed)
2780
2781 @staticmethod
2782 def unpack(buf):
2783 obj = table_features()
2784 if type(buf) == loxi.generic_util.OFReader:
2785 reader = buf
2786 else:
2787 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002788 _length = reader.read("!H")[0]
2789 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002790 reader.skip(5)
2791 obj.name = reader.read("!32s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -07002792 obj.metadata_match = reader.read("!Q")[0]
2793 obj.metadata_write = reader.read("!Q")[0]
2794 obj.config = reader.read("!L")[0]
2795 obj.max_entries = reader.read("!L")[0]
2796 obj.properties = loxi.unimplemented('unpack list(of_table_feature_prop_t)')
Rich Lanec2ee4b82013-04-24 17:12:38 -07002797 return obj
2798
2799 def __eq__(self, other):
2800 if type(self) != type(other): return False
2801 if self.table_id != other.table_id: return False
2802 if self.name != other.name: return False
2803 if self.metadata_match != other.metadata_match: return False
2804 if self.metadata_write != other.metadata_write: return False
2805 if self.config != other.config: return False
2806 if self.max_entries != other.max_entries: return False
2807 if self.properties != other.properties: return False
2808 return True
2809
2810 def __ne__(self, other):
2811 return not self.__eq__(other)
2812
2813 def show(self):
2814 import loxi.pp
2815 return loxi.pp.pp(self)
2816
2817 def pretty_print(self, q):
2818 q.text("table_features {")
2819 with q.group():
2820 with q.indent(2):
2821 q.breakable()
2822 q.text("table_id = ");
2823 q.text("%#x" % self.table_id)
2824 q.text(","); q.breakable()
2825 q.text("name = ");
2826 q.pp(self.name)
2827 q.text(","); q.breakable()
2828 q.text("metadata_match = ");
2829 q.text("%#x" % self.metadata_match)
2830 q.text(","); q.breakable()
2831 q.text("metadata_write = ");
2832 q.text("%#x" % self.metadata_write)
2833 q.text(","); q.breakable()
2834 q.text("config = ");
2835 q.text("%#x" % self.config)
2836 q.text(","); q.breakable()
2837 q.text("max_entries = ");
2838 q.text("%#x" % self.max_entries)
2839 q.text(","); q.breakable()
2840 q.text("properties = ");
2841 q.pp(self.properties)
2842 q.breakable()
2843 q.text('}')
2844
2845class table_stats_entry(object):
2846
2847 def __init__(self, table_id=None, active_count=None, lookup_count=None, matched_count=None):
2848 if table_id != None:
2849 self.table_id = table_id
2850 else:
2851 self.table_id = 0
2852 if active_count != None:
2853 self.active_count = active_count
2854 else:
2855 self.active_count = 0
2856 if lookup_count != None:
2857 self.lookup_count = lookup_count
2858 else:
2859 self.lookup_count = 0
2860 if matched_count != None:
2861 self.matched_count = matched_count
2862 else:
2863 self.matched_count = 0
2864 return
2865
2866 def pack(self):
2867 packed = []
2868 packed.append(struct.pack("!B", self.table_id))
2869 packed.append('\x00' * 3)
2870 packed.append(struct.pack("!L", self.active_count))
2871 packed.append(struct.pack("!Q", self.lookup_count))
2872 packed.append(struct.pack("!Q", self.matched_count))
2873 return ''.join(packed)
2874
2875 @staticmethod
2876 def unpack(buf):
2877 obj = table_stats_entry()
2878 if type(buf) == loxi.generic_util.OFReader:
2879 reader = buf
2880 else:
2881 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002882 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002883 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07002884 obj.active_count = reader.read("!L")[0]
2885 obj.lookup_count = reader.read("!Q")[0]
2886 obj.matched_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002887 return obj
2888
2889 def __eq__(self, other):
2890 if type(self) != type(other): return False
2891 if self.table_id != other.table_id: return False
2892 if self.active_count != other.active_count: return False
2893 if self.lookup_count != other.lookup_count: return False
2894 if self.matched_count != other.matched_count: return False
2895 return True
2896
2897 def __ne__(self, other):
2898 return not self.__eq__(other)
2899
2900 def show(self):
2901 import loxi.pp
2902 return loxi.pp.pp(self)
2903
2904 def pretty_print(self, q):
2905 q.text("table_stats_entry {")
2906 with q.group():
2907 with q.indent(2):
2908 q.breakable()
2909 q.text("table_id = ");
2910 q.text("%#x" % self.table_id)
2911 q.text(","); q.breakable()
2912 q.text("active_count = ");
2913 q.text("%#x" % self.active_count)
2914 q.text(","); q.breakable()
2915 q.text("lookup_count = ");
2916 q.text("%#x" % self.lookup_count)
2917 q.text(","); q.breakable()
2918 q.text("matched_count = ");
2919 q.text("%#x" % self.matched_count)
2920 q.breakable()
2921 q.text('}')
2922
2923class uint32(object):
2924
2925 def __init__(self, value=None):
2926 if value != None:
2927 self.value = value
2928 else:
2929 self.value = 0
2930 return
2931
2932 def pack(self):
2933 packed = []
2934 packed.append(struct.pack("!L", self.value))
2935 return ''.join(packed)
2936
2937 @staticmethod
2938 def unpack(buf):
2939 obj = uint32()
2940 if type(buf) == loxi.generic_util.OFReader:
2941 reader = buf
2942 else:
2943 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002944 obj.value = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002945 return obj
2946
2947 def __eq__(self, other):
2948 if type(self) != type(other): return False
2949 if self.value != other.value: return False
2950 return True
2951
2952 def __ne__(self, other):
2953 return not self.__eq__(other)
2954
2955 def show(self):
2956 import loxi.pp
2957 return loxi.pp.pp(self)
2958
2959 def pretty_print(self, q):
2960 q.text("uint32 {")
2961 with q.group():
2962 with q.indent(2):
2963 q.breakable()
2964 q.text("value = ");
2965 q.text("%#x" % self.value)
2966 q.breakable()
2967 q.text('}')
2968
2969class uint8(object):
2970
2971 def __init__(self, value=None):
2972 if value != None:
2973 self.value = value
2974 else:
2975 self.value = 0
2976 return
2977
2978 def pack(self):
2979 packed = []
2980 packed.append(struct.pack("!B", self.value))
2981 return ''.join(packed)
2982
2983 @staticmethod
2984 def unpack(buf):
2985 obj = uint8()
2986 if type(buf) == loxi.generic_util.OFReader:
2987 reader = buf
2988 else:
2989 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002990 obj.value = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002991 return obj
2992
2993 def __eq__(self, other):
2994 if type(self) != type(other): return False
2995 if self.value != other.value: return False
2996 return True
2997
2998 def __ne__(self, other):
2999 return not self.__eq__(other)
3000
3001 def show(self):
3002 import loxi.pp
3003 return loxi.pp.pp(self)
3004
3005 def pretty_print(self, q):
3006 q.text("uint8 {")
3007 with q.group():
3008 with q.indent(2):
3009 q.breakable()
3010 q.text("value = ");
3011 q.text("%#x" % self.value)
3012 q.breakable()
3013 q.text('}')
3014
3015
3016match = match_v3