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