blob: 674b85d57ef0d124ad0a12911be6cb4fe96e6d6f [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
11import const
12import port_desc_prop
Rich Laneccd32ed2014-11-10 17:48:24 -080013import bsn_tlv
Rich Lane2e079da2014-10-29 15:30:24 -070014import meter_band
15import table_mod_prop
16import instruction
17import queue_desc_prop
18import oxm
19import bundle_prop
20import common
21import instruction_id
22import action
23import role_prop
24import message
25import queue_stats_prop
26import port_stats_prop
27import port_mod_prop
28import async_config_prop
29import action_id
30import util
31import loxi.generic_util
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
Rich Lanecb18dbd2014-12-18 10:02:29 -080063 reader = orig_reader.slice(_length, 4)
Rich Lane2e079da2014-10-29 15:30:24 -070064 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 ethernet(port_desc_prop):
81 type = 0
82
83 def __init__(self, curr=None, advertised=None, supported=None, peer=None, curr_speed=None, max_speed=None):
84 if curr != None:
85 self.curr = curr
86 else:
87 self.curr = 0
88 if advertised != None:
89 self.advertised = advertised
90 else:
91 self.advertised = 0
92 if supported != None:
93 self.supported = supported
94 else:
95 self.supported = 0
96 if peer != None:
97 self.peer = peer
98 else:
99 self.peer = 0
100 if curr_speed != None:
101 self.curr_speed = curr_speed
102 else:
103 self.curr_speed = 0
104 if max_speed != None:
105 self.max_speed = max_speed
106 else:
107 self.max_speed = 0
108 return
109
110 def pack(self):
111 packed = []
112 packed.append(struct.pack("!H", self.type))
113 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
114 packed.append('\x00' * 4)
115 packed.append(struct.pack("!L", self.curr))
116 packed.append(struct.pack("!L", self.advertised))
117 packed.append(struct.pack("!L", self.supported))
118 packed.append(struct.pack("!L", self.peer))
119 packed.append(struct.pack("!L", self.curr_speed))
120 packed.append(struct.pack("!L", self.max_speed))
121 length = sum([len(x) for x in packed])
122 packed[1] = struct.pack("!H", length)
123 return ''.join(packed)
124
125 @staticmethod
126 def unpack(reader):
127 obj = ethernet()
128 _type = reader.read("!H")[0]
129 assert(_type == 0)
130 _length = reader.read("!H")[0]
131 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800132 reader = orig_reader.slice(_length, 4)
Rich Lane2e079da2014-10-29 15:30:24 -0700133 reader.skip(4)
134 obj.curr = reader.read("!L")[0]
135 obj.advertised = reader.read("!L")[0]
136 obj.supported = reader.read("!L")[0]
137 obj.peer = reader.read("!L")[0]
138 obj.curr_speed = reader.read("!L")[0]
139 obj.max_speed = reader.read("!L")[0]
140 return obj
141
142 def __eq__(self, other):
143 if type(self) != type(other): return False
144 if self.curr != other.curr: return False
145 if self.advertised != other.advertised: return False
146 if self.supported != other.supported: return False
147 if self.peer != other.peer: return False
148 if self.curr_speed != other.curr_speed: return False
149 if self.max_speed != other.max_speed: return False
150 return True
151
152 def pretty_print(self, q):
153 q.text("ethernet {")
154 with q.group():
155 with q.indent(2):
156 q.breakable()
157 q.text("curr = ");
158 q.text("%#x" % self.curr)
159 q.text(","); q.breakable()
160 q.text("advertised = ");
161 q.text("%#x" % self.advertised)
162 q.text(","); q.breakable()
163 q.text("supported = ");
164 q.text("%#x" % self.supported)
165 q.text(","); q.breakable()
166 q.text("peer = ");
167 q.text("%#x" % self.peer)
168 q.text(","); q.breakable()
169 q.text("curr_speed = ");
170 q.text("%#x" % self.curr_speed)
171 q.text(","); q.breakable()
172 q.text("max_speed = ");
173 q.text("%#x" % self.max_speed)
174 q.breakable()
175 q.text('}')
176
177port_desc_prop.subtypes[0] = ethernet
178
179class experimenter(port_desc_prop):
180 subtypes = {}
181
182 type = 65535
183
184 def __init__(self, experimenter=None, exp_type=None):
185 if experimenter != None:
186 self.experimenter = experimenter
187 else:
188 self.experimenter = 0
189 if exp_type != None:
190 self.exp_type = exp_type
191 else:
192 self.exp_type = 0
193 return
194
195 def pack(self):
196 packed = []
197 packed.append(struct.pack("!H", self.type))
198 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
199 packed.append(struct.pack("!L", self.experimenter))
200 packed.append(struct.pack("!L", self.exp_type))
201 length = sum([len(x) for x in packed])
202 packed[1] = struct.pack("!H", length)
203 return ''.join(packed)
204
205 @staticmethod
206 def unpack(reader):
207 subtype, = reader.peek('!L', 4)
208 subclass = experimenter.subtypes.get(subtype)
209 if subclass:
210 return subclass.unpack(reader)
211
212 obj = experimenter()
213 _type = reader.read("!H")[0]
214 assert(_type == 65535)
215 _length = reader.read("!H")[0]
216 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800217 reader = orig_reader.slice(_length, 4)
Rich Lane2e079da2014-10-29 15:30:24 -0700218 obj.experimenter = reader.read("!L")[0]
219 obj.exp_type = reader.read("!L")[0]
220 return obj
221
222 def __eq__(self, other):
223 if type(self) != type(other): return False
224 if self.experimenter != other.experimenter: return False
225 if self.exp_type != other.exp_type: return False
226 return True
227
228 def pretty_print(self, q):
229 q.text("experimenter {")
230 with q.group():
231 with q.indent(2):
232 q.breakable()
233 q.text("exp_type = ");
234 q.text("%#x" % self.exp_type)
235 q.breakable()
236 q.text('}')
237
238port_desc_prop.subtypes[65535] = experimenter
239
240class optical(port_desc_prop):
241 type = 1
242
243 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):
244 if supported != None:
245 self.supported = supported
246 else:
247 self.supported = 0
248 if tx_min_freq_lmda != None:
249 self.tx_min_freq_lmda = tx_min_freq_lmda
250 else:
251 self.tx_min_freq_lmda = 0
252 if tx_max_freq_lmda != None:
253 self.tx_max_freq_lmda = tx_max_freq_lmda
254 else:
255 self.tx_max_freq_lmda = 0
256 if tx_grid_freq_lmda != None:
257 self.tx_grid_freq_lmda = tx_grid_freq_lmda
258 else:
259 self.tx_grid_freq_lmda = 0
260 if rx_min_freq_lmda != None:
261 self.rx_min_freq_lmda = rx_min_freq_lmda
262 else:
263 self.rx_min_freq_lmda = 0
264 if rx_max_freq_lmda != None:
265 self.rx_max_freq_lmda = rx_max_freq_lmda
266 else:
267 self.rx_max_freq_lmda = 0
268 if rx_grid_freq_lmda != None:
269 self.rx_grid_freq_lmda = rx_grid_freq_lmda
270 else:
271 self.rx_grid_freq_lmda = 0
272 if tx_pwr_min != None:
273 self.tx_pwr_min = tx_pwr_min
274 else:
275 self.tx_pwr_min = 0
276 if tx_pwr_max != None:
277 self.tx_pwr_max = tx_pwr_max
278 else:
279 self.tx_pwr_max = 0
280 return
281
282 def pack(self):
283 packed = []
284 packed.append(struct.pack("!H", self.type))
285 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
286 packed.append('\x00' * 4)
287 packed.append(struct.pack("!L", self.supported))
288 packed.append(struct.pack("!L", self.tx_min_freq_lmda))
289 packed.append(struct.pack("!L", self.tx_max_freq_lmda))
290 packed.append(struct.pack("!L", self.tx_grid_freq_lmda))
291 packed.append(struct.pack("!L", self.rx_min_freq_lmda))
292 packed.append(struct.pack("!L", self.rx_max_freq_lmda))
293 packed.append(struct.pack("!L", self.rx_grid_freq_lmda))
294 packed.append(struct.pack("!L", self.tx_pwr_min))
295 packed.append(struct.pack("!L", self.tx_pwr_max))
296 length = sum([len(x) for x in packed])
297 packed[1] = struct.pack("!H", length)
298 return ''.join(packed)
299
300 @staticmethod
301 def unpack(reader):
302 obj = optical()
303 _type = reader.read("!H")[0]
304 assert(_type == 1)
305 _length = reader.read("!H")[0]
306 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800307 reader = orig_reader.slice(_length, 4)
Rich Lane2e079da2014-10-29 15:30:24 -0700308 reader.skip(4)
309 obj.supported = reader.read("!L")[0]
310 obj.tx_min_freq_lmda = reader.read("!L")[0]
311 obj.tx_max_freq_lmda = reader.read("!L")[0]
312 obj.tx_grid_freq_lmda = reader.read("!L")[0]
313 obj.rx_min_freq_lmda = reader.read("!L")[0]
314 obj.rx_max_freq_lmda = reader.read("!L")[0]
315 obj.rx_grid_freq_lmda = reader.read("!L")[0]
316 obj.tx_pwr_min = reader.read("!L")[0]
317 obj.tx_pwr_max = reader.read("!L")[0]
318 return obj
319
320 def __eq__(self, other):
321 if type(self) != type(other): return False
322 if self.supported != other.supported: return False
323 if self.tx_min_freq_lmda != other.tx_min_freq_lmda: return False
324 if self.tx_max_freq_lmda != other.tx_max_freq_lmda: return False
325 if self.tx_grid_freq_lmda != other.tx_grid_freq_lmda: return False
326 if self.rx_min_freq_lmda != other.rx_min_freq_lmda: return False
327 if self.rx_max_freq_lmda != other.rx_max_freq_lmda: return False
328 if self.rx_grid_freq_lmda != other.rx_grid_freq_lmda: return False
329 if self.tx_pwr_min != other.tx_pwr_min: return False
330 if self.tx_pwr_max != other.tx_pwr_max: return False
331 return True
332
333 def pretty_print(self, q):
334 q.text("optical {")
335 with q.group():
336 with q.indent(2):
337 q.breakable()
338 q.text("supported = ");
339 q.text("%#x" % self.supported)
340 q.text(","); q.breakable()
341 q.text("tx_min_freq_lmda = ");
342 q.text("%#x" % self.tx_min_freq_lmda)
343 q.text(","); q.breakable()
344 q.text("tx_max_freq_lmda = ");
345 q.text("%#x" % self.tx_max_freq_lmda)
346 q.text(","); q.breakable()
347 q.text("tx_grid_freq_lmda = ");
348 q.text("%#x" % self.tx_grid_freq_lmda)
349 q.text(","); q.breakable()
350 q.text("rx_min_freq_lmda = ");
351 q.text("%#x" % self.rx_min_freq_lmda)
352 q.text(","); q.breakable()
353 q.text("rx_max_freq_lmda = ");
354 q.text("%#x" % self.rx_max_freq_lmda)
355 q.text(","); q.breakable()
356 q.text("rx_grid_freq_lmda = ");
357 q.text("%#x" % self.rx_grid_freq_lmda)
358 q.text(","); q.breakable()
359 q.text("tx_pwr_min = ");
360 q.text("%#x" % self.tx_pwr_min)
361 q.text(","); q.breakable()
362 q.text("tx_pwr_max = ");
363 q.text("%#x" % self.tx_pwr_max)
364 q.breakable()
365 q.text('}')
366
367port_desc_prop.subtypes[1] = optical
368
369