blob: 10460e24527fadebb9574244f3b655888817274f [file] [log] [blame]
Zack Williams41513bf2018-07-07 20:08:35 -07001# Copyright 2017-present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
Nathan Knuth418fdc82016-09-16 22:51:15 -070014# Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
15# Copyright (c) 2011, 2012 Open Networking Foundation
16# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
17# See the file LICENSE.pyloxi which should have been included in the source distribution
18
19# Automatically generated by LOXI from template module.py
20# Do not modify
21
22import struct
23import loxi
24import util
25import loxi.generic_util
26
27import sys
28ofp = sys.modules['loxi.of14']
29
30class port_stats_prop(loxi.OFObject):
31 subtypes = {}
32
33
34 def __init__(self, type=None):
35 if type != None:
36 self.type = type
37 else:
38 self.type = 0
39 return
40
41 def pack(self):
42 packed = []
43 packed.append(struct.pack("!H", self.type))
44 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
45 length = sum([len(x) for x in packed])
46 packed[1] = struct.pack("!H", length)
47 return ''.join(packed)
48
49 @staticmethod
50 def unpack(reader):
51 subtype, = reader.peek('!H', 0)
52 subclass = port_stats_prop.subtypes.get(subtype)
53 if subclass:
54 return subclass.unpack(reader)
55
56 obj = port_stats_prop()
57 obj.type = reader.read("!H")[0]
58 _length = reader.read("!H")[0]
59 orig_reader = reader
60 reader = orig_reader.slice(_length, 4)
61 return obj
62
63 def __eq__(self, other):
64 if type(self) != type(other): return False
65 if self.type != other.type: return False
66 return True
67
68 def pretty_print(self, q):
69 q.text("port_stats_prop {")
70 with q.group():
71 with q.indent(2):
72 q.breakable()
73 q.breakable()
74 q.text('}')
75
76
77class ethernet(port_stats_prop):
78 type = 0
79
80 def __init__(self, rx_frame_err=None, rx_over_err=None, rx_crc_err=None, collisions=None):
81 if rx_frame_err != None:
82 self.rx_frame_err = rx_frame_err
83 else:
84 self.rx_frame_err = 0
85 if rx_over_err != None:
86 self.rx_over_err = rx_over_err
87 else:
88 self.rx_over_err = 0
89 if rx_crc_err != None:
90 self.rx_crc_err = rx_crc_err
91 else:
92 self.rx_crc_err = 0
93 if collisions != None:
94 self.collisions = collisions
95 else:
96 self.collisions = 0
97 return
98
99 def pack(self):
100 packed = []
101 packed.append(struct.pack("!H", self.type))
102 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
103 packed.append('\x00' * 4)
104 packed.append(struct.pack("!Q", self.rx_frame_err))
105 packed.append(struct.pack("!Q", self.rx_over_err))
106 packed.append(struct.pack("!Q", self.rx_crc_err))
107 packed.append(struct.pack("!Q", self.collisions))
108 length = sum([len(x) for x in packed])
109 packed[1] = struct.pack("!H", length)
110 return ''.join(packed)
111
112 @staticmethod
113 def unpack(reader):
114 obj = ethernet()
115 _type = reader.read("!H")[0]
116 assert(_type == 0)
117 _length = reader.read("!H")[0]
118 orig_reader = reader
119 reader = orig_reader.slice(_length, 4)
120 reader.skip(4)
121 obj.rx_frame_err = reader.read("!Q")[0]
122 obj.rx_over_err = reader.read("!Q")[0]
123 obj.rx_crc_err = reader.read("!Q")[0]
124 obj.collisions = reader.read("!Q")[0]
125 return obj
126
127 def __eq__(self, other):
128 if type(self) != type(other): return False
129 if self.rx_frame_err != other.rx_frame_err: return False
130 if self.rx_over_err != other.rx_over_err: return False
131 if self.rx_crc_err != other.rx_crc_err: return False
132 if self.collisions != other.collisions: return False
133 return True
134
135 def pretty_print(self, q):
136 q.text("ethernet {")
137 with q.group():
138 with q.indent(2):
139 q.breakable()
140 q.text("rx_frame_err = ");
141 q.text("%#x" % self.rx_frame_err)
142 q.text(","); q.breakable()
143 q.text("rx_over_err = ");
144 q.text("%#x" % self.rx_over_err)
145 q.text(","); q.breakable()
146 q.text("rx_crc_err = ");
147 q.text("%#x" % self.rx_crc_err)
148 q.text(","); q.breakable()
149 q.text("collisions = ");
150 q.text("%#x" % self.collisions)
151 q.breakable()
152 q.text('}')
153
154port_stats_prop.subtypes[0] = ethernet
155
156class experimenter(port_stats_prop):
157 subtypes = {}
158
159 type = 65535
160
161 def __init__(self, experimenter=None, exp_type=None, experimenter_data=None):
162 if experimenter != None:
163 self.experimenter = experimenter
164 else:
165 self.experimenter = 0
166 if exp_type != None:
167 self.exp_type = exp_type
168 else:
169 self.exp_type = 0
170 if experimenter_data != None:
171 self.experimenter_data = experimenter_data
172 else:
173 self.experimenter_data = ''
174 return
175
176 def pack(self):
177 packed = []
178 packed.append(struct.pack("!H", self.type))
179 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
180 packed.append(struct.pack("!L", self.experimenter))
181 packed.append(struct.pack("!L", self.exp_type))
182 packed.append(self.experimenter_data)
183 length = sum([len(x) for x in packed])
184 packed[1] = struct.pack("!H", length)
185 return ''.join(packed)
186
187 @staticmethod
188 def unpack(reader):
189 subtype, = reader.peek('!L', 4)
190 subclass = experimenter.subtypes.get(subtype)
191 if subclass:
192 return subclass.unpack(reader)
193
194 obj = experimenter()
195 _type = reader.read("!H")[0]
196 assert(_type == 65535)
197 _length = reader.read("!H")[0]
198 orig_reader = reader
199 reader = orig_reader.slice(_length, 4)
200 obj.experimenter = reader.read("!L")[0]
201 obj.exp_type = reader.read("!L")[0]
202 obj.experimenter_data = str(reader.read_all())
203 return obj
204
205 def __eq__(self, other):
206 if type(self) != type(other): return False
207 if self.experimenter != other.experimenter: return False
208 if self.exp_type != other.exp_type: return False
209 if self.experimenter_data != other.experimenter_data: 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.text(","); q.breakable()
220 q.text("experimenter_data = ");
221 q.pp(self.experimenter_data)
222 q.breakable()
223 q.text('}')
224
225port_stats_prop.subtypes[65535] = experimenter
226
227class optical(port_stats_prop):
228 type = 1
229
230 def __init__(self, flags=None, tx_freq_lmda=None, tx_offset=None, tx_grid_span=None, rx_freq_lmda=None, rx_offset=None, rx_grid_span=None, tx_pwr=None, rx_pwr=None, bias_current=None, temperature=None):
231 if flags != None:
232 self.flags = flags
233 else:
234 self.flags = 0
235 if tx_freq_lmda != None:
236 self.tx_freq_lmda = tx_freq_lmda
237 else:
238 self.tx_freq_lmda = 0
239 if tx_offset != None:
240 self.tx_offset = tx_offset
241 else:
242 self.tx_offset = 0
243 if tx_grid_span != None:
244 self.tx_grid_span = tx_grid_span
245 else:
246 self.tx_grid_span = 0
247 if rx_freq_lmda != None:
248 self.rx_freq_lmda = rx_freq_lmda
249 else:
250 self.rx_freq_lmda = 0
251 if rx_offset != None:
252 self.rx_offset = rx_offset
253 else:
254 self.rx_offset = 0
255 if rx_grid_span != None:
256 self.rx_grid_span = rx_grid_span
257 else:
258 self.rx_grid_span = 0
259 if tx_pwr != None:
260 self.tx_pwr = tx_pwr
261 else:
262 self.tx_pwr = 0
263 if rx_pwr != None:
264 self.rx_pwr = rx_pwr
265 else:
266 self.rx_pwr = 0
267 if bias_current != None:
268 self.bias_current = bias_current
269 else:
270 self.bias_current = 0
271 if temperature != None:
272 self.temperature = temperature
273 else:
274 self.temperature = 0
275 return
276
277 def pack(self):
278 packed = []
279 packed.append(struct.pack("!H", self.type))
280 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
281 packed.append('\x00' * 4)
282 packed.append(struct.pack("!L", self.flags))
283 packed.append(struct.pack("!L", self.tx_freq_lmda))
284 packed.append(struct.pack("!L", self.tx_offset))
285 packed.append(struct.pack("!L", self.tx_grid_span))
286 packed.append(struct.pack("!L", self.rx_freq_lmda))
287 packed.append(struct.pack("!L", self.rx_offset))
288 packed.append(struct.pack("!L", self.rx_grid_span))
289 packed.append(struct.pack("!H", self.tx_pwr))
290 packed.append(struct.pack("!H", self.rx_pwr))
291 packed.append(struct.pack("!H", self.bias_current))
292 packed.append(struct.pack("!H", self.temperature))
293 length = sum([len(x) for x in packed])
294 packed[1] = struct.pack("!H", length)
295 return ''.join(packed)
296
297 @staticmethod
298 def unpack(reader):
299 obj = optical()
300 _type = reader.read("!H")[0]
301 assert(_type == 1)
302 _length = reader.read("!H")[0]
303 orig_reader = reader
304 reader = orig_reader.slice(_length, 4)
305 reader.skip(4)
306 obj.flags = reader.read("!L")[0]
307 obj.tx_freq_lmda = reader.read("!L")[0]
308 obj.tx_offset = reader.read("!L")[0]
309 obj.tx_grid_span = reader.read("!L")[0]
310 obj.rx_freq_lmda = reader.read("!L")[0]
311 obj.rx_offset = reader.read("!L")[0]
312 obj.rx_grid_span = reader.read("!L")[0]
313 obj.tx_pwr = reader.read("!H")[0]
314 obj.rx_pwr = reader.read("!H")[0]
315 obj.bias_current = reader.read("!H")[0]
316 obj.temperature = reader.read("!H")[0]
317 return obj
318
319 def __eq__(self, other):
320 if type(self) != type(other): return False
321 if self.flags != other.flags: return False
322 if self.tx_freq_lmda != other.tx_freq_lmda: return False
323 if self.tx_offset != other.tx_offset: return False
324 if self.tx_grid_span != other.tx_grid_span: return False
325 if self.rx_freq_lmda != other.rx_freq_lmda: return False
326 if self.rx_offset != other.rx_offset: return False
327 if self.rx_grid_span != other.rx_grid_span: return False
328 if self.tx_pwr != other.tx_pwr: return False
329 if self.rx_pwr != other.rx_pwr: return False
330 if self.bias_current != other.bias_current: return False
331 if self.temperature != other.temperature: return False
332 return True
333
334 def pretty_print(self, q):
335 q.text("optical {")
336 with q.group():
337 with q.indent(2):
338 q.breakable()
339 q.text("flags = ");
340 q.text("%#x" % self.flags)
341 q.text(","); q.breakable()
342 q.text("tx_freq_lmda = ");
343 q.text("%#x" % self.tx_freq_lmda)
344 q.text(","); q.breakable()
345 q.text("tx_offset = ");
346 q.text("%#x" % self.tx_offset)
347 q.text(","); q.breakable()
348 q.text("tx_grid_span = ");
349 q.text("%#x" % self.tx_grid_span)
350 q.text(","); q.breakable()
351 q.text("rx_freq_lmda = ");
352 q.text("%#x" % self.rx_freq_lmda)
353 q.text(","); q.breakable()
354 q.text("rx_offset = ");
355 q.text("%#x" % self.rx_offset)
356 q.text(","); q.breakable()
357 q.text("rx_grid_span = ");
358 q.text("%#x" % self.rx_grid_span)
359 q.text(","); q.breakable()
360 q.text("tx_pwr = ");
361 q.text("%#x" % self.tx_pwr)
362 q.text(","); q.breakable()
363 q.text("rx_pwr = ");
364 q.text("%#x" % self.rx_pwr)
365 q.text(","); q.breakable()
366 q.text("bias_current = ");
367 q.text("%#x" % self.bias_current)
368 q.text(","); q.breakable()
369 q.text("temperature = ");
370 q.text("%#x" % self.temperature)
371 q.breakable()
372 q.text('}')
373
374port_stats_prop.subtypes[1] = optical
375
376