blob: f40952470e9926706db49542eb850d651f043552 [file] [log] [blame]
Rich Lane2e079da2014-10-29 15:30:24 -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.
4# See the file LICENSE.pyloxi which should have been included in the source distribution
5
6# Automatically generated by LOXI from template module.py
7# Do not modify
8
9import struct
10import loxi
Rich Lane2e079da2014-10-29 15:30:24 -070011import util
12import loxi.generic_util
13
Rich Lanee2567702015-01-26 15:04:35 -080014import sys
15ofp = sys.modules['loxi.of14']
16
Rich Lane2e079da2014-10-29 15:30:24 -070017class bundle_prop(loxi.OFObject):
18 subtypes = {}
19
20
21 def __init__(self, type=None):
22 if type != None:
23 self.type = type
24 else:
25 self.type = 0
26 return
27
28 def pack(self):
29 packed = []
30 packed.append(struct.pack("!H", self.type))
31 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
32 length = sum([len(x) for x in packed])
33 packed[1] = struct.pack("!H", length)
34 return ''.join(packed)
35
36 @staticmethod
37 def unpack(reader):
38 subtype, = reader.peek('!H', 0)
39 subclass = bundle_prop.subtypes.get(subtype)
40 if subclass:
41 return subclass.unpack(reader)
42
43 obj = bundle_prop()
44 obj.type = reader.read("!H")[0]
45 _length = reader.read("!H")[0]
46 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -080047 reader = orig_reader.slice(_length, 4)
Rich Lane2e079da2014-10-29 15:30:24 -070048 return obj
49
50 def __eq__(self, other):
51 if type(self) != type(other): return False
52 if self.type != other.type: return False
53 return True
54
55 def pretty_print(self, q):
56 q.text("bundle_prop {")
57 with q.group():
58 with q.indent(2):
59 q.breakable()
60 q.breakable()
61 q.text('}')
62
63
64class experimenter(bundle_prop):
65 subtypes = {}
66
67 type = 65535
68
69 def __init__(self, experimenter=None, exp_type=None):
70 if experimenter != None:
71 self.experimenter = experimenter
72 else:
73 self.experimenter = 0
74 if exp_type != None:
75 self.exp_type = exp_type
76 else:
77 self.exp_type = 0
78 return
79
80 def pack(self):
81 packed = []
82 packed.append(struct.pack("!H", self.type))
83 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
84 packed.append(struct.pack("!L", self.experimenter))
85 packed.append(struct.pack("!L", self.exp_type))
86 length = sum([len(x) for x in packed])
87 packed[1] = struct.pack("!H", length)
88 return ''.join(packed)
89
90 @staticmethod
91 def unpack(reader):
92 subtype, = reader.peek('!L', 4)
93 subclass = experimenter.subtypes.get(subtype)
94 if subclass:
95 return subclass.unpack(reader)
96
97 obj = experimenter()
98 _type = reader.read("!H")[0]
99 assert(_type == 65535)
100 _length = reader.read("!H")[0]
101 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800102 reader = orig_reader.slice(_length, 4)
Rich Lane2e079da2014-10-29 15:30:24 -0700103 obj.experimenter = reader.read("!L")[0]
104 obj.exp_type = reader.read("!L")[0]
105 return obj
106
107 def __eq__(self, other):
108 if type(self) != type(other): return False
109 if self.experimenter != other.experimenter: return False
110 if self.exp_type != other.exp_type: return False
111 return True
112
113 def pretty_print(self, q):
114 q.text("experimenter {")
115 with q.group():
116 with q.indent(2):
117 q.breakable()
118 q.text("exp_type = ");
119 q.text("%#x" % self.exp_type)
120 q.breakable()
121 q.text('}')
122
123bundle_prop.subtypes[65535] = experimenter
124
125