blob: 5580f27643651521a64b3c894953c2c6f29ac016 [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
Rich Lane95f7fc92014-01-27 17:08:16 -080026
27 def __init__(self, type=None):
28 if type != None:
29 self.type = type
30 else:
31 self.type = 0
32 return
33
34 def pack(self):
35 packed = []
36 packed.append(struct.pack("!H", self.type))
37 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
38 length = sum([len(x) for x in packed])
39 packed[1] = struct.pack("!H", length)
40 return ''.join(packed)
41
Rich Lane7dcdf022013-12-11 14:45:27 -080042 @staticmethod
43 def unpack(reader):
44 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -080045 subclass = instruction_id.subtypes.get(subtype)
46 if subclass:
47 return subclass.unpack(reader)
48
49 obj = instruction_id()
50 obj.type = reader.read("!H")[0]
51 _len = reader.read("!H")[0]
52 orig_reader = reader
53 reader = orig_reader.slice(_len - (2 + 2))
54 return obj
55
56 def __eq__(self, other):
57 if type(self) != type(other): return False
58 if self.type != other.type: return False
59 return True
60
61 def pretty_print(self, q):
62 q.text("instruction_id {")
63 with q.group():
64 with q.indent(2):
65 q.breakable()
66 q.breakable()
67 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -080068
69
70class apply_actions(instruction_id):
71 type = 4
72
73 def __init__(self):
74 return
75
76 def pack(self):
77 packed = []
78 packed.append(struct.pack("!H", self.type))
79 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
80 packed.append('\x00' * 4)
81 length = sum([len(x) for x in packed])
82 packed[1] = struct.pack("!H", length)
83 return ''.join(packed)
84
85 @staticmethod
86 def unpack(reader):
87 obj = apply_actions()
88 _type = reader.read("!H")[0]
89 assert(_type == 4)
90 _len = reader.read("!H")[0]
91 orig_reader = reader
92 reader = orig_reader.slice(_len - (2 + 2))
93 reader.skip(4)
94 return obj
95
96 def __eq__(self, other):
97 if type(self) != type(other): return False
98 return True
99
100 def pretty_print(self, q):
101 q.text("apply_actions {")
102 with q.group():
103 with q.indent(2):
104 q.breakable()
105 q.breakable()
106 q.text('}')
107
108instruction_id.subtypes[4] = apply_actions
109
110class experimenter(instruction_id):
111 subtypes = {}
112
Rich Lane95f7fc92014-01-27 17:08:16 -0800113 type = 65535
114
115 def __init__(self, experimenter=None):
116 if experimenter != None:
117 self.experimenter = experimenter
118 else:
119 self.experimenter = 0
120 return
121
122 def pack(self):
123 packed = []
124 packed.append(struct.pack("!H", self.type))
125 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
126 packed.append(struct.pack("!L", self.experimenter))
127 length = sum([len(x) for x in packed])
128 packed[1] = struct.pack("!H", length)
129 return ''.join(packed)
130
Rich Lane7dcdf022013-12-11 14:45:27 -0800131 @staticmethod
132 def unpack(reader):
133 subtype, = reader.peek('!L', 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800134 subclass = experimenter.subtypes.get(subtype)
135 if subclass:
136 return subclass.unpack(reader)
137
138 obj = experimenter()
139 _type = reader.read("!H")[0]
140 assert(_type == 65535)
141 _len = reader.read("!H")[0]
142 orig_reader = reader
143 reader = orig_reader.slice(_len - (2 + 2))
144 obj.experimenter = reader.read("!L")[0]
145 return obj
146
147 def __eq__(self, other):
148 if type(self) != type(other): return False
149 if self.experimenter != other.experimenter: return False
150 return True
151
152 def pretty_print(self, q):
153 q.text("experimenter {")
154 with q.group():
155 with q.indent(2):
156 q.breakable()
157 q.breakable()
158 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800159
160instruction_id.subtypes[65535] = experimenter
161
162class bsn(experimenter):
163 subtypes = {}
164
Rich Lane95f7fc92014-01-27 17:08:16 -0800165 type = 65535
166 experimenter = 6035143
167
168 def __init__(self, subtype=None):
169 if subtype != None:
170 self.subtype = subtype
171 else:
172 self.subtype = 0
173 return
174
175 def pack(self):
176 packed = []
177 packed.append(struct.pack("!H", self.type))
178 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
179 packed.append(struct.pack("!L", self.experimenter))
180 packed.append(struct.pack("!L", self.subtype))
181 packed.append('\x00' * 4)
182 length = sum([len(x) for x in packed])
183 packed[1] = struct.pack("!H", length)
184 return ''.join(packed)
185
Rich Lane7dcdf022013-12-11 14:45:27 -0800186 @staticmethod
187 def unpack(reader):
188 subtype, = reader.peek('!L', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800189 subclass = bsn.subtypes.get(subtype)
190 if subclass:
191 return subclass.unpack(reader)
192
193 obj = bsn()
194 _type = reader.read("!H")[0]
195 assert(_type == 65535)
196 _len = reader.read("!H")[0]
197 orig_reader = reader
198 reader = orig_reader.slice(_len - (2 + 2))
199 _experimenter = reader.read("!L")[0]
200 assert(_experimenter == 6035143)
201 obj.subtype = reader.read("!L")[0]
202 reader.skip(4)
203 return obj
204
205 def __eq__(self, other):
206 if type(self) != type(other): return False
207 if self.subtype != other.subtype: return False
208 return True
209
210 def pretty_print(self, q):
211 q.text("bsn {")
212 with q.group():
213 with q.indent(2):
214 q.breakable()
215 q.breakable()
216 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800217
218experimenter.subtypes[6035143] = bsn
219
Rich Lane5454b682014-01-14 17:07:36 -0800220class bsn_arp_offload(bsn):
221 type = 65535
222 experimenter = 6035143
223 subtype = 1
224
225 def __init__(self):
226 return
227
228 def pack(self):
229 packed = []
230 packed.append(struct.pack("!H", self.type))
231 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
232 packed.append(struct.pack("!L", self.experimenter))
233 packed.append(struct.pack("!L", self.subtype))
234 packed.append('\x00' * 4)
235 length = sum([len(x) for x in packed])
236 packed[1] = struct.pack("!H", length)
237 return ''.join(packed)
238
239 @staticmethod
240 def unpack(reader):
241 obj = bsn_arp_offload()
242 _type = reader.read("!H")[0]
243 assert(_type == 65535)
244 _len = reader.read("!H")[0]
245 orig_reader = reader
246 reader = orig_reader.slice(_len - (2 + 2))
247 _experimenter = reader.read("!L")[0]
248 assert(_experimenter == 6035143)
249 _subtype = reader.read("!L")[0]
250 assert(_subtype == 1)
251 reader.skip(4)
252 return obj
253
254 def __eq__(self, other):
255 if type(self) != type(other): return False
256 return True
257
258 def pretty_print(self, q):
259 q.text("bsn_arp_offload {")
260 with q.group():
261 with q.indent(2):
262 q.breakable()
263 q.breakable()
264 q.text('}')
265
266bsn.subtypes[1] = bsn_arp_offload
267
Rich Lane1b75abf2014-02-05 11:23:20 -0800268class bsn_dhcp_offload(bsn):
269 type = 65535
270 experimenter = 6035143
271 subtype = 2
272
273 def __init__(self):
274 return
275
276 def pack(self):
277 packed = []
278 packed.append(struct.pack("!H", self.type))
279 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
280 packed.append(struct.pack("!L", self.experimenter))
281 packed.append(struct.pack("!L", self.subtype))
282 packed.append('\x00' * 4)
283 length = sum([len(x) for x in packed])
284 packed[1] = struct.pack("!H", length)
285 return ''.join(packed)
286
287 @staticmethod
288 def unpack(reader):
289 obj = bsn_dhcp_offload()
290 _type = reader.read("!H")[0]
291 assert(_type == 65535)
292 _len = reader.read("!H")[0]
293 orig_reader = reader
294 reader = orig_reader.slice(_len - (2 + 2))
295 _experimenter = reader.read("!L")[0]
296 assert(_experimenter == 6035143)
297 _subtype = reader.read("!L")[0]
298 assert(_subtype == 2)
299 reader.skip(4)
300 return obj
301
302 def __eq__(self, other):
303 if type(self) != type(other): return False
304 return True
305
306 def pretty_print(self, q):
307 q.text("bsn_dhcp_offload {")
308 with q.group():
309 with q.indent(2):
310 q.breakable()
311 q.breakable()
312 q.text('}')
313
314bsn.subtypes[2] = bsn_dhcp_offload
315
Rich Lane7dcdf022013-12-11 14:45:27 -0800316class bsn_disable_src_mac_check(bsn):
317 type = 65535
318 experimenter = 6035143
319 subtype = 0
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(struct.pack("!L", self.experimenter))
329 packed.append(struct.pack("!L", self.subtype))
330 packed.append('\x00' * 4)
331 length = sum([len(x) for x in packed])
332 packed[1] = struct.pack("!H", length)
333 return ''.join(packed)
334
335 @staticmethod
336 def unpack(reader):
337 obj = bsn_disable_src_mac_check()
338 _type = reader.read("!H")[0]
339 assert(_type == 65535)
340 _len = reader.read("!H")[0]
341 orig_reader = reader
342 reader = orig_reader.slice(_len - (2 + 2))
343 _experimenter = reader.read("!L")[0]
344 assert(_experimenter == 6035143)
345 _subtype = reader.read("!L")[0]
346 assert(_subtype == 0)
347 reader.skip(4)
348 return obj
349
350 def __eq__(self, other):
351 if type(self) != type(other): return False
352 return True
353
354 def pretty_print(self, q):
355 q.text("bsn_disable_src_mac_check {")
356 with q.group():
357 with q.indent(2):
358 q.breakable()
359 q.breakable()
360 q.text('}')
361
362bsn.subtypes[0] = bsn_disable_src_mac_check
363
364class clear_actions(instruction_id):
365 type = 5
366
367 def __init__(self):
368 return
369
370 def pack(self):
371 packed = []
372 packed.append(struct.pack("!H", self.type))
373 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
374 packed.append('\x00' * 4)
375 length = sum([len(x) for x in packed])
376 packed[1] = struct.pack("!H", length)
377 return ''.join(packed)
378
379 @staticmethod
380 def unpack(reader):
381 obj = clear_actions()
382 _type = reader.read("!H")[0]
383 assert(_type == 5)
384 _len = reader.read("!H")[0]
385 orig_reader = reader
386 reader = orig_reader.slice(_len - (2 + 2))
387 reader.skip(4)
388 return obj
389
390 def __eq__(self, other):
391 if type(self) != type(other): return False
392 return True
393
394 def pretty_print(self, q):
395 q.text("clear_actions {")
396 with q.group():
397 with q.indent(2):
398 q.breakable()
399 q.breakable()
400 q.text('}')
401
402instruction_id.subtypes[5] = clear_actions
403
404class goto_table(instruction_id):
405 type = 1
406
407 def __init__(self):
408 return
409
410 def pack(self):
411 packed = []
412 packed.append(struct.pack("!H", self.type))
413 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
414 packed.append('\x00' * 3)
415 length = sum([len(x) for x in packed])
416 packed[1] = struct.pack("!H", length)
417 return ''.join(packed)
418
419 @staticmethod
420 def unpack(reader):
421 obj = goto_table()
422 _type = reader.read("!H")[0]
423 assert(_type == 1)
424 _len = reader.read("!H")[0]
425 orig_reader = reader
426 reader = orig_reader.slice(_len - (2 + 2))
427 reader.skip(3)
428 return obj
429
430 def __eq__(self, other):
431 if type(self) != type(other): return False
432 return True
433
434 def pretty_print(self, q):
435 q.text("goto_table {")
436 with q.group():
437 with q.indent(2):
438 q.breakable()
439 q.breakable()
440 q.text('}')
441
442instruction_id.subtypes[1] = goto_table
443
444class meter(instruction_id):
445 type = 6
446
447 def __init__(self):
448 return
449
450 def pack(self):
451 packed = []
452 packed.append(struct.pack("!H", self.type))
453 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
454 length = sum([len(x) for x in packed])
455 packed[1] = struct.pack("!H", length)
456 return ''.join(packed)
457
458 @staticmethod
459 def unpack(reader):
460 obj = meter()
461 _type = reader.read("!H")[0]
462 assert(_type == 6)
463 _len = reader.read("!H")[0]
464 orig_reader = reader
465 reader = orig_reader.slice(_len - (2 + 2))
466 return obj
467
468 def __eq__(self, other):
469 if type(self) != type(other): return False
470 return True
471
472 def pretty_print(self, q):
473 q.text("meter {")
474 with q.group():
475 with q.indent(2):
476 q.breakable()
477 q.breakable()
478 q.text('}')
479
480instruction_id.subtypes[6] = meter
481
482class write_actions(instruction_id):
483 type = 3
484
485 def __init__(self):
486 return
487
488 def pack(self):
489 packed = []
490 packed.append(struct.pack("!H", self.type))
491 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
492 packed.append('\x00' * 4)
493 length = sum([len(x) for x in packed])
494 packed[1] = struct.pack("!H", length)
495 return ''.join(packed)
496
497 @staticmethod
498 def unpack(reader):
499 obj = write_actions()
500 _type = reader.read("!H")[0]
501 assert(_type == 3)
502 _len = reader.read("!H")[0]
503 orig_reader = reader
504 reader = orig_reader.slice(_len - (2 + 2))
505 reader.skip(4)
506 return obj
507
508 def __eq__(self, other):
509 if type(self) != type(other): return False
510 return True
511
512 def pretty_print(self, q):
513 q.text("write_actions {")
514 with q.group():
515 with q.indent(2):
516 q.breakable()
517 q.breakable()
518 q.text('}')
519
520instruction_id.subtypes[3] = write_actions
521
522class write_metadata(instruction_id):
523 type = 2
524
525 def __init__(self):
526 return
527
528 def pack(self):
529 packed = []
530 packed.append(struct.pack("!H", self.type))
531 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
532 packed.append('\x00' * 4)
533 length = sum([len(x) for x in packed])
534 packed[1] = struct.pack("!H", length)
535 return ''.join(packed)
536
537 @staticmethod
538 def unpack(reader):
539 obj = write_metadata()
540 _type = reader.read("!H")[0]
541 assert(_type == 2)
542 _len = reader.read("!H")[0]
543 orig_reader = reader
544 reader = orig_reader.slice(_len - (2 + 2))
545 reader.skip(4)
546 return obj
547
548 def __eq__(self, other):
549 if type(self) != type(other): return False
550 return True
551
552 def pretty_print(self, q):
553 q.text("write_metadata {")
554 with q.group():
555 with q.indent(2):
556 q.breakable()
557 q.breakable()
558 q.text('}')
559
560instruction_id.subtypes[2] = write_metadata
561
562