blob: c4047329058397e9db80164f450124743551ff78 [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_desc_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_desc_prop.subtypes.get(subtype)
55 if subclass:
56 return subclass.unpack(reader)
57
58 obj = port_desc_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_desc_prop {")
72 with q.group():
73 with q.indent(2):
74 q.breakable()
75 q.breakable()
76 q.text('}')
77
78
79class ethernet(port_desc_prop):
80 type = 0
81
82 def __init__(self, curr=None, advertised=None, supported=None, peer=None, curr_speed=None, max_speed=None):
83 if curr != None:
84 self.curr = curr
85 else:
86 self.curr = 0
87 if advertised != None:
88 self.advertised = advertised
89 else:
90 self.advertised = 0
91 if supported != None:
92 self.supported = supported
93 else:
94 self.supported = 0
95 if peer != None:
96 self.peer = peer
97 else:
98 self.peer = 0
99 if curr_speed != None:
100 self.curr_speed = curr_speed
101 else:
102 self.curr_speed = 0
103 if max_speed != None:
104 self.max_speed = max_speed
105 else:
106 self.max_speed = 0
107 return
108
109 def pack(self):
110 packed = []
111 packed.append(struct.pack("!H", self.type))
112 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
113 packed.append('\x00' * 4)
114 packed.append(struct.pack("!L", self.curr))
115 packed.append(struct.pack("!L", self.advertised))
116 packed.append(struct.pack("!L", self.supported))
117 packed.append(struct.pack("!L", self.peer))
118 packed.append(struct.pack("!L", self.curr_speed))
119 packed.append(struct.pack("!L", self.max_speed))
120 length = sum([len(x) for x in packed])
121 packed[1] = struct.pack("!H", length)
122 return ''.join(packed)
123
124 @staticmethod
125 def unpack(reader):
126 obj = ethernet()
127 _type = reader.read("!H")[0]
128 assert(_type == 0)
129 _length = reader.read("!H")[0]
130 orig_reader = reader
131 reader = orig_reader.slice(_length - (2 + 2))
132 reader.skip(4)
133 obj.curr = reader.read("!L")[0]
134 obj.advertised = reader.read("!L")[0]
135 obj.supported = reader.read("!L")[0]
136 obj.peer = reader.read("!L")[0]
137 obj.curr_speed = reader.read("!L")[0]
138 obj.max_speed = reader.read("!L")[0]
139 return obj
140
141 def __eq__(self, other):
142 if type(self) != type(other): return False
143 if self.curr != other.curr: return False
144 if self.advertised != other.advertised: return False
145 if self.supported != other.supported: return False
146 if self.peer != other.peer: return False
147 if self.curr_speed != other.curr_speed: return False
148 if self.max_speed != other.max_speed: return False
149 return True
150
151 def pretty_print(self, q):
152 q.text("ethernet {")
153 with q.group():
154 with q.indent(2):
155 q.breakable()
156 q.text("curr = ");
157 q.text("%#x" % self.curr)
158 q.text(","); q.breakable()
159 q.text("advertised = ");
160 q.text("%#x" % self.advertised)
161 q.text(","); q.breakable()
162 q.text("supported = ");
163 q.text("%#x" % self.supported)
164 q.text(","); q.breakable()
165 q.text("peer = ");
166 q.text("%#x" % self.peer)
167 q.text(","); q.breakable()
168 q.text("curr_speed = ");
169 q.text("%#x" % self.curr_speed)
170 q.text(","); q.breakable()
171 q.text("max_speed = ");
172 q.text("%#x" % self.max_speed)
173 q.breakable()
174 q.text('}')
175
176port_desc_prop.subtypes[0] = ethernet
177
178class experimenter(port_desc_prop):
179 subtypes = {}
180
181 type = 65535
182
183 def __init__(self, experimenter=None, exp_type=None):
184 if experimenter != None:
185 self.experimenter = experimenter
186 else:
187 self.experimenter = 0
188 if exp_type != None:
189 self.exp_type = exp_type
190 else:
191 self.exp_type = 0
192 return
193
194 def pack(self):
195 packed = []
196 packed.append(struct.pack("!H", self.type))
197 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
198 packed.append(struct.pack("!L", self.experimenter))
199 packed.append(struct.pack("!L", self.exp_type))
200 length = sum([len(x) for x in packed])
201 packed[1] = struct.pack("!H", length)
202 return ''.join(packed)
203
204 @staticmethod
205 def unpack(reader):
206 subtype, = reader.peek('!L', 4)
207 subclass = experimenter.subtypes.get(subtype)
208 if subclass:
209 return subclass.unpack(reader)
210
211 obj = experimenter()
212 _type = reader.read("!H")[0]
213 assert(_type == 65535)
214 _length = reader.read("!H")[0]
215 orig_reader = reader
216 reader = orig_reader.slice(_length - (2 + 2))
217 obj.experimenter = reader.read("!L")[0]
218 obj.exp_type = reader.read("!L")[0]
219 return obj
220
221 def __eq__(self, other):
222 if type(self) != type(other): return False
223 if self.experimenter != other.experimenter: return False
224 if self.exp_type != other.exp_type: return False
225 return True
226
227 def pretty_print(self, q):
228 q.text("experimenter {")
229 with q.group():
230 with q.indent(2):
231 q.breakable()
232 q.text("exp_type = ");
233 q.text("%#x" % self.exp_type)
234 q.breakable()
235 q.text('}')
236
237port_desc_prop.subtypes[65535] = experimenter
238
239class optical(port_desc_prop):
240 type = 1
241
242 def __init__(self, supported=None, tx_min_freq_lmda=None, tx_max_freq_lmda=None, tx_grid_freq_lmda=None, rx_min_freq_lmda=None, rx_max_freq_lmda=None, rx_grid_freq_lmda=None, tx_pwr_min=None, tx_pwr_max=None):
243 if supported != None:
244 self.supported = supported
245 else:
246 self.supported = 0
247 if tx_min_freq_lmda != None:
248 self.tx_min_freq_lmda = tx_min_freq_lmda
249 else:
250 self.tx_min_freq_lmda = 0
251 if tx_max_freq_lmda != None:
252 self.tx_max_freq_lmda = tx_max_freq_lmda
253 else:
254 self.tx_max_freq_lmda = 0
255 if tx_grid_freq_lmda != None:
256 self.tx_grid_freq_lmda = tx_grid_freq_lmda
257 else:
258 self.tx_grid_freq_lmda = 0
259 if rx_min_freq_lmda != None:
260 self.rx_min_freq_lmda = rx_min_freq_lmda
261 else:
262 self.rx_min_freq_lmda = 0
263 if rx_max_freq_lmda != None:
264 self.rx_max_freq_lmda = rx_max_freq_lmda
265 else:
266 self.rx_max_freq_lmda = 0
267 if rx_grid_freq_lmda != None:
268 self.rx_grid_freq_lmda = rx_grid_freq_lmda
269 else:
270 self.rx_grid_freq_lmda = 0
271 if tx_pwr_min != None:
272 self.tx_pwr_min = tx_pwr_min
273 else:
274 self.tx_pwr_min = 0
275 if tx_pwr_max != None:
276 self.tx_pwr_max = tx_pwr_max
277 else:
278 self.tx_pwr_max = 0
279 return
280
281 def pack(self):
282 packed = []
283 packed.append(struct.pack("!H", self.type))
284 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
285 packed.append('\x00' * 4)
286 packed.append(struct.pack("!L", self.supported))
287 packed.append(struct.pack("!L", self.tx_min_freq_lmda))
288 packed.append(struct.pack("!L", self.tx_max_freq_lmda))
289 packed.append(struct.pack("!L", self.tx_grid_freq_lmda))
290 packed.append(struct.pack("!L", self.rx_min_freq_lmda))
291 packed.append(struct.pack("!L", self.rx_max_freq_lmda))
292 packed.append(struct.pack("!L", self.rx_grid_freq_lmda))
293 packed.append(struct.pack("!L", self.tx_pwr_min))
294 packed.append(struct.pack("!L", self.tx_pwr_max))
295 length = sum([len(x) for x in packed])
296 packed[1] = struct.pack("!H", length)
297 return ''.join(packed)
298
299 @staticmethod
300 def unpack(reader):
301 obj = optical()
302 _type = reader.read("!H")[0]
303 assert(_type == 1)
304 _length = reader.read("!H")[0]
305 orig_reader = reader
306 reader = orig_reader.slice(_length - (2 + 2))
307 reader.skip(4)
308 obj.supported = reader.read("!L")[0]
309 obj.tx_min_freq_lmda = reader.read("!L")[0]
310 obj.tx_max_freq_lmda = reader.read("!L")[0]
311 obj.tx_grid_freq_lmda = reader.read("!L")[0]
312 obj.rx_min_freq_lmda = reader.read("!L")[0]
313 obj.rx_max_freq_lmda = reader.read("!L")[0]
314 obj.rx_grid_freq_lmda = reader.read("!L")[0]
315 obj.tx_pwr_min = reader.read("!L")[0]
316 obj.tx_pwr_max = reader.read("!L")[0]
317 return obj
318
319 def __eq__(self, other):
320 if type(self) != type(other): return False
321 if self.supported != other.supported: return False
322 if self.tx_min_freq_lmda != other.tx_min_freq_lmda: return False
323 if self.tx_max_freq_lmda != other.tx_max_freq_lmda: return False
324 if self.tx_grid_freq_lmda != other.tx_grid_freq_lmda: return False
325 if self.rx_min_freq_lmda != other.rx_min_freq_lmda: return False
326 if self.rx_max_freq_lmda != other.rx_max_freq_lmda: return False
327 if self.rx_grid_freq_lmda != other.rx_grid_freq_lmda: return False
328 if self.tx_pwr_min != other.tx_pwr_min: return False
329 if self.tx_pwr_max != other.tx_pwr_max: return False
330 return True
331
332 def pretty_print(self, q):
333 q.text("optical {")
334 with q.group():
335 with q.indent(2):
336 q.breakable()
337 q.text("supported = ");
338 q.text("%#x" % self.supported)
339 q.text(","); q.breakable()
340 q.text("tx_min_freq_lmda = ");
341 q.text("%#x" % self.tx_min_freq_lmda)
342 q.text(","); q.breakable()
343 q.text("tx_max_freq_lmda = ");
344 q.text("%#x" % self.tx_max_freq_lmda)
345 q.text(","); q.breakable()
346 q.text("tx_grid_freq_lmda = ");
347 q.text("%#x" % self.tx_grid_freq_lmda)
348 q.text(","); q.breakable()
349 q.text("rx_min_freq_lmda = ");
350 q.text("%#x" % self.rx_min_freq_lmda)
351 q.text(","); q.breakable()
352 q.text("rx_max_freq_lmda = ");
353 q.text("%#x" % self.rx_max_freq_lmda)
354 q.text(","); q.breakable()
355 q.text("rx_grid_freq_lmda = ");
356 q.text("%#x" % self.rx_grid_freq_lmda)
357 q.text(","); q.breakable()
358 q.text("tx_pwr_min = ");
359 q.text("%#x" % self.tx_pwr_min)
360 q.text(","); q.breakable()
361 q.text("tx_pwr_max = ");
362 q.text("%#x" % self.tx_pwr_max)
363 q.breakable()
364 q.text('}')
365
366port_desc_prop.subtypes[1] = optical
367
368