blob: 71f281d7f2f41c4261043dd4b7f925651ff246cd [file] [log] [blame]
Sreeju Sreedhare3fefd92019-04-02 15:57:15 -07001
2# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
17# Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
18# Copyright (c) 2011, 2012 Open Networking Foundation
19# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
20# See the file LICENSE.pyloxi which should have been included in the source distribution
21
22# Automatically generated by LOXI from template module.py
23# Do not modify
24
25import struct
26import loxi
27import util
28import loxi.generic_util
29
30import sys
31ofp = sys.modules['loxi.of14']
32
33class port_desc_prop(loxi.OFObject):
34 subtypes = {}
35
36
37 def __init__(self, type=None):
38 if type != None:
39 self.type = type
40 else:
41 self.type = 0
42 return
43
44 def pack(self):
45 packed = []
46 packed.append(struct.pack("!H", self.type))
47 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
48 length = sum([len(x) for x in packed])
49 packed[1] = struct.pack("!H", length)
50 return ''.join(packed)
51
52 @staticmethod
53 def unpack(reader):
54 subtype, = reader.peek('!H', 0)
55 subclass = port_desc_prop.subtypes.get(subtype)
56 if subclass:
57 return subclass.unpack(reader)
58
59 obj = port_desc_prop()
60 obj.type = reader.read("!H")[0]
61 _length = reader.read("!H")[0]
62 orig_reader = reader
63 reader = orig_reader.slice(_length, 4)
64 return obj
65
66 def __eq__(self, other):
67 if type(self) != type(other): return False
68 if self.type != other.type: return False
69 return True
70
71 def pretty_print(self, q):
72 q.text("port_desc_prop {")
73 with q.group():
74 with q.indent(2):
75 q.breakable()
76 q.breakable()
77 q.text('}')
78
79
80class experimenter(port_desc_prop):
81 subtypes = {}
82
83 type = 65535
84
85 def __init__(self, experimenter=None):
86 if experimenter != None:
87 self.experimenter = experimenter
88 else:
89 self.experimenter = 0
90 return
91
92 def pack(self):
93 packed = []
94 packed.append(struct.pack("!H", self.type))
95 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
96 packed.append(struct.pack("!L", self.experimenter))
97 length = sum([len(x) for x in packed])
98 packed[1] = struct.pack("!H", length)
99 return ''.join(packed)
100
101 @staticmethod
102 def unpack(reader):
103 subtype, = reader.peek('!L', 4)
104 subclass = experimenter.subtypes.get(subtype)
105 if subclass:
106 return subclass.unpack(reader)
107
108 obj = experimenter()
109 _type = reader.read("!H")[0]
110 assert(_type == 65535)
111 _length = reader.read("!H")[0]
112 orig_reader = reader
113 reader = orig_reader.slice(_length, 4)
114 obj.experimenter = reader.read("!L")[0]
115 return obj
116
117 def __eq__(self, other):
118 if type(self) != type(other): return False
119 if self.experimenter != other.experimenter: return False
120 return True
121
122 def pretty_print(self, q):
123 q.text("experimenter {")
124 with q.group():
125 with q.indent(2):
126 q.breakable()
127 q.breakable()
128 q.text('}')
129
130port_desc_prop.subtypes[65535] = experimenter
131
132class bsn(experimenter):
133 subtypes = {}
134
135 type = 65535
136 experimenter = 6035143
137
138 def __init__(self, exp_type=None):
139 if exp_type != None:
140 self.exp_type = exp_type
141 else:
142 self.exp_type = 0
143 return
144
145 def pack(self):
146 packed = []
147 packed.append(struct.pack("!H", self.type))
148 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
149 packed.append(struct.pack("!L", self.experimenter))
150 packed.append(struct.pack("!L", self.exp_type))
151 length = sum([len(x) for x in packed])
152 packed[1] = struct.pack("!H", length)
153 return ''.join(packed)
154
155 @staticmethod
156 def unpack(reader):
157 subtype, = reader.peek('!L', 8)
158 subclass = bsn.subtypes.get(subtype)
159 if subclass:
160 return subclass.unpack(reader)
161
162 obj = bsn()
163 _type = reader.read("!H")[0]
164 assert(_type == 65535)
165 _length = reader.read("!H")[0]
166 orig_reader = reader
167 reader = orig_reader.slice(_length, 4)
168 _experimenter = reader.read("!L")[0]
169 assert(_experimenter == 6035143)
170 obj.exp_type = reader.read("!L")[0]
171 return obj
172
173 def __eq__(self, other):
174 if type(self) != type(other): return False
175 if self.exp_type != other.exp_type: return False
176 return True
177
178 def pretty_print(self, q):
179 q.text("bsn {")
180 with q.group():
181 with q.indent(2):
182 q.breakable()
183 q.breakable()
184 q.text('}')
185
186experimenter.subtypes[6035143] = bsn
187
188class bsn_generation_id(bsn):
189 type = 65535
190 experimenter = 6035143
191 exp_type = 1
192
193 def __init__(self, generation_id=None):
194 if generation_id != None:
195 self.generation_id = generation_id
196 else:
197 self.generation_id = 0
198 return
199
200 def pack(self):
201 packed = []
202 packed.append(struct.pack("!H", self.type))
203 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
204 packed.append(struct.pack("!L", self.experimenter))
205 packed.append(struct.pack("!L", self.exp_type))
206 packed.append(struct.pack("!Q", self.generation_id))
207 length = sum([len(x) for x in packed])
208 packed[1] = struct.pack("!H", length)
209 return ''.join(packed)
210
211 @staticmethod
212 def unpack(reader):
213 obj = bsn_generation_id()
214 _type = reader.read("!H")[0]
215 assert(_type == 65535)
216 _length = reader.read("!H")[0]
217 orig_reader = reader
218 reader = orig_reader.slice(_length, 4)
219 _experimenter = reader.read("!L")[0]
220 assert(_experimenter == 6035143)
221 _exp_type = reader.read("!L")[0]
222 assert(_exp_type == 1)
223 obj.generation_id = reader.read("!Q")[0]
224 return obj
225
226 def __eq__(self, other):
227 if type(self) != type(other): return False
228 if self.generation_id != other.generation_id: return False
229 return True
230
231 def pretty_print(self, q):
232 q.text("bsn_generation_id {")
233 with q.group():
234 with q.indent(2):
235 q.breakable()
236 q.text("generation_id = ");
237 q.text("%#x" % self.generation_id)
238 q.breakable()
239 q.text('}')
240
241bsn.subtypes[1] = bsn_generation_id
242
243class bsn_uplink(bsn):
244 type = 65535
245 experimenter = 6035143
246 exp_type = 0
247
248 def __init__(self):
249 return
250
251 def pack(self):
252 packed = []
253 packed.append(struct.pack("!H", self.type))
254 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
255 packed.append(struct.pack("!L", self.experimenter))
256 packed.append(struct.pack("!L", self.exp_type))
257 length = sum([len(x) for x in packed])
258 packed[1] = struct.pack("!H", length)
259 return ''.join(packed)
260
261 @staticmethod
262 def unpack(reader):
263 obj = bsn_uplink()
264 _type = reader.read("!H")[0]
265 assert(_type == 65535)
266 _length = reader.read("!H")[0]
267 orig_reader = reader
268 reader = orig_reader.slice(_length, 4)
269 _experimenter = reader.read("!L")[0]
270 assert(_experimenter == 6035143)
271 _exp_type = reader.read("!L")[0]
272 assert(_exp_type == 0)
273 return obj
274
275 def __eq__(self, other):
276 if type(self) != type(other): return False
277 return True
278
279 def pretty_print(self, q):
280 q.text("bsn_uplink {")
281 with q.group():
282 with q.indent(2):
283 q.breakable()
284 q.breakable()
285 q.text('}')
286
287bsn.subtypes[0] = bsn_uplink
288
289class ethernet(port_desc_prop):
290 type = 0
291
292 def __init__(self, curr=None, advertised=None, supported=None, peer=None, curr_speed=None, max_speed=None):
293 if curr != None:
294 self.curr = curr
295 else:
296 self.curr = 0
297 if advertised != None:
298 self.advertised = advertised
299 else:
300 self.advertised = 0
301 if supported != None:
302 self.supported = supported
303 else:
304 self.supported = 0
305 if peer != None:
306 self.peer = peer
307 else:
308 self.peer = 0
309 if curr_speed != None:
310 self.curr_speed = curr_speed
311 else:
312 self.curr_speed = 0
313 if max_speed != None:
314 self.max_speed = max_speed
315 else:
316 self.max_speed = 0
317 return
318
319 def pack(self):
320 packed = []
321 packed.append(struct.pack("!H", self.type))
322 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
323 packed.append('\x00' * 4)
324 packed.append(struct.pack("!L", self.curr))
325 packed.append(struct.pack("!L", self.advertised))
326 packed.append(struct.pack("!L", self.supported))
327 packed.append(struct.pack("!L", self.peer))
328 packed.append(struct.pack("!L", self.curr_speed))
329 packed.append(struct.pack("!L", self.max_speed))
330 length = sum([len(x) for x in packed])
331 packed[1] = struct.pack("!H", length)
332 return ''.join(packed)
333
334 @staticmethod
335 def unpack(reader):
336 obj = ethernet()
337 _type = reader.read("!H")[0]
338 assert(_type == 0)
339 _length = reader.read("!H")[0]
340 orig_reader = reader
341 reader = orig_reader.slice(_length, 4)
342 reader.skip(4)
343 obj.curr = reader.read("!L")[0]
344 obj.advertised = reader.read("!L")[0]
345 obj.supported = reader.read("!L")[0]
346 obj.peer = reader.read("!L")[0]
347 obj.curr_speed = reader.read("!L")[0]
348 obj.max_speed = reader.read("!L")[0]
349 return obj
350
351 def __eq__(self, other):
352 if type(self) != type(other): return False
353 if self.curr != other.curr: return False
354 if self.advertised != other.advertised: return False
355 if self.supported != other.supported: return False
356 if self.peer != other.peer: return False
357 if self.curr_speed != other.curr_speed: return False
358 if self.max_speed != other.max_speed: return False
359 return True
360
361 def pretty_print(self, q):
362 q.text("ethernet {")
363 with q.group():
364 with q.indent(2):
365 q.breakable()
366 q.text("curr = ");
367 q.text("%#x" % self.curr)
368 q.text(","); q.breakable()
369 q.text("advertised = ");
370 q.text("%#x" % self.advertised)
371 q.text(","); q.breakable()
372 q.text("supported = ");
373 q.text("%#x" % self.supported)
374 q.text(","); q.breakable()
375 q.text("peer = ");
376 q.text("%#x" % self.peer)
377 q.text(","); q.breakable()
378 q.text("curr_speed = ");
379 q.text("%#x" % self.curr_speed)
380 q.text(","); q.breakable()
381 q.text("max_speed = ");
382 q.text("%#x" % self.max_speed)
383 q.breakable()
384 q.text('}')
385
386port_desc_prop.subtypes[0] = ethernet
387
388class optical(port_desc_prop):
389 type = 1
390
391 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):
392 if supported != None:
393 self.supported = supported
394 else:
395 self.supported = 0
396 if tx_min_freq_lmda != None:
397 self.tx_min_freq_lmda = tx_min_freq_lmda
398 else:
399 self.tx_min_freq_lmda = 0
400 if tx_max_freq_lmda != None:
401 self.tx_max_freq_lmda = tx_max_freq_lmda
402 else:
403 self.tx_max_freq_lmda = 0
404 if tx_grid_freq_lmda != None:
405 self.tx_grid_freq_lmda = tx_grid_freq_lmda
406 else:
407 self.tx_grid_freq_lmda = 0
408 if rx_min_freq_lmda != None:
409 self.rx_min_freq_lmda = rx_min_freq_lmda
410 else:
411 self.rx_min_freq_lmda = 0
412 if rx_max_freq_lmda != None:
413 self.rx_max_freq_lmda = rx_max_freq_lmda
414 else:
415 self.rx_max_freq_lmda = 0
416 if rx_grid_freq_lmda != None:
417 self.rx_grid_freq_lmda = rx_grid_freq_lmda
418 else:
419 self.rx_grid_freq_lmda = 0
420 if tx_pwr_min != None:
421 self.tx_pwr_min = tx_pwr_min
422 else:
423 self.tx_pwr_min = 0
424 if tx_pwr_max != None:
425 self.tx_pwr_max = tx_pwr_max
426 else:
427 self.tx_pwr_max = 0
428 return
429
430 def pack(self):
431 packed = []
432 packed.append(struct.pack("!H", self.type))
433 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
434 packed.append('\x00' * 4)
435 packed.append(struct.pack("!L", self.supported))
436 packed.append(struct.pack("!L", self.tx_min_freq_lmda))
437 packed.append(struct.pack("!L", self.tx_max_freq_lmda))
438 packed.append(struct.pack("!L", self.tx_grid_freq_lmda))
439 packed.append(struct.pack("!L", self.rx_min_freq_lmda))
440 packed.append(struct.pack("!L", self.rx_max_freq_lmda))
441 packed.append(struct.pack("!L", self.rx_grid_freq_lmda))
442 packed.append(struct.pack("!L", self.tx_pwr_min))
443 packed.append(struct.pack("!L", self.tx_pwr_max))
444 length = sum([len(x) for x in packed])
445 packed[1] = struct.pack("!H", length)
446 return ''.join(packed)
447
448 @staticmethod
449 def unpack(reader):
450 obj = optical()
451 _type = reader.read("!H")[0]
452 assert(_type == 1)
453 _length = reader.read("!H")[0]
454 orig_reader = reader
455 reader = orig_reader.slice(_length, 4)
456 reader.skip(4)
457 obj.supported = reader.read("!L")[0]
458 obj.tx_min_freq_lmda = reader.read("!L")[0]
459 obj.tx_max_freq_lmda = reader.read("!L")[0]
460 obj.tx_grid_freq_lmda = reader.read("!L")[0]
461 obj.rx_min_freq_lmda = reader.read("!L")[0]
462 obj.rx_max_freq_lmda = reader.read("!L")[0]
463 obj.rx_grid_freq_lmda = reader.read("!L")[0]
464 obj.tx_pwr_min = reader.read("!L")[0]
465 obj.tx_pwr_max = reader.read("!L")[0]
466 return obj
467
468 def __eq__(self, other):
469 if type(self) != type(other): return False
470 if self.supported != other.supported: return False
471 if self.tx_min_freq_lmda != other.tx_min_freq_lmda: return False
472 if self.tx_max_freq_lmda != other.tx_max_freq_lmda: return False
473 if self.tx_grid_freq_lmda != other.tx_grid_freq_lmda: return False
474 if self.rx_min_freq_lmda != other.rx_min_freq_lmda: return False
475 if self.rx_max_freq_lmda != other.rx_max_freq_lmda: return False
476 if self.rx_grid_freq_lmda != other.rx_grid_freq_lmda: return False
477 if self.tx_pwr_min != other.tx_pwr_min: return False
478 if self.tx_pwr_max != other.tx_pwr_max: return False
479 return True
480
481 def pretty_print(self, q):
482 q.text("optical {")
483 with q.group():
484 with q.indent(2):
485 q.breakable()
486 q.text("supported = ");
487 q.text("%#x" % self.supported)
488 q.text(","); q.breakable()
489 q.text("tx_min_freq_lmda = ");
490 q.text("%#x" % self.tx_min_freq_lmda)
491 q.text(","); q.breakable()
492 q.text("tx_max_freq_lmda = ");
493 q.text("%#x" % self.tx_max_freq_lmda)
494 q.text(","); q.breakable()
495 q.text("tx_grid_freq_lmda = ");
496 q.text("%#x" % self.tx_grid_freq_lmda)
497 q.text(","); q.breakable()
498 q.text("rx_min_freq_lmda = ");
499 q.text("%#x" % self.rx_min_freq_lmda)
500 q.text(","); q.breakable()
501 q.text("rx_max_freq_lmda = ");
502 q.text("%#x" % self.rx_max_freq_lmda)
503 q.text(","); q.breakable()
504 q.text("rx_grid_freq_lmda = ");
505 q.text("%#x" % self.rx_grid_freq_lmda)
506 q.text(","); q.breakable()
507 q.text("tx_pwr_min = ");
508 q.text("%#x" % self.tx_pwr_min)
509 q.text(","); q.breakable()
510 q.text("tx_pwr_max = ");
511 q.text("%#x" % self.tx_pwr_max)
512 q.breakable()
513 q.text('}')
514
515port_desc_prop.subtypes[1] = optical
516
517