blob: 5cfd754caf4eb8948872b8ce7d3c5ecfe5090141 [file] [log] [blame]
Rich Lanec2ee4b82013-04-24 17:12:38 -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.
Dan Talaycof6202252013-07-02 01:00:29 -07004# See the file LICENSE.pyloxi which should have been included in the source distribution
Rich Lanec2ee4b82013-04-24 17:12:38 -07005
Rich Lane7dcdf022013-12-11 14:45:27 -08006# Automatically generated by LOXI from template module.py
Rich Lanec2ee4b82013-04-24 17:12:38 -07007# Do not modify
8
9import struct
Rich Lane7dcdf022013-12-11 14:45:27 -080010import loxi
Rich Lanec2ee4b82013-04-24 17:12:38 -070011import const
Rich Lane7dcdf022013-12-11 14:45:27 -080012import action
Rich Lane7dcdf022013-12-11 14:45:27 -080013import oxm
Harshmeet Singh1db46332014-10-14 16:29:13 -070014import message
15import instruction
16import common
Rich Lanec2ee4b82013-04-24 17:12:38 -070017import util
18import loxi.generic_util
Rich Lanec2ee4b82013-04-24 17:12:38 -070019
Rich Lane7dcdf022013-12-11 14:45:27 -080020class action(loxi.OFObject):
21 subtypes = {}
Rich Lanec2ee4b82013-04-24 17:12:38 -070022
Rich Lane95f7fc92014-01-27 17:08:16 -080023
24 def __init__(self, type=None):
25 if type != None:
26 self.type = type
27 else:
28 self.type = 0
29 return
30
31 def pack(self):
32 packed = []
33 packed.append(struct.pack("!H", self.type))
34 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
35 packed.append('\x00' * 4)
36 length = sum([len(x) for x in packed])
37 packed[1] = struct.pack("!H", length)
38 return ''.join(packed)
39
Rich Lane7dcdf022013-12-11 14:45:27 -080040 @staticmethod
41 def unpack(reader):
42 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -080043 subclass = action.subtypes.get(subtype)
44 if subclass:
45 return subclass.unpack(reader)
46
47 obj = action()
48 obj.type = reader.read("!H")[0]
49 _len = reader.read("!H")[0]
50 orig_reader = reader
51 reader = orig_reader.slice(_len - (2 + 2))
52 reader.skip(4)
53 return obj
54
55 def __eq__(self, other):
56 if type(self) != type(other): return False
57 if self.type != other.type: return False
58 return True
59
60 def pretty_print(self, q):
61 q.text("action {")
62 with q.group():
63 with q.indent(2):
64 q.breakable()
65 q.breakable()
66 q.text('}')
Rich Lanec2ee4b82013-04-24 17:12:38 -070067
Rich Lane7dcdf022013-12-11 14:45:27 -080068
69class experimenter(action):
70 subtypes = {}
71
Rich Lane95f7fc92014-01-27 17:08:16 -080072 type = 65535
73
74 def __init__(self, experimenter=None, data=None):
75 if experimenter != None:
76 self.experimenter = experimenter
77 else:
78 self.experimenter = 0
79 if data != None:
80 self.data = data
81 else:
82 self.data = ''
83 return
84
85 def pack(self):
86 packed = []
87 packed.append(struct.pack("!H", self.type))
88 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
89 packed.append(struct.pack("!L", self.experimenter))
90 packed.append(self.data)
91 length = sum([len(x) for x in packed])
92 packed.append(loxi.generic_util.pad_to(8, length))
93 length += len(packed[-1])
94 packed[1] = struct.pack("!H", length)
95 return ''.join(packed)
96
Rich Lane7dcdf022013-12-11 14:45:27 -080097 @staticmethod
98 def unpack(reader):
99 subtype, = reader.peek('!L', 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800100 subclass = experimenter.subtypes.get(subtype)
101 if subclass:
102 return subclass.unpack(reader)
103
104 obj = experimenter()
105 _type = reader.read("!H")[0]
106 assert(_type == 65535)
107 _len = reader.read("!H")[0]
108 orig_reader = reader
109 reader = orig_reader.slice(_len - (2 + 2))
110 obj.experimenter = reader.read("!L")[0]
111 obj.data = str(reader.read_all())
112 return obj
113
114 def __eq__(self, other):
115 if type(self) != type(other): return False
116 if self.experimenter != other.experimenter: return False
117 if self.data != other.data: return False
118 return True
119
120 def pretty_print(self, q):
121 q.text("experimenter {")
122 with q.group():
123 with q.indent(2):
124 q.breakable()
125 q.text("data = ");
126 q.pp(self.data)
127 q.breakable()
128 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800129
130action.subtypes[65535] = experimenter
131
132class bsn(experimenter):
133 subtypes = {}
134
Rich Lane95f7fc92014-01-27 17:08:16 -0800135 type = 65535
136 experimenter = 6035143
137
138 def __init__(self, subtype=None):
139 if subtype != None:
140 self.subtype = subtype
141 else:
142 self.subtype = 0
143 return
144
145 def pack(self):
146 packed = []
147 packed.append(struct.pack("!H", self.type))
148 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
149 packed.append(struct.pack("!L", self.experimenter))
150 packed.append(struct.pack("!L", self.subtype))
151 packed.append('\x00' * 4)
152 length = sum([len(x) for x in packed])
153 packed[1] = struct.pack("!H", length)
154 return ''.join(packed)
155
Rich Lane7dcdf022013-12-11 14:45:27 -0800156 @staticmethod
157 def unpack(reader):
158 subtype, = reader.peek('!L', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800159 subclass = bsn.subtypes.get(subtype)
160 if subclass:
161 return subclass.unpack(reader)
162
163 obj = bsn()
164 _type = reader.read("!H")[0]
165 assert(_type == 65535)
166 _len = reader.read("!H")[0]
167 orig_reader = reader
168 reader = orig_reader.slice(_len - (2 + 2))
169 _experimenter = reader.read("!L")[0]
170 assert(_experimenter == 6035143)
171 obj.subtype = reader.read("!L")[0]
172 reader.skip(4)
173 return obj
174
175 def __eq__(self, other):
176 if type(self) != type(other): return False
177 if self.subtype != other.subtype: return False
178 return True
179
180 def pretty_print(self, q):
181 q.text("bsn {")
182 with q.group():
183 with q.indent(2):
184 q.breakable()
185 q.breakable()
186 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800187
188experimenter.subtypes[6035143] = bsn
189
Rich Lane5587ab12014-06-30 11:19:09 -0700190class bsn_checksum(bsn):
191 type = 65535
192 experimenter = 6035143
193 subtype = 4
194
195 def __init__(self, checksum=None):
196 if checksum != None:
197 self.checksum = checksum
198 else:
199 self.checksum = 0
200 return
201
202 def pack(self):
203 packed = []
204 packed.append(struct.pack("!H", self.type))
205 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
206 packed.append(struct.pack("!L", self.experimenter))
207 packed.append(struct.pack("!L", self.subtype))
208 packed.append(util.pack_checksum_128(self.checksum))
209 length = sum([len(x) for x in packed])
210 packed[1] = struct.pack("!H", length)
211 return ''.join(packed)
212
213 @staticmethod
214 def unpack(reader):
215 obj = bsn_checksum()
216 _type = reader.read("!H")[0]
217 assert(_type == 65535)
218 _len = reader.read("!H")[0]
219 orig_reader = reader
220 reader = orig_reader.slice(_len - (2 + 2))
221 _experimenter = reader.read("!L")[0]
222 assert(_experimenter == 6035143)
223 _subtype = reader.read("!L")[0]
224 assert(_subtype == 4)
225 obj.checksum = util.unpack_checksum_128(reader)
226 return obj
227
228 def __eq__(self, other):
229 if type(self) != type(other): return False
230 if self.checksum != other.checksum: return False
231 return True
232
233 def pretty_print(self, q):
234 q.text("bsn_checksum {")
235 with q.group():
236 with q.indent(2):
237 q.breakable()
238 q.text("checksum = ");
239 q.pp(self.checksum)
240 q.breakable()
241 q.text('}')
242
243bsn.subtypes[4] = bsn_checksum
244
Rich Lane7dcdf022013-12-11 14:45:27 -0800245class bsn_mirror(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700246 type = 65535
247 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -0700248 subtype = 1
249
250 def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None):
251 if dest_port != None:
252 self.dest_port = dest_port
253 else:
254 self.dest_port = 0
255 if vlan_tag != None:
256 self.vlan_tag = vlan_tag
257 else:
258 self.vlan_tag = 0
259 if copy_stage != None:
260 self.copy_stage = copy_stage
261 else:
262 self.copy_stage = 0
263 return
264
265 def pack(self):
266 packed = []
267 packed.append(struct.pack("!H", self.type))
268 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
269 packed.append(struct.pack("!L", self.experimenter))
270 packed.append(struct.pack("!L", self.subtype))
271 packed.append(struct.pack("!L", self.dest_port))
272 packed.append(struct.pack("!L", self.vlan_tag))
273 packed.append(struct.pack("!B", self.copy_stage))
274 packed.append('\x00' * 3)
275 length = sum([len(x) for x in packed])
276 packed[1] = struct.pack("!H", length)
277 return ''.join(packed)
278
279 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800280 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700281 obj = bsn_mirror()
Dan Talaycof6202252013-07-02 01:00:29 -0700282 _type = reader.read("!H")[0]
283 assert(_type == 65535)
284 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800285 orig_reader = reader
286 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700287 _experimenter = reader.read("!L")[0]
288 assert(_experimenter == 6035143)
289 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700290 assert(_subtype == 1)
Dan Talaycof6202252013-07-02 01:00:29 -0700291 obj.dest_port = reader.read("!L")[0]
292 obj.vlan_tag = reader.read("!L")[0]
293 obj.copy_stage = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700294 reader.skip(3)
295 return obj
296
297 def __eq__(self, other):
298 if type(self) != type(other): return False
299 if self.dest_port != other.dest_port: return False
300 if self.vlan_tag != other.vlan_tag: return False
301 if self.copy_stage != other.copy_stage: return False
302 return True
303
Rich Lanec2ee4b82013-04-24 17:12:38 -0700304 def pretty_print(self, q):
305 q.text("bsn_mirror {")
306 with q.group():
307 with q.indent(2):
308 q.breakable()
309 q.text("dest_port = ");
310 q.text("%#x" % self.dest_port)
311 q.text(","); q.breakable()
312 q.text("vlan_tag = ");
313 q.text("%#x" % self.vlan_tag)
314 q.text(","); q.breakable()
315 q.text("copy_stage = ");
316 q.text("%#x" % self.copy_stage)
317 q.breakable()
318 q.text('}')
319
Rich Lane7dcdf022013-12-11 14:45:27 -0800320bsn.subtypes[1] = bsn_mirror
321
322class bsn_set_tunnel_dst(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700323 type = 65535
324 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -0700325 subtype = 2
326
327 def __init__(self, dst=None):
328 if dst != None:
329 self.dst = dst
330 else:
331 self.dst = 0
332 return
333
334 def pack(self):
335 packed = []
336 packed.append(struct.pack("!H", self.type))
337 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
338 packed.append(struct.pack("!L", self.experimenter))
339 packed.append(struct.pack("!L", self.subtype))
340 packed.append(struct.pack("!L", self.dst))
341 length = sum([len(x) for x in packed])
342 packed[1] = struct.pack("!H", length)
343 return ''.join(packed)
344
345 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800346 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700347 obj = bsn_set_tunnel_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700348 _type = reader.read("!H")[0]
349 assert(_type == 65535)
350 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800351 orig_reader = reader
352 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700353 _experimenter = reader.read("!L")[0]
354 assert(_experimenter == 6035143)
355 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700356 assert(_subtype == 2)
Dan Talaycof6202252013-07-02 01:00:29 -0700357 obj.dst = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700358 return obj
359
360 def __eq__(self, other):
361 if type(self) != type(other): return False
362 if self.dst != other.dst: return False
363 return True
364
Rich Lanec2ee4b82013-04-24 17:12:38 -0700365 def pretty_print(self, q):
366 q.text("bsn_set_tunnel_dst {")
367 with q.group():
368 with q.indent(2):
369 q.breakable()
370 q.text("dst = ");
371 q.text("%#x" % self.dst)
372 q.breakable()
373 q.text('}')
374
Rich Lane7dcdf022013-12-11 14:45:27 -0800375bsn.subtypes[2] = bsn_set_tunnel_dst
376
377class copy_ttl_in(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700378 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -0700379
380 def __init__(self):
381 return
382
383 def pack(self):
384 packed = []
385 packed.append(struct.pack("!H", self.type))
386 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
387 packed.append('\x00' * 4)
388 length = sum([len(x) for x in packed])
389 packed[1] = struct.pack("!H", length)
390 return ''.join(packed)
391
392 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800393 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700394 obj = copy_ttl_in()
Dan Talaycof6202252013-07-02 01:00:29 -0700395 _type = reader.read("!H")[0]
396 assert(_type == 12)
397 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800398 orig_reader = reader
399 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700400 reader.skip(4)
401 return obj
402
403 def __eq__(self, other):
404 if type(self) != type(other): return False
405 return True
406
Rich Lanec2ee4b82013-04-24 17:12:38 -0700407 def pretty_print(self, q):
408 q.text("copy_ttl_in {")
409 with q.group():
410 with q.indent(2):
411 q.breakable()
412 q.breakable()
413 q.text('}')
414
Rich Lane7dcdf022013-12-11 14:45:27 -0800415action.subtypes[12] = copy_ttl_in
416
417class copy_ttl_out(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700418 type = 11
Rich Lanec2ee4b82013-04-24 17:12:38 -0700419
420 def __init__(self):
421 return
422
423 def pack(self):
424 packed = []
425 packed.append(struct.pack("!H", self.type))
426 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
427 packed.append('\x00' * 4)
428 length = sum([len(x) for x in packed])
429 packed[1] = struct.pack("!H", length)
430 return ''.join(packed)
431
432 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800433 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700434 obj = copy_ttl_out()
Dan Talaycof6202252013-07-02 01:00:29 -0700435 _type = reader.read("!H")[0]
436 assert(_type == 11)
437 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800438 orig_reader = reader
439 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700440 reader.skip(4)
441 return obj
442
443 def __eq__(self, other):
444 if type(self) != type(other): return False
445 return True
446
Rich Lanec2ee4b82013-04-24 17:12:38 -0700447 def pretty_print(self, q):
448 q.text("copy_ttl_out {")
449 with q.group():
450 with q.indent(2):
451 q.breakable()
452 q.breakable()
453 q.text('}')
454
Rich Lane7dcdf022013-12-11 14:45:27 -0800455action.subtypes[11] = copy_ttl_out
456
457class dec_mpls_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700458 type = 16
Rich Lanec2ee4b82013-04-24 17:12:38 -0700459
460 def __init__(self):
461 return
462
463 def pack(self):
464 packed = []
465 packed.append(struct.pack("!H", self.type))
466 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
467 packed.append('\x00' * 4)
468 length = sum([len(x) for x in packed])
469 packed[1] = struct.pack("!H", length)
470 return ''.join(packed)
471
472 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800473 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700474 obj = dec_mpls_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700475 _type = reader.read("!H")[0]
476 assert(_type == 16)
477 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800478 orig_reader = reader
479 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700480 reader.skip(4)
481 return obj
482
483 def __eq__(self, other):
484 if type(self) != type(other): return False
485 return True
486
Rich Lanec2ee4b82013-04-24 17:12:38 -0700487 def pretty_print(self, q):
488 q.text("dec_mpls_ttl {")
489 with q.group():
490 with q.indent(2):
491 q.breakable()
492 q.breakable()
493 q.text('}')
494
Rich Lane7dcdf022013-12-11 14:45:27 -0800495action.subtypes[16] = dec_mpls_ttl
496
497class dec_nw_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700498 type = 24
Rich Lanec2ee4b82013-04-24 17:12:38 -0700499
500 def __init__(self):
501 return
502
503 def pack(self):
504 packed = []
505 packed.append(struct.pack("!H", self.type))
506 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
507 packed.append('\x00' * 4)
508 length = sum([len(x) for x in packed])
509 packed[1] = struct.pack("!H", length)
510 return ''.join(packed)
511
512 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800513 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700514 obj = dec_nw_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700515 _type = reader.read("!H")[0]
516 assert(_type == 24)
517 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800518 orig_reader = reader
519 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700520 reader.skip(4)
521 return obj
522
523 def __eq__(self, other):
524 if type(self) != type(other): return False
525 return True
526
Rich Lanec2ee4b82013-04-24 17:12:38 -0700527 def pretty_print(self, q):
528 q.text("dec_nw_ttl {")
529 with q.group():
530 with q.indent(2):
531 q.breakable()
532 q.breakable()
533 q.text('}')
534
Rich Lane7dcdf022013-12-11 14:45:27 -0800535action.subtypes[24] = dec_nw_ttl
536
537class group(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700538 type = 22
Rich Lanec2ee4b82013-04-24 17:12:38 -0700539
540 def __init__(self, group_id=None):
541 if group_id != None:
542 self.group_id = group_id
543 else:
544 self.group_id = 0
545 return
546
547 def pack(self):
548 packed = []
549 packed.append(struct.pack("!H", self.type))
550 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
551 packed.append(struct.pack("!L", self.group_id))
552 length = sum([len(x) for x in packed])
553 packed[1] = struct.pack("!H", length)
554 return ''.join(packed)
555
556 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800557 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700558 obj = group()
Dan Talaycof6202252013-07-02 01:00:29 -0700559 _type = reader.read("!H")[0]
560 assert(_type == 22)
561 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800562 orig_reader = reader
563 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700564 obj.group_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700565 return obj
566
567 def __eq__(self, other):
568 if type(self) != type(other): return False
569 if self.group_id != other.group_id: return False
570 return True
571
Rich Lanec2ee4b82013-04-24 17:12:38 -0700572 def pretty_print(self, q):
573 q.text("group {")
574 with q.group():
575 with q.indent(2):
576 q.breakable()
577 q.text("group_id = ");
578 q.text("%#x" % self.group_id)
579 q.breakable()
580 q.text('}')
581
Rich Lane7dcdf022013-12-11 14:45:27 -0800582action.subtypes[22] = group
583
584class nicira(experimenter):
585 subtypes = {}
586
Rich Lane95f7fc92014-01-27 17:08:16 -0800587 type = 65535
588 experimenter = 8992
589
590 def __init__(self, subtype=None):
591 if subtype != None:
592 self.subtype = subtype
593 else:
594 self.subtype = 0
595 return
596
597 def pack(self):
598 packed = []
599 packed.append(struct.pack("!H", self.type))
600 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
601 packed.append(struct.pack("!L", self.experimenter))
602 packed.append(struct.pack("!H", self.subtype))
603 packed.append('\x00' * 2)
604 packed.append('\x00' * 4)
605 length = sum([len(x) for x in packed])
606 packed[1] = struct.pack("!H", length)
607 return ''.join(packed)
608
Rich Lane7dcdf022013-12-11 14:45:27 -0800609 @staticmethod
610 def unpack(reader):
611 subtype, = reader.peek('!H', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800612 subclass = nicira.subtypes.get(subtype)
613 if subclass:
614 return subclass.unpack(reader)
615
616 obj = nicira()
617 _type = reader.read("!H")[0]
618 assert(_type == 65535)
619 _len = reader.read("!H")[0]
620 orig_reader = reader
621 reader = orig_reader.slice(_len - (2 + 2))
622 _experimenter = reader.read("!L")[0]
623 assert(_experimenter == 8992)
624 obj.subtype = reader.read("!H")[0]
625 reader.skip(2)
626 reader.skip(4)
627 return obj
628
629 def __eq__(self, other):
630 if type(self) != type(other): return False
631 if self.subtype != other.subtype: return False
632 return True
633
634 def pretty_print(self, q):
635 q.text("nicira {")
636 with q.group():
637 with q.indent(2):
638 q.breakable()
639 q.breakable()
640 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800641
642experimenter.subtypes[8992] = nicira
643
644class nicira_dec_ttl(nicira):
Dan Talaycof6202252013-07-02 01:00:29 -0700645 type = 65535
646 experimenter = 8992
Rich Lanec2ee4b82013-04-24 17:12:38 -0700647 subtype = 18
648
649 def __init__(self):
650 return
651
652 def pack(self):
653 packed = []
654 packed.append(struct.pack("!H", self.type))
655 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
656 packed.append(struct.pack("!L", self.experimenter))
657 packed.append(struct.pack("!H", self.subtype))
658 packed.append('\x00' * 2)
659 packed.append('\x00' * 4)
660 length = sum([len(x) for x in packed])
661 packed[1] = struct.pack("!H", length)
662 return ''.join(packed)
663
664 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800665 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700666 obj = nicira_dec_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700667 _type = reader.read("!H")[0]
668 assert(_type == 65535)
669 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800670 orig_reader = reader
671 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700672 _experimenter = reader.read("!L")[0]
673 assert(_experimenter == 8992)
674 _subtype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700675 assert(_subtype == 18)
676 reader.skip(2)
677 reader.skip(4)
678 return obj
679
680 def __eq__(self, other):
681 if type(self) != type(other): return False
682 return True
683
Rich Lanec2ee4b82013-04-24 17:12:38 -0700684 def pretty_print(self, q):
685 q.text("nicira_dec_ttl {")
686 with q.group():
687 with q.indent(2):
688 q.breakable()
689 q.breakable()
690 q.text('}')
691
Rich Lane7dcdf022013-12-11 14:45:27 -0800692nicira.subtypes[18] = nicira_dec_ttl
693
694class output(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700695 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700696
697 def __init__(self, port=None, max_len=None):
698 if port != None:
699 self.port = port
700 else:
701 self.port = 0
702 if max_len != None:
703 self.max_len = max_len
704 else:
705 self.max_len = 0
706 return
707
708 def pack(self):
709 packed = []
710 packed.append(struct.pack("!H", self.type))
711 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700712 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700713 packed.append(struct.pack("!H", self.max_len))
714 packed.append('\x00' * 6)
715 length = sum([len(x) for x in packed])
716 packed[1] = struct.pack("!H", length)
717 return ''.join(packed)
718
719 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800720 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700721 obj = output()
Dan Talaycof6202252013-07-02 01:00:29 -0700722 _type = reader.read("!H")[0]
723 assert(_type == 0)
724 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800725 orig_reader = reader
726 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700727 obj.port = util.unpack_port_no(reader)
728 obj.max_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700729 reader.skip(6)
730 return obj
731
732 def __eq__(self, other):
733 if type(self) != type(other): return False
734 if self.port != other.port: return False
735 if self.max_len != other.max_len: return False
736 return True
737
Rich Lanec2ee4b82013-04-24 17:12:38 -0700738 def pretty_print(self, q):
739 q.text("output {")
740 with q.group():
741 with q.indent(2):
742 q.breakable()
743 q.text("port = ");
744 q.text(util.pretty_port(self.port))
745 q.text(","); q.breakable()
746 q.text("max_len = ");
747 q.text("%#x" % self.max_len)
748 q.breakable()
749 q.text('}')
750
Rich Lane7dcdf022013-12-11 14:45:27 -0800751action.subtypes[0] = output
752
753class pop_mpls(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700754 type = 20
Rich Lanec2ee4b82013-04-24 17:12:38 -0700755
756 def __init__(self, ethertype=None):
757 if ethertype != None:
758 self.ethertype = ethertype
759 else:
760 self.ethertype = 0
761 return
762
763 def pack(self):
764 packed = []
765 packed.append(struct.pack("!H", self.type))
766 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
767 packed.append(struct.pack("!H", self.ethertype))
768 packed.append('\x00' * 2)
769 length = sum([len(x) for x in packed])
770 packed[1] = struct.pack("!H", length)
771 return ''.join(packed)
772
773 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800774 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700775 obj = pop_mpls()
Dan Talaycof6202252013-07-02 01:00:29 -0700776 _type = reader.read("!H")[0]
777 assert(_type == 20)
778 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800779 orig_reader = reader
780 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700781 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700782 reader.skip(2)
783 return obj
784
785 def __eq__(self, other):
786 if type(self) != type(other): return False
787 if self.ethertype != other.ethertype: return False
788 return True
789
Rich Lanec2ee4b82013-04-24 17:12:38 -0700790 def pretty_print(self, q):
791 q.text("pop_mpls {")
792 with q.group():
793 with q.indent(2):
794 q.breakable()
795 q.text("ethertype = ");
796 q.text("%#x" % self.ethertype)
797 q.breakable()
798 q.text('}')
799
Rich Lane7dcdf022013-12-11 14:45:27 -0800800action.subtypes[20] = pop_mpls
801
802class pop_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700803 type = 18
Rich Lanec2ee4b82013-04-24 17:12:38 -0700804
805 def __init__(self):
806 return
807
808 def pack(self):
809 packed = []
810 packed.append(struct.pack("!H", self.type))
811 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
812 packed.append('\x00' * 4)
813 length = sum([len(x) for x in packed])
814 packed[1] = struct.pack("!H", length)
815 return ''.join(packed)
816
817 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800818 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700819 obj = pop_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -0700820 _type = reader.read("!H")[0]
821 assert(_type == 18)
822 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800823 orig_reader = reader
824 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700825 reader.skip(4)
826 return obj
827
828 def __eq__(self, other):
829 if type(self) != type(other): return False
830 return True
831
Rich Lanec2ee4b82013-04-24 17:12:38 -0700832 def pretty_print(self, q):
833 q.text("pop_vlan {")
834 with q.group():
835 with q.indent(2):
836 q.breakable()
837 q.breakable()
838 q.text('}')
839
Rich Lane7dcdf022013-12-11 14:45:27 -0800840action.subtypes[18] = pop_vlan
841
842class push_mpls(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700843 type = 19
Rich Lanec2ee4b82013-04-24 17:12:38 -0700844
845 def __init__(self, ethertype=None):
846 if ethertype != None:
847 self.ethertype = ethertype
848 else:
849 self.ethertype = 0
850 return
851
852 def pack(self):
853 packed = []
854 packed.append(struct.pack("!H", self.type))
855 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
856 packed.append(struct.pack("!H", self.ethertype))
857 packed.append('\x00' * 2)
858 length = sum([len(x) for x in packed])
859 packed[1] = struct.pack("!H", length)
860 return ''.join(packed)
861
862 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800863 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700864 obj = push_mpls()
Dan Talaycof6202252013-07-02 01:00:29 -0700865 _type = reader.read("!H")[0]
866 assert(_type == 19)
867 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800868 orig_reader = reader
869 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700870 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700871 reader.skip(2)
872 return obj
873
874 def __eq__(self, other):
875 if type(self) != type(other): return False
876 if self.ethertype != other.ethertype: return False
877 return True
878
Rich Lanec2ee4b82013-04-24 17:12:38 -0700879 def pretty_print(self, q):
880 q.text("push_mpls {")
881 with q.group():
882 with q.indent(2):
883 q.breakable()
884 q.text("ethertype = ");
885 q.text("%#x" % self.ethertype)
886 q.breakable()
887 q.text('}')
888
Rich Lane7dcdf022013-12-11 14:45:27 -0800889action.subtypes[19] = push_mpls
890
891class push_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700892 type = 17
Rich Lanec2ee4b82013-04-24 17:12:38 -0700893
894 def __init__(self, ethertype=None):
895 if ethertype != None:
896 self.ethertype = ethertype
897 else:
898 self.ethertype = 0
899 return
900
901 def pack(self):
902 packed = []
903 packed.append(struct.pack("!H", self.type))
904 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
905 packed.append(struct.pack("!H", self.ethertype))
906 packed.append('\x00' * 2)
907 length = sum([len(x) for x in packed])
908 packed[1] = struct.pack("!H", length)
909 return ''.join(packed)
910
911 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800912 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700913 obj = push_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -0700914 _type = reader.read("!H")[0]
915 assert(_type == 17)
916 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800917 orig_reader = reader
918 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700919 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700920 reader.skip(2)
921 return obj
922
923 def __eq__(self, other):
924 if type(self) != type(other): return False
925 if self.ethertype != other.ethertype: return False
926 return True
927
Rich Lanec2ee4b82013-04-24 17:12:38 -0700928 def pretty_print(self, q):
929 q.text("push_vlan {")
930 with q.group():
931 with q.indent(2):
932 q.breakable()
933 q.text("ethertype = ");
934 q.text("%#x" % self.ethertype)
935 q.breakable()
936 q.text('}')
937
Rich Lane7dcdf022013-12-11 14:45:27 -0800938action.subtypes[17] = push_vlan
939
940class set_field(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700941 type = 25
Rich Lanec2ee4b82013-04-24 17:12:38 -0700942
943 def __init__(self, field=None):
944 if field != None:
945 self.field = field
946 else:
Rich Laned53156a2013-08-05 17:17:33 -0700947 self.field = None
Rich Lanec2ee4b82013-04-24 17:12:38 -0700948 return
949
950 def pack(self):
951 packed = []
952 packed.append(struct.pack("!H", self.type))
953 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Rich Laned53156a2013-08-05 17:17:33 -0700954 packed.append(self.field.pack())
Rich Lanec2ee4b82013-04-24 17:12:38 -0700955 length = sum([len(x) for x in packed])
Rich Laned53156a2013-08-05 17:17:33 -0700956 packed.append(loxi.generic_util.pad_to(8, length))
957 length += len(packed[-1])
Rich Lanec2ee4b82013-04-24 17:12:38 -0700958 packed[1] = struct.pack("!H", length)
959 return ''.join(packed)
960
961 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800962 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700963 obj = set_field()
Dan Talaycof6202252013-07-02 01:00:29 -0700964 _type = reader.read("!H")[0]
965 assert(_type == 25)
966 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800967 orig_reader = reader
968 reader = orig_reader.slice(_len - (2 + 2))
969 obj.field = oxm.oxm.unpack(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700970 return obj
971
972 def __eq__(self, other):
973 if type(self) != type(other): return False
974 if self.field != other.field: return False
975 return True
976
Rich Lanec2ee4b82013-04-24 17:12:38 -0700977 def pretty_print(self, q):
978 q.text("set_field {")
979 with q.group():
980 with q.indent(2):
981 q.breakable()
982 q.text("field = ");
983 q.pp(self.field)
984 q.breakable()
985 q.text('}')
986
Rich Lane7dcdf022013-12-11 14:45:27 -0800987action.subtypes[25] = set_field
988
989class set_mpls_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700990 type = 15
Rich Lanec2ee4b82013-04-24 17:12:38 -0700991
992 def __init__(self, mpls_ttl=None):
993 if mpls_ttl != None:
994 self.mpls_ttl = mpls_ttl
995 else:
996 self.mpls_ttl = 0
997 return
998
999 def pack(self):
1000 packed = []
1001 packed.append(struct.pack("!H", self.type))
1002 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1003 packed.append(struct.pack("!B", self.mpls_ttl))
1004 packed.append('\x00' * 3)
1005 length = sum([len(x) for x in packed])
1006 packed[1] = struct.pack("!H", length)
1007 return ''.join(packed)
1008
1009 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001010 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001011 obj = set_mpls_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -07001012 _type = reader.read("!H")[0]
1013 assert(_type == 15)
1014 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001015 orig_reader = reader
1016 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001017 obj.mpls_ttl = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001018 reader.skip(3)
1019 return obj
1020
1021 def __eq__(self, other):
1022 if type(self) != type(other): return False
1023 if self.mpls_ttl != other.mpls_ttl: return False
1024 return True
1025
Rich Lanec2ee4b82013-04-24 17:12:38 -07001026 def pretty_print(self, q):
1027 q.text("set_mpls_ttl {")
1028 with q.group():
1029 with q.indent(2):
1030 q.breakable()
1031 q.text("mpls_ttl = ");
1032 q.text("%#x" % self.mpls_ttl)
1033 q.breakable()
1034 q.text('}')
1035
Rich Lane7dcdf022013-12-11 14:45:27 -08001036action.subtypes[15] = set_mpls_ttl
1037
1038class set_nw_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001039 type = 23
Rich Lanec2ee4b82013-04-24 17:12:38 -07001040
1041 def __init__(self, nw_ttl=None):
1042 if nw_ttl != None:
1043 self.nw_ttl = nw_ttl
1044 else:
1045 self.nw_ttl = 0
1046 return
1047
1048 def pack(self):
1049 packed = []
1050 packed.append(struct.pack("!H", self.type))
1051 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1052 packed.append(struct.pack("!B", self.nw_ttl))
1053 packed.append('\x00' * 3)
1054 length = sum([len(x) for x in packed])
1055 packed[1] = struct.pack("!H", length)
1056 return ''.join(packed)
1057
1058 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001059 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001060 obj = set_nw_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -07001061 _type = reader.read("!H")[0]
1062 assert(_type == 23)
1063 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001064 orig_reader = reader
1065 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001066 obj.nw_ttl = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001067 reader.skip(3)
1068 return obj
1069
1070 def __eq__(self, other):
1071 if type(self) != type(other): return False
1072 if self.nw_ttl != other.nw_ttl: return False
1073 return True
1074
Rich Lanec2ee4b82013-04-24 17:12:38 -07001075 def pretty_print(self, q):
1076 q.text("set_nw_ttl {")
1077 with q.group():
1078 with q.indent(2):
1079 q.breakable()
1080 q.text("nw_ttl = ");
1081 q.text("%#x" % self.nw_ttl)
1082 q.breakable()
1083 q.text('}')
1084
Rich Lane7dcdf022013-12-11 14:45:27 -08001085action.subtypes[23] = set_nw_ttl
1086
1087class set_queue(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001088 type = 21
Rich Lanec2ee4b82013-04-24 17:12:38 -07001089
1090 def __init__(self, queue_id=None):
1091 if queue_id != None:
1092 self.queue_id = queue_id
1093 else:
1094 self.queue_id = 0
1095 return
1096
1097 def pack(self):
1098 packed = []
1099 packed.append(struct.pack("!H", self.type))
1100 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1101 packed.append(struct.pack("!L", self.queue_id))
1102 length = sum([len(x) for x in packed])
1103 packed[1] = struct.pack("!H", length)
1104 return ''.join(packed)
1105
1106 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001107 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001108 obj = set_queue()
Dan Talaycof6202252013-07-02 01:00:29 -07001109 _type = reader.read("!H")[0]
1110 assert(_type == 21)
1111 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001112 orig_reader = reader
1113 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001114 obj.queue_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001115 return obj
1116
1117 def __eq__(self, other):
1118 if type(self) != type(other): return False
1119 if self.queue_id != other.queue_id: return False
1120 return True
1121
Rich Lanec2ee4b82013-04-24 17:12:38 -07001122 def pretty_print(self, q):
1123 q.text("set_queue {")
1124 with q.group():
1125 with q.indent(2):
1126 q.breakable()
1127 q.text("queue_id = ");
1128 q.text("%#x" % self.queue_id)
1129 q.breakable()
1130 q.text('}')
1131
Rich Lane7dcdf022013-12-11 14:45:27 -08001132action.subtypes[21] = set_queue
Rich Lanec2ee4b82013-04-24 17:12:38 -07001133
Rich Lanec2ee4b82013-04-24 17:12:38 -07001134