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