blob: 217e004c80283382c8d8dc05838af6a18fc15961 [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
Rich Lane4e748362015-03-03 15:14:34 -080064class experimenter(port_desc_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
102 reader = orig_reader.slice(_length, 4)
103 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
123port_desc_prop.subtypes[65535] = experimenter
124
125class bsn(experimenter):
126 subtypes = {}
127
128 type = 65535
129 experimenter = 6035143
130
131 def __init__(self, exp_type=None):
132 if exp_type != None:
133 self.exp_type = exp_type
134 else:
135 self.exp_type = 0
136 return
137
138 def pack(self):
139 packed = []
140 packed.append(struct.pack("!H", self.type))
141 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
142 packed.append(struct.pack("!L", self.experimenter))
143 packed.append(struct.pack("!L", self.exp_type))
144 length = sum([len(x) for x in packed])
145 packed[1] = struct.pack("!H", length)
146 return ''.join(packed)
147
148 @staticmethod
149 def unpack(reader):
150 subtype, = reader.peek('!L', 8)
151 subclass = bsn.subtypes.get(subtype)
152 if subclass:
153 return subclass.unpack(reader)
154
155 obj = bsn()
156 _type = reader.read("!H")[0]
157 assert(_type == 65535)
158 _length = reader.read("!H")[0]
159 orig_reader = reader
160 reader = orig_reader.slice(_length, 4)
161 _experimenter = reader.read("!L")[0]
162 assert(_experimenter == 6035143)
163 obj.exp_type = reader.read("!L")[0]
164 return obj
165
166 def __eq__(self, other):
167 if type(self) != type(other): return False
168 if self.exp_type != other.exp_type: return False
169 return True
170
171 def pretty_print(self, q):
172 q.text("bsn {")
173 with q.group():
174 with q.indent(2):
175 q.breakable()
176 q.breakable()
177 q.text('}')
178
179experimenter.subtypes[6035143] = bsn
180
181class bsn_uplink(bsn):
182 type = 65535
183 experimenter = 6035143
184 exp_type = 0
185
186 def __init__(self):
187 return
188
189 def pack(self):
190 packed = []
191 packed.append(struct.pack("!H", self.type))
192 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
193 packed.append(struct.pack("!L", self.experimenter))
194 packed.append(struct.pack("!L", self.exp_type))
195 length = sum([len(x) for x in packed])
196 packed[1] = struct.pack("!H", length)
197 return ''.join(packed)
198
199 @staticmethod
200 def unpack(reader):
201 obj = bsn_uplink()
202 _type = reader.read("!H")[0]
203 assert(_type == 65535)
204 _length = reader.read("!H")[0]
205 orig_reader = reader
206 reader = orig_reader.slice(_length, 4)
207 _experimenter = reader.read("!L")[0]
208 assert(_experimenter == 6035143)
209 _exp_type = reader.read("!L")[0]
210 assert(_exp_type == 0)
211 return obj
212
213 def __eq__(self, other):
214 if type(self) != type(other): return False
215 return True
216
217 def pretty_print(self, q):
218 q.text("bsn_uplink {")
219 with q.group():
220 with q.indent(2):
221 q.breakable()
222 q.breakable()
223 q.text('}')
224
225bsn.subtypes[0] = bsn_uplink
226
Rich Lane2e079da2014-10-29 15:30:24 -0700227class ethernet(port_desc_prop):
228 type = 0
229
230 def __init__(self, curr=None, advertised=None, supported=None, peer=None, curr_speed=None, max_speed=None):
231 if curr != None:
232 self.curr = curr
233 else:
234 self.curr = 0
235 if advertised != None:
236 self.advertised = advertised
237 else:
238 self.advertised = 0
239 if supported != None:
240 self.supported = supported
241 else:
242 self.supported = 0
243 if peer != None:
244 self.peer = peer
245 else:
246 self.peer = 0
247 if curr_speed != None:
248 self.curr_speed = curr_speed
249 else:
250 self.curr_speed = 0
251 if max_speed != None:
252 self.max_speed = max_speed
253 else:
254 self.max_speed = 0
255 return
256
257 def pack(self):
258 packed = []
259 packed.append(struct.pack("!H", self.type))
260 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
261 packed.append('\x00' * 4)
262 packed.append(struct.pack("!L", self.curr))
263 packed.append(struct.pack("!L", self.advertised))
264 packed.append(struct.pack("!L", self.supported))
265 packed.append(struct.pack("!L", self.peer))
266 packed.append(struct.pack("!L", self.curr_speed))
267 packed.append(struct.pack("!L", self.max_speed))
268 length = sum([len(x) for x in packed])
269 packed[1] = struct.pack("!H", length)
270 return ''.join(packed)
271
272 @staticmethod
273 def unpack(reader):
274 obj = ethernet()
275 _type = reader.read("!H")[0]
276 assert(_type == 0)
277 _length = reader.read("!H")[0]
278 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800279 reader = orig_reader.slice(_length, 4)
Rich Lane2e079da2014-10-29 15:30:24 -0700280 reader.skip(4)
281 obj.curr = reader.read("!L")[0]
282 obj.advertised = reader.read("!L")[0]
283 obj.supported = reader.read("!L")[0]
284 obj.peer = reader.read("!L")[0]
285 obj.curr_speed = reader.read("!L")[0]
286 obj.max_speed = reader.read("!L")[0]
287 return obj
288
289 def __eq__(self, other):
290 if type(self) != type(other): return False
291 if self.curr != other.curr: return False
292 if self.advertised != other.advertised: return False
293 if self.supported != other.supported: return False
294 if self.peer != other.peer: return False
295 if self.curr_speed != other.curr_speed: return False
296 if self.max_speed != other.max_speed: return False
297 return True
298
299 def pretty_print(self, q):
300 q.text("ethernet {")
301 with q.group():
302 with q.indent(2):
303 q.breakable()
304 q.text("curr = ");
305 q.text("%#x" % self.curr)
306 q.text(","); q.breakable()
307 q.text("advertised = ");
308 q.text("%#x" % self.advertised)
309 q.text(","); q.breakable()
310 q.text("supported = ");
311 q.text("%#x" % self.supported)
312 q.text(","); q.breakable()
313 q.text("peer = ");
314 q.text("%#x" % self.peer)
315 q.text(","); q.breakable()
316 q.text("curr_speed = ");
317 q.text("%#x" % self.curr_speed)
318 q.text(","); q.breakable()
319 q.text("max_speed = ");
320 q.text("%#x" % self.max_speed)
321 q.breakable()
322 q.text('}')
323
324port_desc_prop.subtypes[0] = ethernet
325
Rich Lane2e079da2014-10-29 15:30:24 -0700326class optical(port_desc_prop):
327 type = 1
328
329 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):
330 if supported != None:
331 self.supported = supported
332 else:
333 self.supported = 0
334 if tx_min_freq_lmda != None:
335 self.tx_min_freq_lmda = tx_min_freq_lmda
336 else:
337 self.tx_min_freq_lmda = 0
338 if tx_max_freq_lmda != None:
339 self.tx_max_freq_lmda = tx_max_freq_lmda
340 else:
341 self.tx_max_freq_lmda = 0
342 if tx_grid_freq_lmda != None:
343 self.tx_grid_freq_lmda = tx_grid_freq_lmda
344 else:
345 self.tx_grid_freq_lmda = 0
346 if rx_min_freq_lmda != None:
347 self.rx_min_freq_lmda = rx_min_freq_lmda
348 else:
349 self.rx_min_freq_lmda = 0
350 if rx_max_freq_lmda != None:
351 self.rx_max_freq_lmda = rx_max_freq_lmda
352 else:
353 self.rx_max_freq_lmda = 0
354 if rx_grid_freq_lmda != None:
355 self.rx_grid_freq_lmda = rx_grid_freq_lmda
356 else:
357 self.rx_grid_freq_lmda = 0
358 if tx_pwr_min != None:
359 self.tx_pwr_min = tx_pwr_min
360 else:
361 self.tx_pwr_min = 0
362 if tx_pwr_max != None:
363 self.tx_pwr_max = tx_pwr_max
364 else:
365 self.tx_pwr_max = 0
366 return
367
368 def pack(self):
369 packed = []
370 packed.append(struct.pack("!H", self.type))
371 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
372 packed.append('\x00' * 4)
373 packed.append(struct.pack("!L", self.supported))
374 packed.append(struct.pack("!L", self.tx_min_freq_lmda))
375 packed.append(struct.pack("!L", self.tx_max_freq_lmda))
376 packed.append(struct.pack("!L", self.tx_grid_freq_lmda))
377 packed.append(struct.pack("!L", self.rx_min_freq_lmda))
378 packed.append(struct.pack("!L", self.rx_max_freq_lmda))
379 packed.append(struct.pack("!L", self.rx_grid_freq_lmda))
380 packed.append(struct.pack("!L", self.tx_pwr_min))
381 packed.append(struct.pack("!L", self.tx_pwr_max))
382 length = sum([len(x) for x in packed])
383 packed[1] = struct.pack("!H", length)
384 return ''.join(packed)
385
386 @staticmethod
387 def unpack(reader):
388 obj = optical()
389 _type = reader.read("!H")[0]
390 assert(_type == 1)
391 _length = reader.read("!H")[0]
392 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800393 reader = orig_reader.slice(_length, 4)
Rich Lane2e079da2014-10-29 15:30:24 -0700394 reader.skip(4)
395 obj.supported = reader.read("!L")[0]
396 obj.tx_min_freq_lmda = reader.read("!L")[0]
397 obj.tx_max_freq_lmda = reader.read("!L")[0]
398 obj.tx_grid_freq_lmda = reader.read("!L")[0]
399 obj.rx_min_freq_lmda = reader.read("!L")[0]
400 obj.rx_max_freq_lmda = reader.read("!L")[0]
401 obj.rx_grid_freq_lmda = reader.read("!L")[0]
402 obj.tx_pwr_min = reader.read("!L")[0]
403 obj.tx_pwr_max = reader.read("!L")[0]
404 return obj
405
406 def __eq__(self, other):
407 if type(self) != type(other): return False
408 if self.supported != other.supported: return False
409 if self.tx_min_freq_lmda != other.tx_min_freq_lmda: return False
410 if self.tx_max_freq_lmda != other.tx_max_freq_lmda: return False
411 if self.tx_grid_freq_lmda != other.tx_grid_freq_lmda: return False
412 if self.rx_min_freq_lmda != other.rx_min_freq_lmda: return False
413 if self.rx_max_freq_lmda != other.rx_max_freq_lmda: return False
414 if self.rx_grid_freq_lmda != other.rx_grid_freq_lmda: return False
415 if self.tx_pwr_min != other.tx_pwr_min: return False
416 if self.tx_pwr_max != other.tx_pwr_max: return False
417 return True
418
419 def pretty_print(self, q):
420 q.text("optical {")
421 with q.group():
422 with q.indent(2):
423 q.breakable()
424 q.text("supported = ");
425 q.text("%#x" % self.supported)
426 q.text(","); q.breakable()
427 q.text("tx_min_freq_lmda = ");
428 q.text("%#x" % self.tx_min_freq_lmda)
429 q.text(","); q.breakable()
430 q.text("tx_max_freq_lmda = ");
431 q.text("%#x" % self.tx_max_freq_lmda)
432 q.text(","); q.breakable()
433 q.text("tx_grid_freq_lmda = ");
434 q.text("%#x" % self.tx_grid_freq_lmda)
435 q.text(","); q.breakable()
436 q.text("rx_min_freq_lmda = ");
437 q.text("%#x" % self.rx_min_freq_lmda)
438 q.text(","); q.breakable()
439 q.text("rx_max_freq_lmda = ");
440 q.text("%#x" % self.rx_max_freq_lmda)
441 q.text(","); q.breakable()
442 q.text("rx_grid_freq_lmda = ");
443 q.text("%#x" % self.rx_grid_freq_lmda)
444 q.text(","); q.breakable()
445 q.text("tx_pwr_min = ");
446 q.text("%#x" % self.tx_pwr_min)
447 q.text(","); q.breakable()
448 q.text("tx_pwr_max = ");
449 q.text("%#x" % self.tx_pwr_max)
450 q.breakable()
451 q.text('}')
452
453port_desc_prop.subtypes[1] = optical
454
455