blob: ce9e448cd5776a78529d6a4b9fe21713859cea45 [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_mod_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_mod_prop.subtypes.get(subtype)
56 if subclass:
57 return subclass.unpack(reader)
58
59 obj = port_mod_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_mod_prop {")
73 with q.group():
74 with q.indent(2):
75 q.breakable()
76 q.breakable()
77 q.text('}')
78
79
80class ethernet(port_mod_prop):
81 type = 0
82
83 def __init__(self, advertise=None):
84 if advertise != None:
85 self.advertise = advertise
86 else:
87 self.advertise = 0
88 return
89
90 def pack(self):
91 packed = []
92 packed.append(struct.pack("!H", self.type))
93 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
94 packed.append(struct.pack("!L", self.advertise))
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 obj.advertise = reader.read("!L")[0]
108 return obj
109
110 def __eq__(self, other):
111 if type(self) != type(other): return False
112 if self.advertise != other.advertise: return False
113 return True
114
115 def pretty_print(self, q):
116 q.text("ethernet {")
117 with q.group():
118 with q.indent(2):
119 q.breakable()
120 q.text("advertise = ");
121 q.text("%#x" % self.advertise)
122 q.breakable()
123 q.text('}')
124
125port_mod_prop.subtypes[0] = ethernet
126
127class experimenter(port_mod_prop):
128 subtypes = {}
129
130 type = 65535
131
132 def __init__(self, experimenter=None, exp_type=None):
133 if experimenter != None:
134 self.experimenter = experimenter
135 else:
136 self.experimenter = 0
137 if exp_type != None:
138 self.exp_type = exp_type
139 else:
140 self.exp_type = 0
141 return
142
143 def pack(self):
144 packed = []
145 packed.append(struct.pack("!H", self.type))
146 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
147 packed.append(struct.pack("!L", self.experimenter))
148 packed.append(struct.pack("!L", self.exp_type))
149 length = sum([len(x) for x in packed])
150 packed[1] = struct.pack("!H", length)
151 return ''.join(packed)
152
153 @staticmethod
154 def unpack(reader):
155 subtype, = reader.peek('!L', 4)
156 subclass = experimenter.subtypes.get(subtype)
157 if subclass:
158 return subclass.unpack(reader)
159
160 obj = experimenter()
161 _type = reader.read("!H")[0]
162 assert(_type == 65535)
163 _length = reader.read("!H")[0]
164 orig_reader = reader
165 reader = orig_reader.slice(_length, 4)
166 obj.experimenter = reader.read("!L")[0]
167 obj.exp_type = reader.read("!L")[0]
168 return obj
169
170 def __eq__(self, other):
171 if type(self) != type(other): return False
172 if self.experimenter != other.experimenter: return False
173 if self.exp_type != other.exp_type: return False
174 return True
175
176 def pretty_print(self, q):
177 q.text("experimenter {")
178 with q.group():
179 with q.indent(2):
180 q.breakable()
181 q.text("exp_type = ");
182 q.text("%#x" % self.exp_type)
183 q.breakable()
184 q.text('}')
185
186port_mod_prop.subtypes[65535] = experimenter
187
188class optical(port_mod_prop):
189 type = 1
190
191 def __init__(self, configure=None, freq_ldma=None, fl_offset=None, grid_span=None, tx_pwr=None):
192 if configure != None:
193 self.configure = configure
194 else:
195 self.configure = 0
196 if freq_ldma != None:
197 self.freq_ldma = freq_ldma
198 else:
199 self.freq_ldma = 0
200 if fl_offset != None:
201 self.fl_offset = fl_offset
202 else:
203 self.fl_offset = 0
204 if grid_span != None:
205 self.grid_span = grid_span
206 else:
207 self.grid_span = 0
208 if tx_pwr != None:
209 self.tx_pwr = tx_pwr
210 else:
211 self.tx_pwr = 0
212 return
213
214 def pack(self):
215 packed = []
216 packed.append(struct.pack("!H", self.type))
217 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
218 packed.append(struct.pack("!L", self.configure))
219 packed.append(struct.pack("!L", self.freq_ldma))
220 packed.append(struct.pack("!L", self.fl_offset))
221 packed.append(struct.pack("!L", self.grid_span))
222 packed.append(struct.pack("!L", self.tx_pwr))
223 length = sum([len(x) for x in packed])
224 packed[1] = struct.pack("!H", length)
225 return ''.join(packed)
226
227 @staticmethod
228 def unpack(reader):
229 obj = optical()
230 _type = reader.read("!H")[0]
231 assert(_type == 1)
232 _length = reader.read("!H")[0]
233 orig_reader = reader
234 reader = orig_reader.slice(_length, 4)
235 obj.configure = reader.read("!L")[0]
236 obj.freq_ldma = reader.read("!L")[0]
237 obj.fl_offset = reader.read("!L")[0]
238 obj.grid_span = reader.read("!L")[0]
239 obj.tx_pwr = reader.read("!L")[0]
240 return obj
241
242 def __eq__(self, other):
243 if type(self) != type(other): return False
244 if self.configure != other.configure: return False
245 if self.freq_ldma != other.freq_ldma: return False
246 if self.fl_offset != other.fl_offset: return False
247 if self.grid_span != other.grid_span: return False
248 if self.tx_pwr != other.tx_pwr: return False
249 return True
250
251 def pretty_print(self, q):
252 q.text("optical {")
253 with q.group():
254 with q.indent(2):
255 q.breakable()
256 q.text("configure = ");
257 q.text("%#x" % self.configure)
258 q.text(","); q.breakable()
259 q.text("freq_ldma = ");
260 q.text("%#x" % self.freq_ldma)
261 q.text(","); q.breakable()
262 q.text("fl_offset = ");
263 q.text("%#x" % self.fl_offset)
264 q.text(","); q.breakable()
265 q.text("grid_span = ");
266 q.text("%#x" % self.grid_span)
267 q.text(","); q.breakable()
268 q.text("tx_pwr = ");
269 q.text("%#x" % self.tx_pwr)
270 q.breakable()
271 q.text('}')
272
273port_mod_prop.subtypes[1] = optical
274
275