blob: df8c796d1b200b8b65e04360b55de7acc0a10dce [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
11import const
12import port_desc_prop
13import meter_band
14import table_mod_prop
15import instruction
16import queue_desc_prop
17import oxm
18import bundle_prop
19import common
20import instruction_id
21import action
22import role_prop
23import message
24import queue_stats_prop
25import port_stats_prop
26import port_mod_prop
27import async_config_prop
28import action_id
29import util
30import loxi.generic_util
31
32class port_mod_prop(loxi.OFObject):
33 subtypes = {}
34
35
36 def __init__(self, type=None):
37 if type != None:
38 self.type = type
39 else:
40 self.type = 0
41 return
42
43 def pack(self):
44 packed = []
45 packed.append(struct.pack("!H", self.type))
46 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
47 length = sum([len(x) for x in packed])
48 packed[1] = struct.pack("!H", length)
49 return ''.join(packed)
50
51 @staticmethod
52 def unpack(reader):
53 subtype, = reader.peek('!H', 0)
54 subclass = port_mod_prop.subtypes.get(subtype)
55 if subclass:
56 return subclass.unpack(reader)
57
58 obj = port_mod_prop()
59 obj.type = reader.read("!H")[0]
60 _length = reader.read("!H")[0]
61 orig_reader = reader
62 reader = orig_reader.slice(_length - (2 + 2))
63 return obj
64
65 def __eq__(self, other):
66 if type(self) != type(other): return False
67 if self.type != other.type: return False
68 return True
69
70 def pretty_print(self, q):
71 q.text("port_mod_prop {")
72 with q.group():
73 with q.indent(2):
74 q.breakable()
75 q.breakable()
76 q.text('}')
77
78
79class ethernet(port_mod_prop):
80 type = 0
81
82 def __init__(self, advertise=None):
83 if advertise != None:
84 self.advertise = advertise
85 else:
86 self.advertise = 0
87 return
88
89 def pack(self):
90 packed = []
91 packed.append(struct.pack("!H", self.type))
92 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
93 packed.append(struct.pack("!L", self.advertise))
94 length = sum([len(x) for x in packed])
95 packed[1] = struct.pack("!H", length)
96 return ''.join(packed)
97
98 @staticmethod
99 def unpack(reader):
100 obj = ethernet()
101 _type = reader.read("!H")[0]
102 assert(_type == 0)
103 _length = reader.read("!H")[0]
104 orig_reader = reader
105 reader = orig_reader.slice(_length - (2 + 2))
106 obj.advertise = reader.read("!L")[0]
107 return obj
108
109 def __eq__(self, other):
110 if type(self) != type(other): return False
111 if self.advertise != other.advertise: return False
112 return True
113
114 def pretty_print(self, q):
115 q.text("ethernet {")
116 with q.group():
117 with q.indent(2):
118 q.breakable()
119 q.text("advertise = ");
120 q.text("%#x" % self.advertise)
121 q.breakable()
122 q.text('}')
123
124port_mod_prop.subtypes[0] = ethernet
125
126class experimenter(port_mod_prop):
127 subtypes = {}
128
129 type = 65535
130
131 def __init__(self, experimenter=None, exp_type=None):
132 if experimenter != None:
133 self.experimenter = experimenter
134 else:
135 self.experimenter = 0
136 if exp_type != None:
137 self.exp_type = exp_type
138 else:
139 self.exp_type = 0
140 return
141
142 def pack(self):
143 packed = []
144 packed.append(struct.pack("!H", self.type))
145 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
146 packed.append(struct.pack("!L", self.experimenter))
147 packed.append(struct.pack("!L", self.exp_type))
148 length = sum([len(x) for x in packed])
149 packed[1] = struct.pack("!H", length)
150 return ''.join(packed)
151
152 @staticmethod
153 def unpack(reader):
154 subtype, = reader.peek('!L', 4)
155 subclass = experimenter.subtypes.get(subtype)
156 if subclass:
157 return subclass.unpack(reader)
158
159 obj = experimenter()
160 _type = reader.read("!H")[0]
161 assert(_type == 65535)
162 _length = reader.read("!H")[0]
163 orig_reader = reader
164 reader = orig_reader.slice(_length - (2 + 2))
165 obj.experimenter = reader.read("!L")[0]
166 obj.exp_type = reader.read("!L")[0]
167 return obj
168
169 def __eq__(self, other):
170 if type(self) != type(other): return False
171 if self.experimenter != other.experimenter: return False
172 if self.exp_type != other.exp_type: return False
173 return True
174
175 def pretty_print(self, q):
176 q.text("experimenter {")
177 with q.group():
178 with q.indent(2):
179 q.breakable()
180 q.text("exp_type = ");
181 q.text("%#x" % self.exp_type)
182 q.breakable()
183 q.text('}')
184
185port_mod_prop.subtypes[65535] = experimenter
186
187class optical(port_mod_prop):
188 type = 1
189
190 def __init__(self, configure=None, freq_ldma=None, fl_offset=None, grid_span=None, tx_pwr=None):
191 if configure != None:
192 self.configure = configure
193 else:
194 self.configure = 0
195 if freq_ldma != None:
196 self.freq_ldma = freq_ldma
197 else:
198 self.freq_ldma = 0
199 if fl_offset != None:
200 self.fl_offset = fl_offset
201 else:
202 self.fl_offset = 0
203 if grid_span != None:
204 self.grid_span = grid_span
205 else:
206 self.grid_span = 0
207 if tx_pwr != None:
208 self.tx_pwr = tx_pwr
209 else:
210 self.tx_pwr = 0
211 return
212
213 def pack(self):
214 packed = []
215 packed.append(struct.pack("!H", self.type))
216 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
217 packed.append(struct.pack("!L", self.configure))
218 packed.append(struct.pack("!L", self.freq_ldma))
219 packed.append(struct.pack("!L", self.fl_offset))
220 packed.append(struct.pack("!L", self.grid_span))
221 packed.append(struct.pack("!L", self.tx_pwr))
222 length = sum([len(x) for x in packed])
223 packed[1] = struct.pack("!H", length)
224 return ''.join(packed)
225
226 @staticmethod
227 def unpack(reader):
228 obj = optical()
229 _type = reader.read("!H")[0]
230 assert(_type == 1)
231 _length = reader.read("!H")[0]
232 orig_reader = reader
233 reader = orig_reader.slice(_length - (2 + 2))
234 obj.configure = reader.read("!L")[0]
235 obj.freq_ldma = reader.read("!L")[0]
236 obj.fl_offset = reader.read("!L")[0]
237 obj.grid_span = reader.read("!L")[0]
238 obj.tx_pwr = reader.read("!L")[0]
239 return obj
240
241 def __eq__(self, other):
242 if type(self) != type(other): return False
243 if self.configure != other.configure: return False
244 if self.freq_ldma != other.freq_ldma: return False
245 if self.fl_offset != other.fl_offset: return False
246 if self.grid_span != other.grid_span: return False
247 if self.tx_pwr != other.tx_pwr: return False
248 return True
249
250 def pretty_print(self, q):
251 q.text("optical {")
252 with q.group():
253 with q.indent(2):
254 q.breakable()
255 q.text("configure = ");
256 q.text("%#x" % self.configure)
257 q.text(","); q.breakable()
258 q.text("freq_ldma = ");
259 q.text("%#x" % self.freq_ldma)
260 q.text(","); q.breakable()
261 q.text("fl_offset = ");
262 q.text("%#x" % self.fl_offset)
263 q.text(","); q.breakable()
264 q.text("grid_span = ");
265 q.text("%#x" % self.grid_span)
266 q.text(","); q.breakable()
267 q.text("tx_pwr = ");
268 q.text("%#x" % self.tx_pwr)
269 q.breakable()
270 q.text('}')
271
272port_mod_prop.subtypes[1] = optical
273
274