blob: 952aeba2fe5f4f3b9ae23994dd05865f2da5f5db [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
Rich Lanec2ee4b82013-04-24 17:12:38 -070063class bsn_interface(object):
64
65 def __init__(self, hw_addr=None, name=None, ipv4_addr=None, ipv4_netmask=None):
66 if hw_addr != None:
67 self.hw_addr = hw_addr
68 else:
69 self.hw_addr = [0,0,0,0,0,0]
70 if name != None:
71 self.name = name
72 else:
73 self.name = ""
74 if ipv4_addr != None:
75 self.ipv4_addr = ipv4_addr
76 else:
77 self.ipv4_addr = 0
78 if ipv4_netmask != None:
79 self.ipv4_netmask = ipv4_netmask
80 else:
81 self.ipv4_netmask = 0
82 return
83
84 def pack(self):
85 packed = []
86 packed.append(struct.pack("!6B", *self.hw_addr))
87 packed.append('\x00' * 2)
88 packed.append(struct.pack("!16s", self.name))
89 packed.append(struct.pack("!L", self.ipv4_addr))
90 packed.append(struct.pack("!L", self.ipv4_netmask))
91 return ''.join(packed)
92
93 @staticmethod
94 def unpack(buf):
95 obj = bsn_interface()
96 if type(buf) == loxi.generic_util.OFReader:
97 reader = buf
98 else:
99 reader = loxi.generic_util.OFReader(buf)
100 obj.hw_addr = list(reader.read('!6B'))
101 reader.skip(2)
102 obj.name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -0700103 obj.ipv4_addr = reader.read("!L")[0]
104 obj.ipv4_netmask = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700105 return obj
106
107 def __eq__(self, other):
108 if type(self) != type(other): return False
109 if self.hw_addr != other.hw_addr: return False
110 if self.name != other.name: return False
111 if self.ipv4_addr != other.ipv4_addr: return False
112 if self.ipv4_netmask != other.ipv4_netmask: return False
113 return True
114
115 def __ne__(self, other):
116 return not self.__eq__(other)
117
118 def show(self):
119 import loxi.pp
120 return loxi.pp.pp(self)
121
122 def pretty_print(self, q):
123 q.text("bsn_interface {")
124 with q.group():
125 with q.indent(2):
126 q.breakable()
127 q.text("hw_addr = ");
128 q.text(util.pretty_mac(self.hw_addr))
129 q.text(","); q.breakable()
130 q.text("name = ");
131 q.pp(self.name)
132 q.text(","); q.breakable()
133 q.text("ipv4_addr = ");
134 q.text(util.pretty_ipv4(self.ipv4_addr))
135 q.text(","); q.breakable()
136 q.text("ipv4_netmask = ");
137 q.text(util.pretty_ipv4(self.ipv4_netmask))
138 q.breakable()
139 q.text('}')
140
Dan Talaycof6202252013-07-02 01:00:29 -0700141class bsn_vport_q_in_q(object):
142 type = 0
143
144 def __init__(self, port_no=None, ingress_tpid=None, ingress_vlan_id=None, egress_tpid=None, egress_vlan_id=None):
145 if port_no != None:
146 self.port_no = port_no
147 else:
148 self.port_no = 0
149 if ingress_tpid != None:
150 self.ingress_tpid = ingress_tpid
151 else:
152 self.ingress_tpid = 0
153 if ingress_vlan_id != None:
154 self.ingress_vlan_id = ingress_vlan_id
155 else:
156 self.ingress_vlan_id = 0
157 if egress_tpid != None:
158 self.egress_tpid = egress_tpid
159 else:
160 self.egress_tpid = 0
161 if egress_vlan_id != None:
162 self.egress_vlan_id = egress_vlan_id
163 else:
164 self.egress_vlan_id = 0
165 return
166
167 def pack(self):
168 packed = []
169 packed.append(struct.pack("!H", self.type))
170 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
171 packed.append(struct.pack("!L", self.port_no))
172 packed.append(struct.pack("!H", self.ingress_tpid))
173 packed.append(struct.pack("!H", self.ingress_vlan_id))
174 packed.append(struct.pack("!H", self.egress_tpid))
175 packed.append(struct.pack("!H", self.egress_vlan_id))
176 length = sum([len(x) for x in packed])
177 packed[1] = struct.pack("!H", length)
178 return ''.join(packed)
179
180 @staticmethod
181 def unpack(buf):
182 obj = bsn_vport_q_in_q()
183 if type(buf) == loxi.generic_util.OFReader:
184 reader = buf
185 else:
186 reader = loxi.generic_util.OFReader(buf)
187 _type = reader.read("!H")[0]
188 assert(_type == 0)
189 _length = reader.read("!H")[0]
190 obj.port_no = reader.read("!L")[0]
191 obj.ingress_tpid = reader.read("!H")[0]
192 obj.ingress_vlan_id = reader.read("!H")[0]
193 obj.egress_tpid = reader.read("!H")[0]
194 obj.egress_vlan_id = reader.read("!H")[0]
195 return obj
196
197 def __eq__(self, other):
198 if type(self) != type(other): return False
199 if self.port_no != other.port_no: return False
200 if self.ingress_tpid != other.ingress_tpid: return False
201 if self.ingress_vlan_id != other.ingress_vlan_id: return False
202 if self.egress_tpid != other.egress_tpid: return False
203 if self.egress_vlan_id != other.egress_vlan_id: return False
204 return True
205
206 def __ne__(self, other):
207 return not self.__eq__(other)
208
209 def show(self):
210 import loxi.pp
211 return loxi.pp.pp(self)
212
213 def pretty_print(self, q):
214 q.text("bsn_vport_q_in_q {")
215 with q.group():
216 with q.indent(2):
217 q.breakable()
218 q.text("port_no = ");
219 q.text("%#x" % self.port_no)
220 q.text(","); q.breakable()
221 q.text("ingress_tpid = ");
222 q.text("%#x" % self.ingress_tpid)
223 q.text(","); q.breakable()
224 q.text("ingress_vlan_id = ");
225 q.text("%#x" % self.ingress_vlan_id)
226 q.text(","); q.breakable()
227 q.text("egress_tpid = ");
228 q.text("%#x" % self.egress_tpid)
229 q.text(","); q.breakable()
230 q.text("egress_vlan_id = ");
231 q.text("%#x" % self.egress_vlan_id)
232 q.breakable()
233 q.text('}')
234
Rich Lanec2ee4b82013-04-24 17:12:38 -0700235class bucket(object):
236
237 def __init__(self, weight=None, watch_port=None, watch_group=None, actions=None):
238 if weight != None:
239 self.weight = weight
240 else:
241 self.weight = 0
242 if watch_port != None:
243 self.watch_port = watch_port
244 else:
245 self.watch_port = 0
246 if watch_group != None:
247 self.watch_group = watch_group
248 else:
249 self.watch_group = 0
250 if actions != None:
251 self.actions = actions
252 else:
253 self.actions = []
254 return
255
256 def pack(self):
257 packed = []
258 packed.append(struct.pack("!H", 0)) # placeholder for len at index 0
259 packed.append(struct.pack("!H", self.weight))
Dan Talaycof6202252013-07-02 01:00:29 -0700260 packed.append(util.pack_port_no(self.watch_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700261 packed.append(struct.pack("!L", self.watch_group))
262 packed.append('\x00' * 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700263 packed.append(util.pack_list(self.actions))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700264 length = sum([len(x) for x in packed])
265 packed[0] = struct.pack("!H", length)
266 return ''.join(packed)
267
268 @staticmethod
269 def unpack(buf):
270 obj = bucket()
271 if type(buf) == loxi.generic_util.OFReader:
272 reader = buf
273 else:
274 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -0700275 _len = reader.read("!H")[0]
276 obj.weight = reader.read("!H")[0]
277 obj.watch_port = util.unpack_port_no(reader)
278 obj.watch_group = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700279 reader.skip(4)
280 obj.actions = action.unpack_list(reader)
281 return obj
282
283 def __eq__(self, other):
284 if type(self) != type(other): return False
285 if self.weight != other.weight: return False
286 if self.watch_port != other.watch_port: return False
287 if self.watch_group != other.watch_group: return False
288 if self.actions != other.actions: return False
289 return True
290
291 def __ne__(self, other):
292 return not self.__eq__(other)
293
294 def show(self):
295 import loxi.pp
296 return loxi.pp.pp(self)
297
298 def pretty_print(self, q):
299 q.text("bucket {")
300 with q.group():
301 with q.indent(2):
302 q.breakable()
303 q.text("weight = ");
304 q.text("%#x" % self.weight)
305 q.text(","); q.breakable()
306 q.text("watch_port = ");
307 q.text(util.pretty_port(self.watch_port))
308 q.text(","); q.breakable()
309 q.text("watch_group = ");
310 q.text("%#x" % self.watch_group)
311 q.text(","); q.breakable()
312 q.text("actions = ");
313 q.pp(self.actions)
314 q.breakable()
315 q.text('}')
316
317class bucket_counter(object):
318
319 def __init__(self, packet_count=None, byte_count=None):
320 if packet_count != None:
321 self.packet_count = packet_count
322 else:
323 self.packet_count = 0
324 if byte_count != None:
325 self.byte_count = byte_count
326 else:
327 self.byte_count = 0
328 return
329
330 def pack(self):
331 packed = []
332 packed.append(struct.pack("!Q", self.packet_count))
333 packed.append(struct.pack("!Q", self.byte_count))
334 return ''.join(packed)
335
336 @staticmethod
337 def unpack(buf):
338 obj = bucket_counter()
339 if type(buf) == loxi.generic_util.OFReader:
340 reader = buf
341 else:
342 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -0700343 obj.packet_count = reader.read("!Q")[0]
344 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700345 return obj
346
347 def __eq__(self, other):
348 if type(self) != type(other): return False
349 if self.packet_count != other.packet_count: return False
350 if self.byte_count != other.byte_count: 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_counter {")
362 with q.group():
363 with q.indent(2):
364 q.breakable()
365 q.text("packet_count = ");
366 q.text("%#x" % self.packet_count)
367 q.text(","); q.breakable()
368 q.text("byte_count = ");
369 q.text("%#x" % self.byte_count)
370 q.breakable()
371 q.text('}')
372
373class flow_stats_entry(object):
374
375 def __init__(self, table_id=None, duration_sec=None, duration_nsec=None, priority=None, idle_timeout=None, hard_timeout=None, cookie=None, packet_count=None, byte_count=None, match=None, instructions=None):
376 if table_id != None:
377 self.table_id = table_id
378 else:
379 self.table_id = 0
380 if duration_sec != None:
381 self.duration_sec = duration_sec
382 else:
383 self.duration_sec = 0
384 if duration_nsec != None:
385 self.duration_nsec = duration_nsec
386 else:
387 self.duration_nsec = 0
388 if priority != None:
389 self.priority = priority
390 else:
391 self.priority = 0
392 if idle_timeout != None:
393 self.idle_timeout = idle_timeout
394 else:
395 self.idle_timeout = 0
396 if hard_timeout != None:
397 self.hard_timeout = hard_timeout
398 else:
399 self.hard_timeout = 0
400 if cookie != None:
401 self.cookie = cookie
402 else:
403 self.cookie = 0
404 if packet_count != None:
405 self.packet_count = packet_count
406 else:
407 self.packet_count = 0
408 if byte_count != None:
409 self.byte_count = byte_count
410 else:
411 self.byte_count = 0
412 if match != None:
413 self.match = match
414 else:
415 self.match = common.match()
416 if instructions != None:
417 self.instructions = instructions
418 else:
419 self.instructions = []
420 return
421
422 def pack(self):
423 packed = []
424 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
425 packed.append(struct.pack("!B", self.table_id))
426 packed.append('\x00' * 1)
427 packed.append(struct.pack("!L", self.duration_sec))
428 packed.append(struct.pack("!L", self.duration_nsec))
429 packed.append(struct.pack("!H", self.priority))
430 packed.append(struct.pack("!H", self.idle_timeout))
431 packed.append(struct.pack("!H", self.hard_timeout))
432 packed.append('\x00' * 6)
433 packed.append(struct.pack("!Q", self.cookie))
434 packed.append(struct.pack("!Q", self.packet_count))
435 packed.append(struct.pack("!Q", self.byte_count))
436 packed.append(self.match.pack())
Dan Talaycof6202252013-07-02 01:00:29 -0700437 packed.append(util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700438 length = sum([len(x) for x in packed])
439 packed[0] = struct.pack("!H", length)
440 return ''.join(packed)
441
442 @staticmethod
443 def unpack(buf):
444 obj = flow_stats_entry()
445 if type(buf) == loxi.generic_util.OFReader:
446 reader = buf
447 else:
448 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -0700449 _length = reader.read("!H")[0]
450 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700451 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -0700452 obj.duration_sec = reader.read("!L")[0]
453 obj.duration_nsec = reader.read("!L")[0]
454 obj.priority = reader.read("!H")[0]
455 obj.idle_timeout = reader.read("!H")[0]
456 obj.hard_timeout = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700457 reader.skip(6)
Dan Talaycof6202252013-07-02 01:00:29 -0700458 obj.cookie = reader.read("!Q")[0]
459 obj.packet_count = reader.read("!Q")[0]
460 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700461 obj.match = common.match.unpack(reader)
462 obj.instructions = instruction.unpack_list(reader)
463 return obj
464
465 def __eq__(self, other):
466 if type(self) != type(other): return False
467 if self.table_id != other.table_id: return False
468 if self.duration_sec != other.duration_sec: return False
469 if self.duration_nsec != other.duration_nsec: return False
470 if self.priority != other.priority: return False
471 if self.idle_timeout != other.idle_timeout: return False
472 if self.hard_timeout != other.hard_timeout: return False
473 if self.cookie != other.cookie: return False
474 if self.packet_count != other.packet_count: return False
475 if self.byte_count != other.byte_count: return False
476 if self.match != other.match: return False
477 if self.instructions != other.instructions: return False
478 return True
479
480 def __ne__(self, other):
481 return not self.__eq__(other)
482
483 def show(self):
484 import loxi.pp
485 return loxi.pp.pp(self)
486
487 def pretty_print(self, q):
488 q.text("flow_stats_entry {")
489 with q.group():
490 with q.indent(2):
491 q.breakable()
492 q.text("table_id = ");
493 q.text("%#x" % self.table_id)
494 q.text(","); q.breakable()
495 q.text("duration_sec = ");
496 q.text("%#x" % self.duration_sec)
497 q.text(","); q.breakable()
498 q.text("duration_nsec = ");
499 q.text("%#x" % self.duration_nsec)
500 q.text(","); q.breakable()
501 q.text("priority = ");
502 q.text("%#x" % self.priority)
503 q.text(","); q.breakable()
504 q.text("idle_timeout = ");
505 q.text("%#x" % self.idle_timeout)
506 q.text(","); q.breakable()
507 q.text("hard_timeout = ");
508 q.text("%#x" % self.hard_timeout)
509 q.text(","); q.breakable()
510 q.text("cookie = ");
511 q.text("%#x" % self.cookie)
512 q.text(","); q.breakable()
513 q.text("packet_count = ");
514 q.text("%#x" % self.packet_count)
515 q.text(","); q.breakable()
516 q.text("byte_count = ");
517 q.text("%#x" % self.byte_count)
518 q.text(","); q.breakable()
519 q.text("match = ");
520 q.pp(self.match)
521 q.text(","); q.breakable()
522 q.text("instructions = ");
523 q.pp(self.instructions)
524 q.breakable()
525 q.text('}')
526
527class group_desc_stats_entry(object):
528
529 def __init__(self, type=None, group_id=None, buckets=None):
530 if type != None:
531 self.type = type
532 else:
533 self.type = 0
534 if group_id != None:
535 self.group_id = group_id
536 else:
537 self.group_id = 0
538 if buckets != None:
539 self.buckets = buckets
540 else:
541 self.buckets = []
542 return
543
544 def pack(self):
545 packed = []
546 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
547 packed.append(struct.pack("!B", self.type))
548 packed.append('\x00' * 1)
549 packed.append(struct.pack("!L", self.group_id))
Dan Talaycof6202252013-07-02 01:00:29 -0700550 packed.append(util.pack_list(self.buckets))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700551 length = sum([len(x) for x in packed])
552 packed[0] = struct.pack("!H", length)
553 return ''.join(packed)
554
555 @staticmethod
556 def unpack(buf):
557 obj = group_desc_stats_entry()
558 if type(buf) == loxi.generic_util.OFReader:
559 reader = buf
560 else:
561 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -0700562 _length = reader.read("!H")[0]
563 obj.type = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700564 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -0700565 obj.group_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700566 obj.buckets = common.unpack_list_bucket(reader)
567 return obj
568
569 def __eq__(self, other):
570 if type(self) != type(other): return False
571 if self.type != other.type: return False
572 if self.group_id != other.group_id: return False
573 if self.buckets != other.buckets: return False
574 return True
575
576 def __ne__(self, other):
577 return not self.__eq__(other)
578
579 def show(self):
580 import loxi.pp
581 return loxi.pp.pp(self)
582
583 def pretty_print(self, q):
584 q.text("group_desc_stats_entry {")
585 with q.group():
586 with q.indent(2):
587 q.breakable()
588 q.text("type = ");
589 q.text("%#x" % self.type)
590 q.text(","); q.breakable()
591 q.text("group_id = ");
592 q.text("%#x" % self.group_id)
593 q.text(","); q.breakable()
594 q.text("buckets = ");
595 q.pp(self.buckets)
596 q.breakable()
597 q.text('}')
598
599class group_stats_entry(object):
600
601 def __init__(self, group_id=None, ref_count=None, packet_count=None, byte_count=None, duration_sec=None, duration_nsec=None, bucket_stats=None):
602 if group_id != None:
603 self.group_id = group_id
604 else:
605 self.group_id = 0
606 if ref_count != None:
607 self.ref_count = ref_count
608 else:
609 self.ref_count = 0
610 if packet_count != None:
611 self.packet_count = packet_count
612 else:
613 self.packet_count = 0
614 if byte_count != None:
615 self.byte_count = byte_count
616 else:
617 self.byte_count = 0
618 if duration_sec != None:
619 self.duration_sec = duration_sec
620 else:
621 self.duration_sec = 0
622 if duration_nsec != None:
623 self.duration_nsec = duration_nsec
624 else:
625 self.duration_nsec = 0
626 if bucket_stats != None:
627 self.bucket_stats = bucket_stats
628 else:
629 self.bucket_stats = []
630 return
631
632 def pack(self):
633 packed = []
634 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
635 packed.append('\x00' * 2)
636 packed.append(struct.pack("!L", self.group_id))
637 packed.append(struct.pack("!L", self.ref_count))
638 packed.append('\x00' * 4)
639 packed.append(struct.pack("!Q", self.packet_count))
640 packed.append(struct.pack("!Q", self.byte_count))
641 packed.append(struct.pack("!L", self.duration_sec))
642 packed.append(struct.pack("!L", self.duration_nsec))
Dan Talaycof6202252013-07-02 01:00:29 -0700643 packed.append(util.pack_list(self.bucket_stats))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700644 length = sum([len(x) for x in packed])
645 packed[0] = struct.pack("!H", length)
646 return ''.join(packed)
647
648 @staticmethod
649 def unpack(buf):
650 obj = group_stats_entry()
651 if type(buf) == loxi.generic_util.OFReader:
652 reader = buf
653 else:
654 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -0700655 _length = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700656 reader.skip(2)
Dan Talaycof6202252013-07-02 01:00:29 -0700657 obj.group_id = reader.read("!L")[0]
658 obj.ref_count = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700659 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -0700660 obj.packet_count = reader.read("!Q")[0]
661 obj.byte_count = reader.read("!Q")[0]
662 obj.duration_sec = reader.read("!L")[0]
663 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700664 obj.bucket_stats = loxi.generic_util.unpack_list(reader, common.bucket_counter.unpack)
665 return obj
666
667 def __eq__(self, other):
668 if type(self) != type(other): return False
669 if self.group_id != other.group_id: return False
670 if self.ref_count != other.ref_count: return False
671 if self.packet_count != other.packet_count: return False
672 if self.byte_count != other.byte_count: return False
673 if self.duration_sec != other.duration_sec: return False
674 if self.duration_nsec != other.duration_nsec: return False
675 if self.bucket_stats != other.bucket_stats: return False
676 return True
677
678 def __ne__(self, other):
679 return not self.__eq__(other)
680
681 def show(self):
682 import loxi.pp
683 return loxi.pp.pp(self)
684
685 def pretty_print(self, q):
686 q.text("group_stats_entry {")
687 with q.group():
688 with q.indent(2):
689 q.breakable()
690 q.text("group_id = ");
691 q.text("%#x" % self.group_id)
692 q.text(","); q.breakable()
693 q.text("ref_count = ");
694 q.text("%#x" % self.ref_count)
695 q.text(","); q.breakable()
696 q.text("packet_count = ");
697 q.text("%#x" % self.packet_count)
698 q.text(","); q.breakable()
699 q.text("byte_count = ");
700 q.text("%#x" % self.byte_count)
701 q.text(","); q.breakable()
702 q.text("duration_sec = ");
703 q.text("%#x" % self.duration_sec)
704 q.text(","); q.breakable()
705 q.text("duration_nsec = ");
706 q.text("%#x" % self.duration_nsec)
707 q.text(","); q.breakable()
708 q.text("bucket_stats = ");
709 q.pp(self.bucket_stats)
710 q.breakable()
711 q.text('}')
712
713class hello_elem_versionbitmap(object):
Dan Talaycof6202252013-07-02 01:00:29 -0700714 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -0700715
716 def __init__(self, bitmaps=None):
717 if bitmaps != None:
718 self.bitmaps = bitmaps
719 else:
720 self.bitmaps = []
721 return
722
723 def pack(self):
724 packed = []
725 packed.append(struct.pack("!H", self.type))
726 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700727 packed.append(util.pack_list(self.bitmaps))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700728 length = sum([len(x) for x in packed])
729 packed[1] = struct.pack("!H", length)
730 return ''.join(packed)
731
732 @staticmethod
733 def unpack(buf):
734 obj = hello_elem_versionbitmap()
735 if type(buf) == loxi.generic_util.OFReader:
736 reader = buf
737 else:
738 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -0700739 _type = reader.read("!H")[0]
740 assert(_type == 1)
741 _length = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700742 obj.bitmaps = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
743 return obj
744
745 def __eq__(self, other):
746 if type(self) != type(other): return False
747 if self.bitmaps != other.bitmaps: 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("hello_elem_versionbitmap {")
759 with q.group():
760 with q.indent(2):
761 q.breakable()
762 q.text("bitmaps = ");
763 q.pp(self.bitmaps)
764 q.breakable()
765 q.text('}')
766
767class match_v3(object):
768 type = 1
769
770 def __init__(self, oxm_list=None):
771 if oxm_list != None:
772 self.oxm_list = oxm_list
773 else:
774 self.oxm_list = []
775 return
776
777 def pack(self):
778 packed = []
779 packed.append(struct.pack("!H", self.type))
780 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700781 packed.append(util.pack_list(self.oxm_list))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700782 length = sum([len(x) for x in packed])
783 packed[1] = struct.pack("!H", length)
Rich Laned53156a2013-08-05 17:17:33 -0700784 packed.append(loxi.generic_util.pad_to(8, length))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700785 return ''.join(packed)
786
787 @staticmethod
788 def unpack(buf):
789 obj = match_v3()
790 if type(buf) == loxi.generic_util.OFReader:
791 reader = buf
792 else:
793 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -0700794 _type = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700795 assert(_type == 1)
Dan Talaycof6202252013-07-02 01:00:29 -0700796 _length = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700797 obj.oxm_list = oxm.unpack_list(reader.slice(_length-4))
Rich Laned53156a2013-08-05 17:17:33 -0700798 reader.skip_align()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700799 return obj
800
801 def __eq__(self, other):
802 if type(self) != type(other): return False
803 if self.oxm_list != other.oxm_list: return False
804 return True
805
806 def __ne__(self, other):
807 return not self.__eq__(other)
808
809 def show(self):
810 import loxi.pp
811 return loxi.pp.pp(self)
812
813 def pretty_print(self, q):
814 q.text("match_v3 {")
815 with q.group():
816 with q.indent(2):
817 q.breakable()
818 q.text("oxm_list = ");
819 q.pp(self.oxm_list)
820 q.breakable()
821 q.text('}')
822
823class meter_band_stats(object):
824
825 def __init__(self, packet_band_count=None, byte_band_count=None):
826 if packet_band_count != None:
827 self.packet_band_count = packet_band_count
828 else:
829 self.packet_band_count = 0
830 if byte_band_count != None:
831 self.byte_band_count = byte_band_count
832 else:
833 self.byte_band_count = 0
834 return
835
836 def pack(self):
837 packed = []
838 packed.append(struct.pack("!Q", self.packet_band_count))
839 packed.append(struct.pack("!Q", self.byte_band_count))
840 return ''.join(packed)
841
842 @staticmethod
843 def unpack(buf):
844 obj = meter_band_stats()
845 if type(buf) == loxi.generic_util.OFReader:
846 reader = buf
847 else:
848 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -0700849 obj.packet_band_count = reader.read("!Q")[0]
850 obj.byte_band_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700851 return obj
852
853 def __eq__(self, other):
854 if type(self) != type(other): return False
855 if self.packet_band_count != other.packet_band_count: return False
856 if self.byte_band_count != other.byte_band_count: return False
857 return True
858
859 def __ne__(self, other):
860 return not self.__eq__(other)
861
862 def show(self):
863 import loxi.pp
864 return loxi.pp.pp(self)
865
866 def pretty_print(self, q):
867 q.text("meter_band_stats {")
868 with q.group():
869 with q.indent(2):
870 q.breakable()
871 q.text("packet_band_count = ");
872 q.text("%#x" % self.packet_band_count)
873 q.text(","); q.breakable()
874 q.text("byte_band_count = ");
875 q.text("%#x" % self.byte_band_count)
876 q.breakable()
877 q.text('}')
878
879class meter_config(object):
880
881 def __init__(self, flags=None, meter_id=None, entries=None):
882 if flags != None:
883 self.flags = flags
884 else:
885 self.flags = 0
886 if meter_id != None:
887 self.meter_id = meter_id
888 else:
889 self.meter_id = 0
890 if entries != None:
891 self.entries = entries
892 else:
893 self.entries = []
894 return
895
896 def pack(self):
897 packed = []
898 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
899 packed.append(struct.pack("!H", self.flags))
900 packed.append(struct.pack("!L", self.meter_id))
Dan Talaycof6202252013-07-02 01:00:29 -0700901 packed.append(util.pack_list(self.entries))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700902 length = sum([len(x) for x in packed])
903 packed[0] = struct.pack("!H", length)
904 return ''.join(packed)
905
906 @staticmethod
907 def unpack(buf):
908 obj = meter_config()
909 if type(buf) == loxi.generic_util.OFReader:
910 reader = buf
911 else:
912 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -0700913 _length = reader.read("!H")[0]
914 obj.flags = reader.read("!H")[0]
915 obj.meter_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700916 obj.entries = meter_band.unpack_list(reader)
917 return obj
918
919 def __eq__(self, other):
920 if type(self) != type(other): return False
921 if self.flags != other.flags: return False
922 if self.meter_id != other.meter_id: return False
923 if self.entries != other.entries: return False
924 return True
925
926 def __ne__(self, other):
927 return not self.__eq__(other)
928
929 def show(self):
930 import loxi.pp
931 return loxi.pp.pp(self)
932
933 def pretty_print(self, q):
934 q.text("meter_config {")
935 with q.group():
936 with q.indent(2):
937 q.breakable()
938 q.text("flags = ");
939 q.text("%#x" % self.flags)
940 q.text(","); q.breakable()
941 q.text("meter_id = ");
942 q.text("%#x" % self.meter_id)
943 q.text(","); q.breakable()
944 q.text("entries = ");
945 q.pp(self.entries)
946 q.breakable()
947 q.text('}')
948
949class meter_features(object):
950
951 def __init__(self, max_meter=None, band_types=None, capabilities=None, max_bands=None, max_color=None):
952 if max_meter != None:
953 self.max_meter = max_meter
954 else:
955 self.max_meter = 0
956 if band_types != None:
957 self.band_types = band_types
958 else:
959 self.band_types = 0
960 if capabilities != None:
961 self.capabilities = capabilities
962 else:
963 self.capabilities = 0
964 if max_bands != None:
965 self.max_bands = max_bands
966 else:
967 self.max_bands = 0
968 if max_color != None:
969 self.max_color = max_color
970 else:
971 self.max_color = 0
972 return
973
974 def pack(self):
975 packed = []
976 packed.append(struct.pack("!L", self.max_meter))
977 packed.append(struct.pack("!L", self.band_types))
978 packed.append(struct.pack("!L", self.capabilities))
979 packed.append(struct.pack("!B", self.max_bands))
980 packed.append(struct.pack("!B", self.max_color))
981 packed.append('\x00' * 2)
982 return ''.join(packed)
983
984 @staticmethod
985 def unpack(buf):
986 obj = meter_features()
987 if type(buf) == loxi.generic_util.OFReader:
988 reader = buf
989 else:
990 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -0700991 obj.max_meter = reader.read("!L")[0]
992 obj.band_types = reader.read("!L")[0]
993 obj.capabilities = reader.read("!L")[0]
994 obj.max_bands = reader.read("!B")[0]
995 obj.max_color = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700996 reader.skip(2)
997 return obj
998
999 def __eq__(self, other):
1000 if type(self) != type(other): return False
1001 if self.max_meter != other.max_meter: return False
1002 if self.band_types != other.band_types: return False
1003 if self.capabilities != other.capabilities: return False
1004 if self.max_bands != other.max_bands: return False
1005 if self.max_color != other.max_color: return False
1006 return True
1007
1008 def __ne__(self, other):
1009 return not self.__eq__(other)
1010
1011 def show(self):
1012 import loxi.pp
1013 return loxi.pp.pp(self)
1014
1015 def pretty_print(self, q):
1016 q.text("meter_features {")
1017 with q.group():
1018 with q.indent(2):
1019 q.breakable()
1020 q.text("max_meter = ");
1021 q.text("%#x" % self.max_meter)
1022 q.text(","); q.breakable()
1023 q.text("band_types = ");
1024 q.text("%#x" % self.band_types)
1025 q.text(","); q.breakable()
1026 q.text("capabilities = ");
1027 q.text("%#x" % self.capabilities)
1028 q.text(","); q.breakable()
1029 q.text("max_bands = ");
1030 q.text("%#x" % self.max_bands)
1031 q.text(","); q.breakable()
1032 q.text("max_color = ");
1033 q.text("%#x" % self.max_color)
1034 q.breakable()
1035 q.text('}')
1036
1037class meter_stats(object):
1038
1039 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):
1040 if meter_id != None:
1041 self.meter_id = meter_id
1042 else:
1043 self.meter_id = 0
1044 if flow_count != None:
1045 self.flow_count = flow_count
1046 else:
1047 self.flow_count = 0
1048 if packet_in_count != None:
1049 self.packet_in_count = packet_in_count
1050 else:
1051 self.packet_in_count = 0
1052 if byte_in_count != None:
1053 self.byte_in_count = byte_in_count
1054 else:
1055 self.byte_in_count = 0
1056 if duration_sec != None:
1057 self.duration_sec = duration_sec
1058 else:
1059 self.duration_sec = 0
1060 if duration_nsec != None:
1061 self.duration_nsec = duration_nsec
1062 else:
1063 self.duration_nsec = 0
1064 if band_stats != None:
1065 self.band_stats = band_stats
1066 else:
1067 self.band_stats = []
1068 return
1069
1070 def pack(self):
1071 packed = []
1072 packed.append(struct.pack("!L", self.meter_id))
1073 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1074 packed.append('\x00' * 6)
1075 packed.append(struct.pack("!L", self.flow_count))
1076 packed.append(struct.pack("!Q", self.packet_in_count))
1077 packed.append(struct.pack("!Q", self.byte_in_count))
1078 packed.append(struct.pack("!L", self.duration_sec))
1079 packed.append(struct.pack("!L", self.duration_nsec))
Dan Talaycof6202252013-07-02 01:00:29 -07001080 packed.append(util.pack_list(self.band_stats))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001081 length = sum([len(x) for x in packed])
1082 packed[1] = struct.pack("!H", length)
1083 return ''.join(packed)
1084
1085 @staticmethod
1086 def unpack(buf):
1087 obj = meter_stats()
1088 if type(buf) == loxi.generic_util.OFReader:
1089 reader = buf
1090 else:
1091 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001092 obj.meter_id = reader.read("!L")[0]
1093 _len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001094 reader.skip(6)
Dan Talaycof6202252013-07-02 01:00:29 -07001095 obj.flow_count = reader.read("!L")[0]
1096 obj.packet_in_count = reader.read("!Q")[0]
1097 obj.byte_in_count = reader.read("!Q")[0]
1098 obj.duration_sec = reader.read("!L")[0]
1099 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001100 obj.band_stats = loxi.generic_util.unpack_list(reader, common.meter_band_stats.unpack)
1101 return obj
1102
1103 def __eq__(self, other):
1104 if type(self) != type(other): return False
1105 if self.meter_id != other.meter_id: return False
1106 if self.flow_count != other.flow_count: return False
1107 if self.packet_in_count != other.packet_in_count: return False
1108 if self.byte_in_count != other.byte_in_count: return False
1109 if self.duration_sec != other.duration_sec: return False
1110 if self.duration_nsec != other.duration_nsec: return False
1111 if self.band_stats != other.band_stats: return False
1112 return True
1113
1114 def __ne__(self, other):
1115 return not self.__eq__(other)
1116
1117 def show(self):
1118 import loxi.pp
1119 return loxi.pp.pp(self)
1120
1121 def pretty_print(self, q):
1122 q.text("meter_stats {")
1123 with q.group():
1124 with q.indent(2):
1125 q.breakable()
1126 q.text("meter_id = ");
1127 q.text("%#x" % self.meter_id)
1128 q.text(","); q.breakable()
1129 q.text("flow_count = ");
1130 q.text("%#x" % self.flow_count)
1131 q.text(","); q.breakable()
1132 q.text("packet_in_count = ");
1133 q.text("%#x" % self.packet_in_count)
1134 q.text(","); q.breakable()
1135 q.text("byte_in_count = ");
1136 q.text("%#x" % self.byte_in_count)
1137 q.text(","); q.breakable()
1138 q.text("duration_sec = ");
1139 q.text("%#x" % self.duration_sec)
1140 q.text(","); q.breakable()
1141 q.text("duration_nsec = ");
1142 q.text("%#x" % self.duration_nsec)
1143 q.text(","); q.breakable()
1144 q.text("band_stats = ");
1145 q.pp(self.band_stats)
1146 q.breakable()
1147 q.text('}')
1148
1149class packet_queue(object):
1150
1151 def __init__(self, queue_id=None, port=None, properties=None):
1152 if queue_id != None:
1153 self.queue_id = queue_id
1154 else:
1155 self.queue_id = 0
1156 if port != None:
1157 self.port = port
1158 else:
1159 self.port = 0
1160 if properties != None:
1161 self.properties = properties
1162 else:
1163 self.properties = []
1164 return
1165
1166 def pack(self):
1167 packed = []
1168 packed.append(struct.pack("!L", self.queue_id))
Dan Talaycof6202252013-07-02 01:00:29 -07001169 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001170 packed.append(struct.pack("!H", 0)) # placeholder for len at index 2
1171 packed.append('\x00' * 6)
Dan Talaycof6202252013-07-02 01:00:29 -07001172 packed.append(util.pack_list(self.properties))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001173 length = sum([len(x) for x in packed])
1174 packed[2] = struct.pack("!H", length)
1175 return ''.join(packed)
1176
1177 @staticmethod
1178 def unpack(buf):
1179 obj = packet_queue()
1180 if type(buf) == loxi.generic_util.OFReader:
1181 reader = buf
1182 else:
1183 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001184 obj.queue_id = reader.read("!L")[0]
1185 obj.port = util.unpack_port_no(reader)
1186 _len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001187 reader.skip(6)
1188 obj.properties = common.unpack_list_queue_prop(reader)
1189 return obj
1190
1191 def __eq__(self, other):
1192 if type(self) != type(other): return False
1193 if self.queue_id != other.queue_id: return False
1194 if self.port != other.port: return False
1195 if self.properties != other.properties: return False
1196 return True
1197
1198 def __ne__(self, other):
1199 return not self.__eq__(other)
1200
1201 def show(self):
1202 import loxi.pp
1203 return loxi.pp.pp(self)
1204
1205 def pretty_print(self, q):
1206 q.text("packet_queue {")
1207 with q.group():
1208 with q.indent(2):
1209 q.breakable()
1210 q.text("queue_id = ");
1211 q.text("%#x" % self.queue_id)
1212 q.text(","); q.breakable()
1213 q.text("port = ");
1214 q.text(util.pretty_port(self.port))
1215 q.text(","); q.breakable()
1216 q.text("properties = ");
1217 q.pp(self.properties)
1218 q.breakable()
1219 q.text('}')
1220
1221class port_desc(object):
1222
1223 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):
1224 if port_no != None:
1225 self.port_no = port_no
1226 else:
1227 self.port_no = 0
1228 if hw_addr != None:
1229 self.hw_addr = hw_addr
1230 else:
1231 self.hw_addr = [0,0,0,0,0,0]
1232 if name != None:
1233 self.name = name
1234 else:
1235 self.name = ""
1236 if config != None:
1237 self.config = config
1238 else:
1239 self.config = 0
1240 if state != None:
1241 self.state = state
1242 else:
1243 self.state = 0
1244 if curr != None:
1245 self.curr = curr
1246 else:
1247 self.curr = 0
1248 if advertised != None:
1249 self.advertised = advertised
1250 else:
1251 self.advertised = 0
1252 if supported != None:
1253 self.supported = supported
1254 else:
1255 self.supported = 0
1256 if peer != None:
1257 self.peer = peer
1258 else:
1259 self.peer = 0
1260 if curr_speed != None:
1261 self.curr_speed = curr_speed
1262 else:
1263 self.curr_speed = 0
1264 if max_speed != None:
1265 self.max_speed = max_speed
1266 else:
1267 self.max_speed = 0
1268 return
1269
1270 def pack(self):
1271 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07001272 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001273 packed.append('\x00' * 4)
1274 packed.append(struct.pack("!6B", *self.hw_addr))
1275 packed.append('\x00' * 2)
1276 packed.append(struct.pack("!16s", self.name))
1277 packed.append(struct.pack("!L", self.config))
1278 packed.append(struct.pack("!L", self.state))
1279 packed.append(struct.pack("!L", self.curr))
1280 packed.append(struct.pack("!L", self.advertised))
1281 packed.append(struct.pack("!L", self.supported))
1282 packed.append(struct.pack("!L", self.peer))
1283 packed.append(struct.pack("!L", self.curr_speed))
1284 packed.append(struct.pack("!L", self.max_speed))
1285 return ''.join(packed)
1286
1287 @staticmethod
1288 def unpack(buf):
1289 obj = port_desc()
1290 if type(buf) == loxi.generic_util.OFReader:
1291 reader = buf
1292 else:
1293 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001294 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001295 reader.skip(4)
1296 obj.hw_addr = list(reader.read('!6B'))
1297 reader.skip(2)
1298 obj.name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -07001299 obj.config = reader.read("!L")[0]
1300 obj.state = reader.read("!L")[0]
1301 obj.curr = reader.read("!L")[0]
1302 obj.advertised = reader.read("!L")[0]
1303 obj.supported = reader.read("!L")[0]
1304 obj.peer = reader.read("!L")[0]
1305 obj.curr_speed = reader.read("!L")[0]
1306 obj.max_speed = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001307 return obj
1308
1309 def __eq__(self, other):
1310 if type(self) != type(other): return False
1311 if self.port_no != other.port_no: return False
1312 if self.hw_addr != other.hw_addr: return False
1313 if self.name != other.name: return False
1314 if self.config != other.config: return False
1315 if self.state != other.state: return False
1316 if self.curr != other.curr: return False
1317 if self.advertised != other.advertised: return False
1318 if self.supported != other.supported: return False
1319 if self.peer != other.peer: return False
1320 if self.curr_speed != other.curr_speed: return False
1321 if self.max_speed != other.max_speed: return False
1322 return True
1323
1324 def __ne__(self, other):
1325 return not self.__eq__(other)
1326
1327 def show(self):
1328 import loxi.pp
1329 return loxi.pp.pp(self)
1330
1331 def pretty_print(self, q):
1332 q.text("port_desc {")
1333 with q.group():
1334 with q.indent(2):
1335 q.breakable()
1336 q.text("port_no = ");
1337 q.text(util.pretty_port(self.port_no))
1338 q.text(","); q.breakable()
1339 q.text("hw_addr = ");
1340 q.text(util.pretty_mac(self.hw_addr))
1341 q.text(","); q.breakable()
1342 q.text("name = ");
1343 q.pp(self.name)
1344 q.text(","); q.breakable()
1345 q.text("config = ");
1346 q.text("%#x" % self.config)
1347 q.text(","); q.breakable()
1348 q.text("state = ");
1349 q.text("%#x" % self.state)
1350 q.text(","); q.breakable()
1351 q.text("curr = ");
1352 q.text("%#x" % self.curr)
1353 q.text(","); q.breakable()
1354 q.text("advertised = ");
1355 q.text("%#x" % self.advertised)
1356 q.text(","); q.breakable()
1357 q.text("supported = ");
1358 q.text("%#x" % self.supported)
1359 q.text(","); q.breakable()
1360 q.text("peer = ");
1361 q.text("%#x" % self.peer)
1362 q.text(","); q.breakable()
1363 q.text("curr_speed = ");
1364 q.text("%#x" % self.curr_speed)
1365 q.text(","); q.breakable()
1366 q.text("max_speed = ");
1367 q.text("%#x" % self.max_speed)
1368 q.breakable()
1369 q.text('}')
1370
1371class port_stats_entry(object):
1372
1373 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):
1374 if port_no != None:
1375 self.port_no = port_no
1376 else:
1377 self.port_no = 0
1378 if rx_packets != None:
1379 self.rx_packets = rx_packets
1380 else:
1381 self.rx_packets = 0
1382 if tx_packets != None:
1383 self.tx_packets = tx_packets
1384 else:
1385 self.tx_packets = 0
1386 if rx_bytes != None:
1387 self.rx_bytes = rx_bytes
1388 else:
1389 self.rx_bytes = 0
1390 if tx_bytes != None:
1391 self.tx_bytes = tx_bytes
1392 else:
1393 self.tx_bytes = 0
1394 if rx_dropped != None:
1395 self.rx_dropped = rx_dropped
1396 else:
1397 self.rx_dropped = 0
1398 if tx_dropped != None:
1399 self.tx_dropped = tx_dropped
1400 else:
1401 self.tx_dropped = 0
1402 if rx_errors != None:
1403 self.rx_errors = rx_errors
1404 else:
1405 self.rx_errors = 0
1406 if tx_errors != None:
1407 self.tx_errors = tx_errors
1408 else:
1409 self.tx_errors = 0
1410 if rx_frame_err != None:
1411 self.rx_frame_err = rx_frame_err
1412 else:
1413 self.rx_frame_err = 0
1414 if rx_over_err != None:
1415 self.rx_over_err = rx_over_err
1416 else:
1417 self.rx_over_err = 0
1418 if rx_crc_err != None:
1419 self.rx_crc_err = rx_crc_err
1420 else:
1421 self.rx_crc_err = 0
1422 if collisions != None:
1423 self.collisions = collisions
1424 else:
1425 self.collisions = 0
1426 if duration_sec != None:
1427 self.duration_sec = duration_sec
1428 else:
1429 self.duration_sec = 0
1430 if duration_nsec != None:
1431 self.duration_nsec = duration_nsec
1432 else:
1433 self.duration_nsec = 0
1434 return
1435
1436 def pack(self):
1437 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07001438 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001439 packed.append('\x00' * 4)
1440 packed.append(struct.pack("!Q", self.rx_packets))
1441 packed.append(struct.pack("!Q", self.tx_packets))
1442 packed.append(struct.pack("!Q", self.rx_bytes))
1443 packed.append(struct.pack("!Q", self.tx_bytes))
1444 packed.append(struct.pack("!Q", self.rx_dropped))
1445 packed.append(struct.pack("!Q", self.tx_dropped))
1446 packed.append(struct.pack("!Q", self.rx_errors))
1447 packed.append(struct.pack("!Q", self.tx_errors))
1448 packed.append(struct.pack("!Q", self.rx_frame_err))
1449 packed.append(struct.pack("!Q", self.rx_over_err))
1450 packed.append(struct.pack("!Q", self.rx_crc_err))
1451 packed.append(struct.pack("!Q", self.collisions))
1452 packed.append(struct.pack("!L", self.duration_sec))
1453 packed.append(struct.pack("!L", self.duration_nsec))
1454 return ''.join(packed)
1455
1456 @staticmethod
1457 def unpack(buf):
1458 obj = port_stats_entry()
1459 if type(buf) == loxi.generic_util.OFReader:
1460 reader = buf
1461 else:
1462 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001463 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001464 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001465 obj.rx_packets = reader.read("!Q")[0]
1466 obj.tx_packets = reader.read("!Q")[0]
1467 obj.rx_bytes = reader.read("!Q")[0]
1468 obj.tx_bytes = reader.read("!Q")[0]
1469 obj.rx_dropped = reader.read("!Q")[0]
1470 obj.tx_dropped = reader.read("!Q")[0]
1471 obj.rx_errors = reader.read("!Q")[0]
1472 obj.tx_errors = reader.read("!Q")[0]
1473 obj.rx_frame_err = reader.read("!Q")[0]
1474 obj.rx_over_err = reader.read("!Q")[0]
1475 obj.rx_crc_err = reader.read("!Q")[0]
1476 obj.collisions = reader.read("!Q")[0]
1477 obj.duration_sec = reader.read("!L")[0]
1478 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001479 return obj
1480
1481 def __eq__(self, other):
1482 if type(self) != type(other): return False
1483 if self.port_no != other.port_no: return False
1484 if self.rx_packets != other.rx_packets: return False
1485 if self.tx_packets != other.tx_packets: return False
1486 if self.rx_bytes != other.rx_bytes: return False
1487 if self.tx_bytes != other.tx_bytes: return False
1488 if self.rx_dropped != other.rx_dropped: return False
1489 if self.tx_dropped != other.tx_dropped: return False
1490 if self.rx_errors != other.rx_errors: return False
1491 if self.tx_errors != other.tx_errors: return False
1492 if self.rx_frame_err != other.rx_frame_err: return False
1493 if self.rx_over_err != other.rx_over_err: return False
1494 if self.rx_crc_err != other.rx_crc_err: return False
1495 if self.collisions != other.collisions: return False
1496 if self.duration_sec != other.duration_sec: return False
1497 if self.duration_nsec != other.duration_nsec: return False
1498 return True
1499
1500 def __ne__(self, other):
1501 return not self.__eq__(other)
1502
1503 def show(self):
1504 import loxi.pp
1505 return loxi.pp.pp(self)
1506
1507 def pretty_print(self, q):
1508 q.text("port_stats_entry {")
1509 with q.group():
1510 with q.indent(2):
1511 q.breakable()
1512 q.text("port_no = ");
1513 q.text(util.pretty_port(self.port_no))
1514 q.text(","); q.breakable()
1515 q.text("rx_packets = ");
1516 q.text("%#x" % self.rx_packets)
1517 q.text(","); q.breakable()
1518 q.text("tx_packets = ");
1519 q.text("%#x" % self.tx_packets)
1520 q.text(","); q.breakable()
1521 q.text("rx_bytes = ");
1522 q.text("%#x" % self.rx_bytes)
1523 q.text(","); q.breakable()
1524 q.text("tx_bytes = ");
1525 q.text("%#x" % self.tx_bytes)
1526 q.text(","); q.breakable()
1527 q.text("rx_dropped = ");
1528 q.text("%#x" % self.rx_dropped)
1529 q.text(","); q.breakable()
1530 q.text("tx_dropped = ");
1531 q.text("%#x" % self.tx_dropped)
1532 q.text(","); q.breakable()
1533 q.text("rx_errors = ");
1534 q.text("%#x" % self.rx_errors)
1535 q.text(","); q.breakable()
1536 q.text("tx_errors = ");
1537 q.text("%#x" % self.tx_errors)
1538 q.text(","); q.breakable()
1539 q.text("rx_frame_err = ");
1540 q.text("%#x" % self.rx_frame_err)
1541 q.text(","); q.breakable()
1542 q.text("rx_over_err = ");
1543 q.text("%#x" % self.rx_over_err)
1544 q.text(","); q.breakable()
1545 q.text("rx_crc_err = ");
1546 q.text("%#x" % self.rx_crc_err)
1547 q.text(","); q.breakable()
1548 q.text("collisions = ");
1549 q.text("%#x" % self.collisions)
1550 q.text(","); q.breakable()
1551 q.text("duration_sec = ");
1552 q.text("%#x" % self.duration_sec)
1553 q.text(","); q.breakable()
1554 q.text("duration_nsec = ");
1555 q.text("%#x" % self.duration_nsec)
1556 q.breakable()
1557 q.text('}')
1558
1559class queue_prop_experimenter(object):
Dan Talaycof6202252013-07-02 01:00:29 -07001560 type = 65535
Rich Lanec2ee4b82013-04-24 17:12:38 -07001561
1562 def __init__(self, experimenter=None, data=None):
1563 if experimenter != None:
1564 self.experimenter = experimenter
1565 else:
1566 self.experimenter = 0
1567 if data != None:
1568 self.data = data
1569 else:
Dan Talaycof6202252013-07-02 01:00:29 -07001570 self.data = ''
Rich Lanec2ee4b82013-04-24 17:12:38 -07001571 return
1572
1573 def pack(self):
1574 packed = []
1575 packed.append(struct.pack("!H", self.type))
1576 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1577 packed.append('\x00' * 4)
1578 packed.append(struct.pack("!L", self.experimenter))
1579 packed.append('\x00' * 4)
1580 packed.append(self.data)
1581 length = sum([len(x) for x in packed])
1582 packed[1] = struct.pack("!H", length)
1583 return ''.join(packed)
1584
1585 @staticmethod
1586 def unpack(buf):
1587 obj = queue_prop_experimenter()
1588 if type(buf) == loxi.generic_util.OFReader:
1589 reader = buf
1590 else:
1591 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001592 _type = reader.read("!H")[0]
1593 assert(_type == 65535)
1594 _len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001595 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001596 obj.experimenter = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001597 reader.skip(4)
1598 obj.data = str(reader.read_all())
1599 return obj
1600
1601 def __eq__(self, other):
1602 if type(self) != type(other): return False
1603 if self.experimenter != other.experimenter: return False
1604 if self.data != other.data: return False
1605 return True
1606
1607 def __ne__(self, other):
1608 return not self.__eq__(other)
1609
1610 def show(self):
1611 import loxi.pp
1612 return loxi.pp.pp(self)
1613
1614 def pretty_print(self, q):
1615 q.text("queue_prop_experimenter {")
1616 with q.group():
1617 with q.indent(2):
1618 q.breakable()
1619 q.text("experimenter = ");
1620 q.text("%#x" % self.experimenter)
1621 q.text(","); q.breakable()
1622 q.text("data = ");
1623 q.pp(self.data)
1624 q.breakable()
1625 q.text('}')
1626
1627class queue_prop_max_rate(object):
Dan Talaycof6202252013-07-02 01:00:29 -07001628 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07001629
1630 def __init__(self, rate=None):
1631 if rate != None:
1632 self.rate = rate
1633 else:
1634 self.rate = 0
1635 return
1636
1637 def pack(self):
1638 packed = []
1639 packed.append(struct.pack("!H", self.type))
1640 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1641 packed.append('\x00' * 4)
1642 packed.append(struct.pack("!H", self.rate))
1643 packed.append('\x00' * 6)
1644 length = sum([len(x) for x in packed])
1645 packed[1] = struct.pack("!H", length)
1646 return ''.join(packed)
1647
1648 @staticmethod
1649 def unpack(buf):
1650 obj = queue_prop_max_rate()
1651 if type(buf) == loxi.generic_util.OFReader:
1652 reader = buf
1653 else:
1654 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001655 _type = reader.read("!H")[0]
1656 assert(_type == 2)
1657 _len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001658 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001659 obj.rate = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001660 reader.skip(6)
1661 return obj
1662
1663 def __eq__(self, other):
1664 if type(self) != type(other): return False
1665 if self.rate != other.rate: return False
1666 return True
1667
1668 def __ne__(self, other):
1669 return not self.__eq__(other)
1670
1671 def show(self):
1672 import loxi.pp
1673 return loxi.pp.pp(self)
1674
1675 def pretty_print(self, q):
1676 q.text("queue_prop_max_rate {")
1677 with q.group():
1678 with q.indent(2):
1679 q.breakable()
1680 q.text("rate = ");
1681 q.text("%#x" % self.rate)
1682 q.breakable()
1683 q.text('}')
1684
1685class queue_prop_min_rate(object):
Dan Talaycof6202252013-07-02 01:00:29 -07001686 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07001687
1688 def __init__(self, rate=None):
1689 if rate != None:
1690 self.rate = rate
1691 else:
1692 self.rate = 0
1693 return
1694
1695 def pack(self):
1696 packed = []
1697 packed.append(struct.pack("!H", self.type))
1698 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1699 packed.append('\x00' * 4)
1700 packed.append(struct.pack("!H", self.rate))
1701 packed.append('\x00' * 6)
1702 length = sum([len(x) for x in packed])
1703 packed[1] = struct.pack("!H", length)
1704 return ''.join(packed)
1705
1706 @staticmethod
1707 def unpack(buf):
1708 obj = queue_prop_min_rate()
1709 if type(buf) == loxi.generic_util.OFReader:
1710 reader = buf
1711 else:
1712 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001713 _type = reader.read("!H")[0]
1714 assert(_type == 1)
1715 _len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001716 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001717 obj.rate = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001718 reader.skip(6)
1719 return obj
1720
1721 def __eq__(self, other):
1722 if type(self) != type(other): return False
1723 if self.rate != other.rate: return False
1724 return True
1725
1726 def __ne__(self, other):
1727 return not self.__eq__(other)
1728
1729 def show(self):
1730 import loxi.pp
1731 return loxi.pp.pp(self)
1732
1733 def pretty_print(self, q):
1734 q.text("queue_prop_min_rate {")
1735 with q.group():
1736 with q.indent(2):
1737 q.breakable()
1738 q.text("rate = ");
1739 q.text("%#x" % self.rate)
1740 q.breakable()
1741 q.text('}')
1742
1743class queue_stats_entry(object):
1744
1745 def __init__(self, port_no=None, queue_id=None, tx_bytes=None, tx_packets=None, tx_errors=None, duration_sec=None, duration_nsec=None):
1746 if port_no != None:
1747 self.port_no = port_no
1748 else:
1749 self.port_no = 0
1750 if queue_id != None:
1751 self.queue_id = queue_id
1752 else:
1753 self.queue_id = 0
1754 if tx_bytes != None:
1755 self.tx_bytes = tx_bytes
1756 else:
1757 self.tx_bytes = 0
1758 if tx_packets != None:
1759 self.tx_packets = tx_packets
1760 else:
1761 self.tx_packets = 0
1762 if tx_errors != None:
1763 self.tx_errors = tx_errors
1764 else:
1765 self.tx_errors = 0
1766 if duration_sec != None:
1767 self.duration_sec = duration_sec
1768 else:
1769 self.duration_sec = 0
1770 if duration_nsec != None:
1771 self.duration_nsec = duration_nsec
1772 else:
1773 self.duration_nsec = 0
1774 return
1775
1776 def pack(self):
1777 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07001778 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001779 packed.append(struct.pack("!L", self.queue_id))
1780 packed.append(struct.pack("!Q", self.tx_bytes))
1781 packed.append(struct.pack("!Q", self.tx_packets))
1782 packed.append(struct.pack("!Q", self.tx_errors))
1783 packed.append(struct.pack("!L", self.duration_sec))
1784 packed.append(struct.pack("!L", self.duration_nsec))
1785 return ''.join(packed)
1786
1787 @staticmethod
1788 def unpack(buf):
1789 obj = queue_stats_entry()
1790 if type(buf) == loxi.generic_util.OFReader:
1791 reader = buf
1792 else:
1793 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001794 obj.port_no = util.unpack_port_no(reader)
1795 obj.queue_id = reader.read("!L")[0]
1796 obj.tx_bytes = reader.read("!Q")[0]
1797 obj.tx_packets = reader.read("!Q")[0]
1798 obj.tx_errors = reader.read("!Q")[0]
1799 obj.duration_sec = reader.read("!L")[0]
1800 obj.duration_nsec = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001801 return obj
1802
1803 def __eq__(self, other):
1804 if type(self) != type(other): return False
1805 if self.port_no != other.port_no: return False
1806 if self.queue_id != other.queue_id: return False
1807 if self.tx_bytes != other.tx_bytes: return False
1808 if self.tx_packets != other.tx_packets: return False
1809 if self.tx_errors != other.tx_errors: return False
1810 if self.duration_sec != other.duration_sec: return False
1811 if self.duration_nsec != other.duration_nsec: return False
1812 return True
1813
1814 def __ne__(self, other):
1815 return not self.__eq__(other)
1816
1817 def show(self):
1818 import loxi.pp
1819 return loxi.pp.pp(self)
1820
1821 def pretty_print(self, q):
1822 q.text("queue_stats_entry {")
1823 with q.group():
1824 with q.indent(2):
1825 q.breakable()
1826 q.text("port_no = ");
1827 q.text(util.pretty_port(self.port_no))
1828 q.text(","); q.breakable()
1829 q.text("queue_id = ");
1830 q.text("%#x" % self.queue_id)
1831 q.text(","); q.breakable()
1832 q.text("tx_bytes = ");
1833 q.text("%#x" % self.tx_bytes)
1834 q.text(","); q.breakable()
1835 q.text("tx_packets = ");
1836 q.text("%#x" % self.tx_packets)
1837 q.text(","); q.breakable()
1838 q.text("tx_errors = ");
1839 q.text("%#x" % self.tx_errors)
1840 q.text(","); q.breakable()
1841 q.text("duration_sec = ");
1842 q.text("%#x" % self.duration_sec)
1843 q.text(","); q.breakable()
1844 q.text("duration_nsec = ");
1845 q.text("%#x" % self.duration_nsec)
1846 q.breakable()
1847 q.text('}')
1848
1849class table_feature_prop_apply_actions(object):
Dan Talaycof6202252013-07-02 01:00:29 -07001850 type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07001851
Dan Talaycof6202252013-07-02 01:00:29 -07001852 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001853 if action_ids != None:
1854 self.action_ids = action_ids
1855 else:
1856 self.action_ids = []
1857 return
1858
1859 def pack(self):
1860 packed = []
1861 packed.append(struct.pack("!H", self.type))
1862 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -07001863 packed.append(util.pack_list(self.action_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001864 length = sum([len(x) for x in packed])
1865 packed[1] = struct.pack("!H", length)
1866 return ''.join(packed)
1867
1868 @staticmethod
1869 def unpack(buf):
1870 obj = table_feature_prop_apply_actions()
1871 if type(buf) == loxi.generic_util.OFReader:
1872 reader = buf
1873 else:
1874 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07001875 _type = reader.read("!H")[0]
1876 assert(_type == 6)
1877 _length = reader.read("!H")[0]
1878 obj.action_ids = loxi.unimplemented('unpack list(of_action_id_t)')
Rich Lanec2ee4b82013-04-24 17:12:38 -07001879 return obj
1880
1881 def __eq__(self, other):
1882 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07001883 if self.action_ids != other.action_ids: 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_apply_actions {")
1895 with q.group():
1896 with q.indent(2):
1897 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001898 q.text("action_ids = ");
1899 q.pp(self.action_ids)
1900 q.breakable()
1901 q.text('}')
1902
1903class table_feature_prop_apply_actions_miss(object):
Dan Talaycof6202252013-07-02 01:00:29 -07001904 type = 7
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_miss()
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 == 7)
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_miss {")
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_setfield(object):
Dan Talaycof6202252013-07-02 01:00:29 -07001958 type = 14
Rich Lanec2ee4b82013-04-24 17:12:38 -07001959
Dan Talaycof6202252013-07-02 01:00:29 -07001960 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001961 if oxm_ids != None:
1962 self.oxm_ids = oxm_ids
1963 else:
1964 self.oxm_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.oxm_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_setfield()
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 == 14)
1985 _length = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001986 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
1987 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.oxm_ids != other.oxm_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_setfield {")
2003 with q.group():
2004 with q.indent(2):
2005 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002006 q.text("oxm_ids = ");
2007 q.pp(self.oxm_ids)
2008 q.breakable()
2009 q.text('}')
2010
2011class table_feature_prop_apply_setfield_miss(object):
Dan Talaycof6202252013-07-02 01:00:29 -07002012 type = 15
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_miss()
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 == 15)
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_miss {")
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_experimenter(object):
Dan Talaycof6202252013-07-02 01:00:29 -07002066 type = 65535
Rich Lanec2ee4b82013-04-24 17:12:38 -07002067
Dan Talaycof6202252013-07-02 01:00:29 -07002068 def __init__(self, experimenter=None, subtype=None, experimenter_data=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002069 if experimenter != None:
2070 self.experimenter = experimenter
2071 else:
2072 self.experimenter = 0
2073 if subtype != None:
2074 self.subtype = subtype
2075 else:
2076 self.subtype = 0
2077 if experimenter_data != None:
2078 self.experimenter_data = experimenter_data
2079 else:
Dan Talaycof6202252013-07-02 01:00:29 -07002080 self.experimenter_data = ''
Rich Lanec2ee4b82013-04-24 17:12:38 -07002081 return
2082
2083 def pack(self):
2084 packed = []
2085 packed.append(struct.pack("!H", self.type))
2086 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
2087 packed.append(struct.pack("!L", self.experimenter))
2088 packed.append(struct.pack("!L", self.subtype))
2089 packed.append(self.experimenter_data)
2090 length = sum([len(x) for x in packed])
2091 packed[1] = struct.pack("!H", length)
2092 return ''.join(packed)
2093
2094 @staticmethod
2095 def unpack(buf):
2096 obj = table_feature_prop_experimenter()
2097 if type(buf) == loxi.generic_util.OFReader:
2098 reader = buf
2099 else:
2100 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002101 _type = reader.read("!H")[0]
2102 assert(_type == 65535)
2103 _length = reader.read("!H")[0]
2104 obj.experimenter = reader.read("!L")[0]
2105 obj.subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002106 obj.experimenter_data = str(reader.read_all())
2107 return obj
2108
2109 def __eq__(self, other):
2110 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002111 if self.experimenter != other.experimenter: return False
2112 if self.subtype != other.subtype: return False
2113 if self.experimenter_data != other.experimenter_data: return False
2114 return True
2115
2116 def __ne__(self, other):
2117 return not self.__eq__(other)
2118
2119 def show(self):
2120 import loxi.pp
2121 return loxi.pp.pp(self)
2122
2123 def pretty_print(self, q):
2124 q.text("table_feature_prop_experimenter {")
2125 with q.group():
2126 with q.indent(2):
2127 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002128 q.text("experimenter = ");
2129 q.text("%#x" % self.experimenter)
2130 q.text(","); q.breakable()
2131 q.text("subtype = ");
2132 q.text("%#x" % self.subtype)
2133 q.text(","); q.breakable()
2134 q.text("experimenter_data = ");
2135 q.pp(self.experimenter_data)
2136 q.breakable()
2137 q.text('}')
2138
2139class table_feature_prop_instructions(object):
Dan Talaycof6202252013-07-02 01:00:29 -07002140 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07002141
Dan Talaycof6202252013-07-02 01:00:29 -07002142 def __init__(self, instruction_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002143 if instruction_ids != None:
2144 self.instruction_ids = instruction_ids
2145 else:
2146 self.instruction_ids = []
2147 return
2148
2149 def pack(self):
2150 packed = []
2151 packed.append(struct.pack("!H", self.type))
2152 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -07002153 packed.append(util.pack_list(self.instruction_ids))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002154 length = sum([len(x) for x in packed])
2155 packed[1] = struct.pack("!H", length)
2156 return ''.join(packed)
2157
2158 @staticmethod
2159 def unpack(buf):
2160 obj = table_feature_prop_instructions()
2161 if type(buf) == loxi.generic_util.OFReader:
2162 reader = buf
2163 else:
2164 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002165 _type = reader.read("!H")[0]
2166 assert(_type == 0)
2167 _length = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002168 obj.instruction_ids = instruction.unpack_list(reader)
2169 return obj
2170
2171 def __eq__(self, other):
2172 if type(self) != type(other): return False
Rich Lanec2ee4b82013-04-24 17:12:38 -07002173 if self.instruction_ids != other.instruction_ids: return False
2174 return True
2175
2176 def __ne__(self, other):
2177 return not self.__eq__(other)
2178
2179 def show(self):
2180 import loxi.pp
2181 return loxi.pp.pp(self)
2182
2183 def pretty_print(self, q):
2184 q.text("table_feature_prop_instructions {")
2185 with q.group():
2186 with q.indent(2):
2187 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002188 q.text("instruction_ids = ");
2189 q.pp(self.instruction_ids)
2190 q.breakable()
2191 q.text('}')
2192
2193class table_feature_prop_instructions_miss(object):
Dan Talaycof6202252013-07-02 01:00:29 -07002194 type = 1
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_miss()
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 == 1)
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_miss {")
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_match(object):
Dan Talaycof6202252013-07-02 01:00:29 -07002248 type = 8
Rich Lanec2ee4b82013-04-24 17:12:38 -07002249
Dan Talaycof6202252013-07-02 01:00:29 -07002250 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002251 if oxm_ids != None:
2252 self.oxm_ids = oxm_ids
2253 else:
2254 self.oxm_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.oxm_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_match()
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 == 8)
2275 _length = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002276 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
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.oxm_ids != other.oxm_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_match {")
2293 with q.group():
2294 with q.indent(2):
2295 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002296 q.text("oxm_ids = ");
2297 q.pp(self.oxm_ids)
2298 q.breakable()
2299 q.text('}')
2300
2301class table_feature_prop_next_tables(object):
Dan Talaycof6202252013-07-02 01:00:29 -07002302 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07002303
Dan Talaycof6202252013-07-02 01:00:29 -07002304 def __init__(self, next_table_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002305 if next_table_ids != None:
2306 self.next_table_ids = next_table_ids
2307 else:
2308 self.next_table_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.next_table_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_next_tables()
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 == 2)
2329 _length = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002330 obj.next_table_ids = loxi.generic_util.unpack_list(reader, common.uint8.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.next_table_ids != other.next_table_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_next_tables {")
2347 with q.group():
2348 with q.indent(2):
2349 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002350 q.text("next_table_ids = ");
2351 q.pp(self.next_table_ids)
2352 q.breakable()
2353 q.text('}')
2354
2355class table_feature_prop_next_tables_miss(object):
Dan Talaycof6202252013-07-02 01:00:29 -07002356 type = 3
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_miss()
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 == 3)
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_miss {")
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_wildcards(object):
Dan Talaycof6202252013-07-02 01:00:29 -07002410 type = 10
Rich Lanec2ee4b82013-04-24 17:12:38 -07002411
Dan Talaycof6202252013-07-02 01:00:29 -07002412 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002413 if oxm_ids != None:
2414 self.oxm_ids = oxm_ids
2415 else:
2416 self.oxm_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.oxm_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_wildcards()
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 == 10)
2437 _length = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002438 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.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.oxm_ids != other.oxm_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_wildcards {")
2455 with q.group():
2456 with q.indent(2):
2457 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002458 q.text("oxm_ids = ");
2459 q.pp(self.oxm_ids)
2460 q.breakable()
2461 q.text('}')
2462
2463class table_feature_prop_write_actions(object):
Dan Talaycof6202252013-07-02 01:00:29 -07002464 type = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -07002465
Dan Talaycof6202252013-07-02 01:00:29 -07002466 def __init__(self, action_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002467 if action_ids != None:
2468 self.action_ids = action_ids
2469 else:
2470 self.action_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.action_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_write_actions()
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 == 4)
2491 _length = reader.read("!H")[0]
2492 obj.action_ids = loxi.unimplemented('unpack list(of_action_id_t)')
Rich Lanec2ee4b82013-04-24 17:12:38 -07002493 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.action_ids != other.action_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_write_actions {")
2509 with q.group():
2510 with q.indent(2):
2511 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002512 q.text("action_ids = ");
2513 q.pp(self.action_ids)
2514 q.breakable()
2515 q.text('}')
2516
2517class table_feature_prop_write_actions_miss(object):
Dan Talaycof6202252013-07-02 01:00:29 -07002518 type = 5
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_miss()
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 == 5)
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_miss {")
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_setfield(object):
Dan Talaycof6202252013-07-02 01:00:29 -07002572 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -07002573
Dan Talaycof6202252013-07-02 01:00:29 -07002574 def __init__(self, oxm_ids=None):
Rich Lanec2ee4b82013-04-24 17:12:38 -07002575 if oxm_ids != None:
2576 self.oxm_ids = oxm_ids
2577 else:
2578 self.oxm_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.oxm_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_setfield()
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 == 12)
2599 _length = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002600 obj.oxm_ids = loxi.generic_util.unpack_list(reader, common.uint32.unpack)
2601 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.oxm_ids != other.oxm_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_setfield {")
2617 with q.group():
2618 with q.indent(2):
2619 q.breakable()
Rich Lanec2ee4b82013-04-24 17:12:38 -07002620 q.text("oxm_ids = ");
2621 q.pp(self.oxm_ids)
2622 q.breakable()
2623 q.text('}')
2624
2625class table_feature_prop_write_setfield_miss(object):
Dan Talaycof6202252013-07-02 01:00:29 -07002626 type = 13
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_miss()
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 == 13)
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_miss {")
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_features(object):
2680
2681 def __init__(self, table_id=None, name=None, metadata_match=None, metadata_write=None, config=None, max_entries=None, properties=None):
2682 if table_id != None:
2683 self.table_id = table_id
2684 else:
2685 self.table_id = 0
2686 if name != None:
2687 self.name = name
2688 else:
2689 self.name = ""
2690 if metadata_match != None:
2691 self.metadata_match = metadata_match
2692 else:
2693 self.metadata_match = 0
2694 if metadata_write != None:
2695 self.metadata_write = metadata_write
2696 else:
2697 self.metadata_write = 0
2698 if config != None:
2699 self.config = config
2700 else:
2701 self.config = 0
2702 if max_entries != None:
2703 self.max_entries = max_entries
2704 else:
2705 self.max_entries = 0
2706 if properties != None:
2707 self.properties = properties
2708 else:
2709 self.properties = []
2710 return
2711
2712 def pack(self):
2713 packed = []
2714 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
2715 packed.append(struct.pack("!B", self.table_id))
2716 packed.append('\x00' * 5)
2717 packed.append(struct.pack("!32s", self.name))
2718 packed.append(struct.pack("!Q", self.metadata_match))
2719 packed.append(struct.pack("!Q", self.metadata_write))
2720 packed.append(struct.pack("!L", self.config))
2721 packed.append(struct.pack("!L", self.max_entries))
Dan Talaycof6202252013-07-02 01:00:29 -07002722 packed.append(util.pack_list(self.properties))
Rich Lanec2ee4b82013-04-24 17:12:38 -07002723 length = sum([len(x) for x in packed])
2724 packed[0] = struct.pack("!H", length)
2725 return ''.join(packed)
2726
2727 @staticmethod
2728 def unpack(buf):
2729 obj = table_features()
2730 if type(buf) == loxi.generic_util.OFReader:
2731 reader = buf
2732 else:
2733 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002734 _length = reader.read("!H")[0]
2735 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002736 reader.skip(5)
2737 obj.name = reader.read("!32s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -07002738 obj.metadata_match = reader.read("!Q")[0]
2739 obj.metadata_write = reader.read("!Q")[0]
2740 obj.config = reader.read("!L")[0]
2741 obj.max_entries = reader.read("!L")[0]
2742 obj.properties = loxi.unimplemented('unpack list(of_table_feature_prop_t)')
Rich Lanec2ee4b82013-04-24 17:12:38 -07002743 return obj
2744
2745 def __eq__(self, other):
2746 if type(self) != type(other): return False
2747 if self.table_id != other.table_id: return False
2748 if self.name != other.name: return False
2749 if self.metadata_match != other.metadata_match: return False
2750 if self.metadata_write != other.metadata_write: return False
2751 if self.config != other.config: return False
2752 if self.max_entries != other.max_entries: return False
2753 if self.properties != other.properties: return False
2754 return True
2755
2756 def __ne__(self, other):
2757 return not self.__eq__(other)
2758
2759 def show(self):
2760 import loxi.pp
2761 return loxi.pp.pp(self)
2762
2763 def pretty_print(self, q):
2764 q.text("table_features {")
2765 with q.group():
2766 with q.indent(2):
2767 q.breakable()
2768 q.text("table_id = ");
2769 q.text("%#x" % self.table_id)
2770 q.text(","); q.breakable()
2771 q.text("name = ");
2772 q.pp(self.name)
2773 q.text(","); q.breakable()
2774 q.text("metadata_match = ");
2775 q.text("%#x" % self.metadata_match)
2776 q.text(","); q.breakable()
2777 q.text("metadata_write = ");
2778 q.text("%#x" % self.metadata_write)
2779 q.text(","); q.breakable()
2780 q.text("config = ");
2781 q.text("%#x" % self.config)
2782 q.text(","); q.breakable()
2783 q.text("max_entries = ");
2784 q.text("%#x" % self.max_entries)
2785 q.text(","); q.breakable()
2786 q.text("properties = ");
2787 q.pp(self.properties)
2788 q.breakable()
2789 q.text('}')
2790
2791class table_stats_entry(object):
2792
2793 def __init__(self, table_id=None, active_count=None, lookup_count=None, matched_count=None):
2794 if table_id != None:
2795 self.table_id = table_id
2796 else:
2797 self.table_id = 0
2798 if active_count != None:
2799 self.active_count = active_count
2800 else:
2801 self.active_count = 0
2802 if lookup_count != None:
2803 self.lookup_count = lookup_count
2804 else:
2805 self.lookup_count = 0
2806 if matched_count != None:
2807 self.matched_count = matched_count
2808 else:
2809 self.matched_count = 0
2810 return
2811
2812 def pack(self):
2813 packed = []
2814 packed.append(struct.pack("!B", self.table_id))
2815 packed.append('\x00' * 3)
2816 packed.append(struct.pack("!L", self.active_count))
2817 packed.append(struct.pack("!Q", self.lookup_count))
2818 packed.append(struct.pack("!Q", self.matched_count))
2819 return ''.join(packed)
2820
2821 @staticmethod
2822 def unpack(buf):
2823 obj = table_stats_entry()
2824 if type(buf) == loxi.generic_util.OFReader:
2825 reader = buf
2826 else:
2827 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002828 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002829 reader.skip(3)
Dan Talaycof6202252013-07-02 01:00:29 -07002830 obj.active_count = reader.read("!L")[0]
2831 obj.lookup_count = reader.read("!Q")[0]
2832 obj.matched_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002833 return obj
2834
2835 def __eq__(self, other):
2836 if type(self) != type(other): return False
2837 if self.table_id != other.table_id: return False
2838 if self.active_count != other.active_count: return False
2839 if self.lookup_count != other.lookup_count: return False
2840 if self.matched_count != other.matched_count: return False
2841 return True
2842
2843 def __ne__(self, other):
2844 return not self.__eq__(other)
2845
2846 def show(self):
2847 import loxi.pp
2848 return loxi.pp.pp(self)
2849
2850 def pretty_print(self, q):
2851 q.text("table_stats_entry {")
2852 with q.group():
2853 with q.indent(2):
2854 q.breakable()
2855 q.text("table_id = ");
2856 q.text("%#x" % self.table_id)
2857 q.text(","); q.breakable()
2858 q.text("active_count = ");
2859 q.text("%#x" % self.active_count)
2860 q.text(","); q.breakable()
2861 q.text("lookup_count = ");
2862 q.text("%#x" % self.lookup_count)
2863 q.text(","); q.breakable()
2864 q.text("matched_count = ");
2865 q.text("%#x" % self.matched_count)
2866 q.breakable()
2867 q.text('}')
2868
2869class uint32(object):
2870
2871 def __init__(self, value=None):
2872 if value != None:
2873 self.value = value
2874 else:
2875 self.value = 0
2876 return
2877
2878 def pack(self):
2879 packed = []
2880 packed.append(struct.pack("!L", self.value))
2881 return ''.join(packed)
2882
2883 @staticmethod
2884 def unpack(buf):
2885 obj = uint32()
2886 if type(buf) == loxi.generic_util.OFReader:
2887 reader = buf
2888 else:
2889 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002890 obj.value = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002891 return obj
2892
2893 def __eq__(self, other):
2894 if type(self) != type(other): return False
2895 if self.value != other.value: return False
2896 return True
2897
2898 def __ne__(self, other):
2899 return not self.__eq__(other)
2900
2901 def show(self):
2902 import loxi.pp
2903 return loxi.pp.pp(self)
2904
2905 def pretty_print(self, q):
2906 q.text("uint32 {")
2907 with q.group():
2908 with q.indent(2):
2909 q.breakable()
2910 q.text("value = ");
2911 q.text("%#x" % self.value)
2912 q.breakable()
2913 q.text('}')
2914
2915class uint8(object):
2916
2917 def __init__(self, value=None):
2918 if value != None:
2919 self.value = value
2920 else:
2921 self.value = 0
2922 return
2923
2924 def pack(self):
2925 packed = []
2926 packed.append(struct.pack("!B", self.value))
2927 return ''.join(packed)
2928
2929 @staticmethod
2930 def unpack(buf):
2931 obj = uint8()
2932 if type(buf) == loxi.generic_util.OFReader:
2933 reader = buf
2934 else:
2935 reader = loxi.generic_util.OFReader(buf)
Dan Talaycof6202252013-07-02 01:00:29 -07002936 obj.value = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07002937 return obj
2938
2939 def __eq__(self, other):
2940 if type(self) != type(other): return False
2941 if self.value != other.value: return False
2942 return True
2943
2944 def __ne__(self, other):
2945 return not self.__eq__(other)
2946
2947 def show(self):
2948 import loxi.pp
2949 return loxi.pp.pp(self)
2950
2951 def pretty_print(self, q):
2952 q.text("uint8 {")
2953 with q.group():
2954 with q.indent(2):
2955 q.breakable()
2956 q.text("value = ");
2957 q.text("%#x" % self.value)
2958 q.breakable()
2959 q.text('}')
2960
2961
2962match = match_v3