blob: 52a33457b76ea618ea47139bc5937ea36424a558 [file] [log] [blame]
Rich Lane7dcdf022013-12-11 14:45:27 -08001# 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 common
13import action
14import instruction
15import oxm
16import action_id
17import instruction_id
18import meter_band
Rich Lane5454b682014-01-14 17:07:36 -080019import bsn_tlv
Rich Lane7dcdf022013-12-11 14:45:27 -080020import util
21import loxi.generic_util
22
23class instruction_id(loxi.OFObject):
24 subtypes = {}
25
26 @staticmethod
27 def unpack(reader):
28 subtype, = reader.peek('!H', 0)
29 try:
30 subclass = instruction_id.subtypes[subtype]
31 except KeyError:
32 raise loxi.ProtocolError("unknown instruction_id subtype %#x" % subtype)
33 return subclass.unpack(reader)
34
35
36class apply_actions(instruction_id):
37 type = 4
38
39 def __init__(self):
40 return
41
42 def pack(self):
43 packed = []
44 packed.append(struct.pack("!H", self.type))
45 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
46 packed.append('\x00' * 4)
47 length = sum([len(x) for x in packed])
48 packed[1] = struct.pack("!H", length)
49 return ''.join(packed)
50
51 @staticmethod
52 def unpack(reader):
53 obj = apply_actions()
54 _type = reader.read("!H")[0]
55 assert(_type == 4)
56 _len = reader.read("!H")[0]
57 orig_reader = reader
58 reader = orig_reader.slice(_len - (2 + 2))
59 reader.skip(4)
60 return obj
61
62 def __eq__(self, other):
63 if type(self) != type(other): return False
64 return True
65
66 def pretty_print(self, q):
67 q.text("apply_actions {")
68 with q.group():
69 with q.indent(2):
70 q.breakable()
71 q.breakable()
72 q.text('}')
73
74instruction_id.subtypes[4] = apply_actions
75
76class experimenter(instruction_id):
77 subtypes = {}
78
79 @staticmethod
80 def unpack(reader):
81 subtype, = reader.peek('!L', 4)
82 try:
83 subclass = experimenter.subtypes[subtype]
84 except KeyError:
85 raise loxi.ProtocolError("unknown experimenter instruction_id subtype %#x" % subtype)
86 return subclass.unpack(reader)
87
88instruction_id.subtypes[65535] = experimenter
89
90class bsn(experimenter):
91 subtypes = {}
92
93 @staticmethod
94 def unpack(reader):
95 subtype, = reader.peek('!L', 8)
96 try:
97 subclass = bsn.subtypes[subtype]
98 except KeyError:
99 raise loxi.ProtocolError("unknown bsn experimenter instruction_id subtype %#x" % subtype)
100 return subclass.unpack(reader)
101
102experimenter.subtypes[6035143] = bsn
103
Rich Lane5454b682014-01-14 17:07:36 -0800104class bsn_arp_offload(bsn):
105 type = 65535
106 experimenter = 6035143
107 subtype = 1
108
109 def __init__(self):
110 return
111
112 def pack(self):
113 packed = []
114 packed.append(struct.pack("!H", self.type))
115 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
116 packed.append(struct.pack("!L", self.experimenter))
117 packed.append(struct.pack("!L", self.subtype))
118 packed.append('\x00' * 4)
119 length = sum([len(x) for x in packed])
120 packed[1] = struct.pack("!H", length)
121 return ''.join(packed)
122
123 @staticmethod
124 def unpack(reader):
125 obj = bsn_arp_offload()
126 _type = reader.read("!H")[0]
127 assert(_type == 65535)
128 _len = reader.read("!H")[0]
129 orig_reader = reader
130 reader = orig_reader.slice(_len - (2 + 2))
131 _experimenter = reader.read("!L")[0]
132 assert(_experimenter == 6035143)
133 _subtype = reader.read("!L")[0]
134 assert(_subtype == 1)
135 reader.skip(4)
136 return obj
137
138 def __eq__(self, other):
139 if type(self) != type(other): return False
140 return True
141
142 def pretty_print(self, q):
143 q.text("bsn_arp_offload {")
144 with q.group():
145 with q.indent(2):
146 q.breakable()
147 q.breakable()
148 q.text('}')
149
150bsn.subtypes[1] = bsn_arp_offload
151
Rich Lane7dcdf022013-12-11 14:45:27 -0800152class bsn_disable_src_mac_check(bsn):
153 type = 65535
154 experimenter = 6035143
155 subtype = 0
156
157 def __init__(self):
158 return
159
160 def pack(self):
161 packed = []
162 packed.append(struct.pack("!H", self.type))
163 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
164 packed.append(struct.pack("!L", self.experimenter))
165 packed.append(struct.pack("!L", self.subtype))
166 packed.append('\x00' * 4)
167 length = sum([len(x) for x in packed])
168 packed[1] = struct.pack("!H", length)
169 return ''.join(packed)
170
171 @staticmethod
172 def unpack(reader):
173 obj = bsn_disable_src_mac_check()
174 _type = reader.read("!H")[0]
175 assert(_type == 65535)
176 _len = reader.read("!H")[0]
177 orig_reader = reader
178 reader = orig_reader.slice(_len - (2 + 2))
179 _experimenter = reader.read("!L")[0]
180 assert(_experimenter == 6035143)
181 _subtype = reader.read("!L")[0]
182 assert(_subtype == 0)
183 reader.skip(4)
184 return obj
185
186 def __eq__(self, other):
187 if type(self) != type(other): return False
188 return True
189
190 def pretty_print(self, q):
191 q.text("bsn_disable_src_mac_check {")
192 with q.group():
193 with q.indent(2):
194 q.breakable()
195 q.breakable()
196 q.text('}')
197
198bsn.subtypes[0] = bsn_disable_src_mac_check
199
200class clear_actions(instruction_id):
201 type = 5
202
203 def __init__(self):
204 return
205
206 def pack(self):
207 packed = []
208 packed.append(struct.pack("!H", self.type))
209 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
210 packed.append('\x00' * 4)
211 length = sum([len(x) for x in packed])
212 packed[1] = struct.pack("!H", length)
213 return ''.join(packed)
214
215 @staticmethod
216 def unpack(reader):
217 obj = clear_actions()
218 _type = reader.read("!H")[0]
219 assert(_type == 5)
220 _len = reader.read("!H")[0]
221 orig_reader = reader
222 reader = orig_reader.slice(_len - (2 + 2))
223 reader.skip(4)
224 return obj
225
226 def __eq__(self, other):
227 if type(self) != type(other): return False
228 return True
229
230 def pretty_print(self, q):
231 q.text("clear_actions {")
232 with q.group():
233 with q.indent(2):
234 q.breakable()
235 q.breakable()
236 q.text('}')
237
238instruction_id.subtypes[5] = clear_actions
239
240class goto_table(instruction_id):
241 type = 1
242
243 def __init__(self):
244 return
245
246 def pack(self):
247 packed = []
248 packed.append(struct.pack("!H", self.type))
249 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
250 packed.append('\x00' * 3)
251 length = sum([len(x) for x in packed])
252 packed[1] = struct.pack("!H", length)
253 return ''.join(packed)
254
255 @staticmethod
256 def unpack(reader):
257 obj = goto_table()
258 _type = reader.read("!H")[0]
259 assert(_type == 1)
260 _len = reader.read("!H")[0]
261 orig_reader = reader
262 reader = orig_reader.slice(_len - (2 + 2))
263 reader.skip(3)
264 return obj
265
266 def __eq__(self, other):
267 if type(self) != type(other): return False
268 return True
269
270 def pretty_print(self, q):
271 q.text("goto_table {")
272 with q.group():
273 with q.indent(2):
274 q.breakable()
275 q.breakable()
276 q.text('}')
277
278instruction_id.subtypes[1] = goto_table
279
280class meter(instruction_id):
281 type = 6
282
283 def __init__(self):
284 return
285
286 def pack(self):
287 packed = []
288 packed.append(struct.pack("!H", self.type))
289 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
290 length = sum([len(x) for x in packed])
291 packed[1] = struct.pack("!H", length)
292 return ''.join(packed)
293
294 @staticmethod
295 def unpack(reader):
296 obj = meter()
297 _type = reader.read("!H")[0]
298 assert(_type == 6)
299 _len = reader.read("!H")[0]
300 orig_reader = reader
301 reader = orig_reader.slice(_len - (2 + 2))
302 return obj
303
304 def __eq__(self, other):
305 if type(self) != type(other): return False
306 return True
307
308 def pretty_print(self, q):
309 q.text("meter {")
310 with q.group():
311 with q.indent(2):
312 q.breakable()
313 q.breakable()
314 q.text('}')
315
316instruction_id.subtypes[6] = meter
317
318class write_actions(instruction_id):
319 type = 3
320
321 def __init__(self):
322 return
323
324 def pack(self):
325 packed = []
326 packed.append(struct.pack("!H", self.type))
327 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
328 packed.append('\x00' * 4)
329 length = sum([len(x) for x in packed])
330 packed[1] = struct.pack("!H", length)
331 return ''.join(packed)
332
333 @staticmethod
334 def unpack(reader):
335 obj = write_actions()
336 _type = reader.read("!H")[0]
337 assert(_type == 3)
338 _len = reader.read("!H")[0]
339 orig_reader = reader
340 reader = orig_reader.slice(_len - (2 + 2))
341 reader.skip(4)
342 return obj
343
344 def __eq__(self, other):
345 if type(self) != type(other): return False
346 return True
347
348 def pretty_print(self, q):
349 q.text("write_actions {")
350 with q.group():
351 with q.indent(2):
352 q.breakable()
353 q.breakable()
354 q.text('}')
355
356instruction_id.subtypes[3] = write_actions
357
358class write_metadata(instruction_id):
359 type = 2
360
361 def __init__(self):
362 return
363
364 def pack(self):
365 packed = []
366 packed.append(struct.pack("!H", self.type))
367 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
368 packed.append('\x00' * 4)
369 length = sum([len(x) for x in packed])
370 packed[1] = struct.pack("!H", length)
371 return ''.join(packed)
372
373 @staticmethod
374 def unpack(reader):
375 obj = write_metadata()
376 _type = reader.read("!H")[0]
377 assert(_type == 2)
378 _len = reader.read("!H")[0]
379 orig_reader = reader
380 reader = orig_reader.slice(_len - (2 + 2))
381 reader.skip(4)
382 return obj
383
384 def __eq__(self, other):
385 if type(self) != type(other): return False
386 return True
387
388 def pretty_print(self, q):
389 q.text("write_metadata {")
390 with q.group():
391 with q.indent(2):
392 q.breakable()
393 q.breakable()
394 q.text('}')
395
396instruction_id.subtypes[2] = write_metadata
397
398