blob: 2266f3c7a4f4cbc25b52d7261184fa2f5607d520 [file] [log] [blame]
Nathan Knuth418fdc82016-09-16 22:51:15 -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 util
12import loxi.generic_util
13
14import sys
15ofp = sys.modules['loxi.of14']
16
17class port_stats_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_stats_prop.subtypes.get(subtype)
40 if subclass:
41 return subclass.unpack(reader)
42
43 obj = port_stats_prop()
44 obj.type = reader.read("!H")[0]
45 _length = reader.read("!H")[0]
46 orig_reader = reader
47 reader = orig_reader.slice(_length, 4)
48 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_stats_prop {")
57 with q.group():
58 with q.indent(2):
59 q.breakable()
60 q.breakable()
61 q.text('}')
62
63
64class ethernet(port_stats_prop):
65 type = 0
66
67 def __init__(self, rx_frame_err=None, rx_over_err=None, rx_crc_err=None, collisions=None):
68 if rx_frame_err != None:
69 self.rx_frame_err = rx_frame_err
70 else:
71 self.rx_frame_err = 0
72 if rx_over_err != None:
73 self.rx_over_err = rx_over_err
74 else:
75 self.rx_over_err = 0
76 if rx_crc_err != None:
77 self.rx_crc_err = rx_crc_err
78 else:
79 self.rx_crc_err = 0
80 if collisions != None:
81 self.collisions = collisions
82 else:
83 self.collisions = 0
84 return
85
86 def pack(self):
87 packed = []
88 packed.append(struct.pack("!H", self.type))
89 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
90 packed.append('\x00' * 4)
91 packed.append(struct.pack("!Q", self.rx_frame_err))
92 packed.append(struct.pack("!Q", self.rx_over_err))
93 packed.append(struct.pack("!Q", self.rx_crc_err))
94 packed.append(struct.pack("!Q", self.collisions))
95 length = sum([len(x) for x in packed])
96 packed[1] = struct.pack("!H", length)
97 return ''.join(packed)
98
99 @staticmethod
100 def unpack(reader):
101 obj = ethernet()
102 _type = reader.read("!H")[0]
103 assert(_type == 0)
104 _length = reader.read("!H")[0]
105 orig_reader = reader
106 reader = orig_reader.slice(_length, 4)
107 reader.skip(4)
108 obj.rx_frame_err = reader.read("!Q")[0]
109 obj.rx_over_err = reader.read("!Q")[0]
110 obj.rx_crc_err = reader.read("!Q")[0]
111 obj.collisions = reader.read("!Q")[0]
112 return obj
113
114 def __eq__(self, other):
115 if type(self) != type(other): return False
116 if self.rx_frame_err != other.rx_frame_err: return False
117 if self.rx_over_err != other.rx_over_err: return False
118 if self.rx_crc_err != other.rx_crc_err: return False
119 if self.collisions != other.collisions: return False
120 return True
121
122 def pretty_print(self, q):
123 q.text("ethernet {")
124 with q.group():
125 with q.indent(2):
126 q.breakable()
127 q.text("rx_frame_err = ");
128 q.text("%#x" % self.rx_frame_err)
129 q.text(","); q.breakable()
130 q.text("rx_over_err = ");
131 q.text("%#x" % self.rx_over_err)
132 q.text(","); q.breakable()
133 q.text("rx_crc_err = ");
134 q.text("%#x" % self.rx_crc_err)
135 q.text(","); q.breakable()
136 q.text("collisions = ");
137 q.text("%#x" % self.collisions)
138 q.breakable()
139 q.text('}')
140
141port_stats_prop.subtypes[0] = ethernet
142
143class experimenter(port_stats_prop):
144 subtypes = {}
145
146 type = 65535
147
148 def __init__(self, experimenter=None, exp_type=None, experimenter_data=None):
149 if experimenter != None:
150 self.experimenter = experimenter
151 else:
152 self.experimenter = 0
153 if exp_type != None:
154 self.exp_type = exp_type
155 else:
156 self.exp_type = 0
157 if experimenter_data != None:
158 self.experimenter_data = experimenter_data
159 else:
160 self.experimenter_data = ''
161 return
162
163 def pack(self):
164 packed = []
165 packed.append(struct.pack("!H", self.type))
166 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
167 packed.append(struct.pack("!L", self.experimenter))
168 packed.append(struct.pack("!L", self.exp_type))
169 packed.append(self.experimenter_data)
170 length = sum([len(x) for x in packed])
171 packed[1] = struct.pack("!H", length)
172 return ''.join(packed)
173
174 @staticmethod
175 def unpack(reader):
176 subtype, = reader.peek('!L', 4)
177 subclass = experimenter.subtypes.get(subtype)
178 if subclass:
179 return subclass.unpack(reader)
180
181 obj = experimenter()
182 _type = reader.read("!H")[0]
183 assert(_type == 65535)
184 _length = reader.read("!H")[0]
185 orig_reader = reader
186 reader = orig_reader.slice(_length, 4)
187 obj.experimenter = reader.read("!L")[0]
188 obj.exp_type = reader.read("!L")[0]
189 obj.experimenter_data = str(reader.read_all())
190 return obj
191
192 def __eq__(self, other):
193 if type(self) != type(other): return False
194 if self.experimenter != other.experimenter: return False
195 if self.exp_type != other.exp_type: return False
196 if self.experimenter_data != other.experimenter_data: return False
197 return True
198
199 def pretty_print(self, q):
200 q.text("experimenter {")
201 with q.group():
202 with q.indent(2):
203 q.breakable()
204 q.text("exp_type = ");
205 q.text("%#x" % self.exp_type)
206 q.text(","); q.breakable()
207 q.text("experimenter_data = ");
208 q.pp(self.experimenter_data)
209 q.breakable()
210 q.text('}')
211
212port_stats_prop.subtypes[65535] = experimenter
213
214class optical(port_stats_prop):
215 type = 1
216
217 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):
218 if flags != None:
219 self.flags = flags
220 else:
221 self.flags = 0
222 if tx_freq_lmda != None:
223 self.tx_freq_lmda = tx_freq_lmda
224 else:
225 self.tx_freq_lmda = 0
226 if tx_offset != None:
227 self.tx_offset = tx_offset
228 else:
229 self.tx_offset = 0
230 if tx_grid_span != None:
231 self.tx_grid_span = tx_grid_span
232 else:
233 self.tx_grid_span = 0
234 if rx_freq_lmda != None:
235 self.rx_freq_lmda = rx_freq_lmda
236 else:
237 self.rx_freq_lmda = 0
238 if rx_offset != None:
239 self.rx_offset = rx_offset
240 else:
241 self.rx_offset = 0
242 if rx_grid_span != None:
243 self.rx_grid_span = rx_grid_span
244 else:
245 self.rx_grid_span = 0
246 if tx_pwr != None:
247 self.tx_pwr = tx_pwr
248 else:
249 self.tx_pwr = 0
250 if rx_pwr != None:
251 self.rx_pwr = rx_pwr
252 else:
253 self.rx_pwr = 0
254 if bias_current != None:
255 self.bias_current = bias_current
256 else:
257 self.bias_current = 0
258 if temperature != None:
259 self.temperature = temperature
260 else:
261 self.temperature = 0
262 return
263
264 def pack(self):
265 packed = []
266 packed.append(struct.pack("!H", self.type))
267 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
268 packed.append('\x00' * 4)
269 packed.append(struct.pack("!L", self.flags))
270 packed.append(struct.pack("!L", self.tx_freq_lmda))
271 packed.append(struct.pack("!L", self.tx_offset))
272 packed.append(struct.pack("!L", self.tx_grid_span))
273 packed.append(struct.pack("!L", self.rx_freq_lmda))
274 packed.append(struct.pack("!L", self.rx_offset))
275 packed.append(struct.pack("!L", self.rx_grid_span))
276 packed.append(struct.pack("!H", self.tx_pwr))
277 packed.append(struct.pack("!H", self.rx_pwr))
278 packed.append(struct.pack("!H", self.bias_current))
279 packed.append(struct.pack("!H", self.temperature))
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
291 reader = orig_reader.slice(_length, 4)
292 reader.skip(4)
293 obj.flags = reader.read("!L")[0]
294 obj.tx_freq_lmda = reader.read("!L")[0]
295 obj.tx_offset = reader.read("!L")[0]
296 obj.tx_grid_span = reader.read("!L")[0]
297 obj.rx_freq_lmda = reader.read("!L")[0]
298 obj.rx_offset = reader.read("!L")[0]
299 obj.rx_grid_span = reader.read("!L")[0]
300 obj.tx_pwr = reader.read("!H")[0]
301 obj.rx_pwr = reader.read("!H")[0]
302 obj.bias_current = reader.read("!H")[0]
303 obj.temperature = reader.read("!H")[0]
304 return obj
305
306 def __eq__(self, other):
307 if type(self) != type(other): return False
308 if self.flags != other.flags: return False
309 if self.tx_freq_lmda != other.tx_freq_lmda: return False
310 if self.tx_offset != other.tx_offset: return False
311 if self.tx_grid_span != other.tx_grid_span: return False
312 if self.rx_freq_lmda != other.rx_freq_lmda: return False
313 if self.rx_offset != other.rx_offset: return False
314 if self.rx_grid_span != other.rx_grid_span: return False
315 if self.tx_pwr != other.tx_pwr: return False
316 if self.rx_pwr != other.rx_pwr: return False
317 if self.bias_current != other.bias_current: return False
318 if self.temperature != other.temperature: return False
319 return True
320
321 def pretty_print(self, q):
322 q.text("optical {")
323 with q.group():
324 with q.indent(2):
325 q.breakable()
326 q.text("flags = ");
327 q.text("%#x" % self.flags)
328 q.text(","); q.breakable()
329 q.text("tx_freq_lmda = ");
330 q.text("%#x" % self.tx_freq_lmda)
331 q.text(","); q.breakable()
332 q.text("tx_offset = ");
333 q.text("%#x" % self.tx_offset)
334 q.text(","); q.breakable()
335 q.text("tx_grid_span = ");
336 q.text("%#x" % self.tx_grid_span)
337 q.text(","); q.breakable()
338 q.text("rx_freq_lmda = ");
339 q.text("%#x" % self.rx_freq_lmda)
340 q.text(","); q.breakable()
341 q.text("rx_offset = ");
342 q.text("%#x" % self.rx_offset)
343 q.text(","); q.breakable()
344 q.text("rx_grid_span = ");
345 q.text("%#x" % self.rx_grid_span)
346 q.text(","); q.breakable()
347 q.text("tx_pwr = ");
348 q.text("%#x" % self.tx_pwr)
349 q.text(","); q.breakable()
350 q.text("rx_pwr = ");
351 q.text("%#x" % self.rx_pwr)
352 q.text(","); q.breakable()
353 q.text("bias_current = ");
354 q.text("%#x" % self.bias_current)
355 q.text(","); q.breakable()
356 q.text("temperature = ");
357 q.text("%#x" % self.temperature)
358 q.breakable()
359 q.text('}')
360
361port_stats_prop.subtypes[1] = optical
362
363