blob: a95aa78555f9caad87d2b248fdb3042487e656ed [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 util
12import loxi.generic_util
Rich Lanec2ee4b82013-04-24 17:12:38 -070013
Rich Lanee2567702015-01-26 15:04:35 -080014import sys
15ofp = sys.modules['loxi.of12']
16
Rich Lane7dcdf022013-12-11 14:45:27 -080017class action(loxi.OFObject):
18 subtypes = {}
Rich Lanec2ee4b82013-04-24 17:12:38 -070019
Rich Lane95f7fc92014-01-27 17:08:16 -080020
21 def __init__(self, type=None):
22 if type != None:
23 self.type = type
24 else:
25 self.type = 0
26 return
27
28 def pack(self):
29 packed = []
30 packed.append(struct.pack("!H", self.type))
31 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
32 packed.append('\x00' * 4)
33 length = sum([len(x) for x in packed])
34 packed[1] = struct.pack("!H", length)
35 return ''.join(packed)
36
Rich Lane7dcdf022013-12-11 14:45:27 -080037 @staticmethod
38 def unpack(reader):
39 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -080040 subclass = action.subtypes.get(subtype)
41 if subclass:
42 return subclass.unpack(reader)
43
44 obj = action()
45 obj.type = reader.read("!H")[0]
46 _len = reader.read("!H")[0]
47 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -080048 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -080049 reader.skip(4)
50 return obj
51
52 def __eq__(self, other):
53 if type(self) != type(other): return False
54 if self.type != other.type: return False
55 return True
56
57 def pretty_print(self, q):
58 q.text("action {")
59 with q.group():
60 with q.indent(2):
61 q.breakable()
62 q.breakable()
63 q.text('}')
Rich Lanec2ee4b82013-04-24 17:12:38 -070064
Rich Lane7dcdf022013-12-11 14:45:27 -080065
66class experimenter(action):
67 subtypes = {}
68
Rich Lane95f7fc92014-01-27 17:08:16 -080069 type = 65535
70
71 def __init__(self, experimenter=None, data=None):
72 if experimenter != None:
73 self.experimenter = experimenter
74 else:
75 self.experimenter = 0
76 if data != None:
77 self.data = data
78 else:
79 self.data = ''
80 return
81
82 def pack(self):
83 packed = []
84 packed.append(struct.pack("!H", self.type))
85 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
86 packed.append(struct.pack("!L", self.experimenter))
87 packed.append(self.data)
88 length = sum([len(x) for x in packed])
89 packed.append(loxi.generic_util.pad_to(8, length))
90 length += len(packed[-1])
91 packed[1] = struct.pack("!H", length)
92 return ''.join(packed)
93
Rich Lane7dcdf022013-12-11 14:45:27 -080094 @staticmethod
95 def unpack(reader):
96 subtype, = reader.peek('!L', 4)
Rich Lane95f7fc92014-01-27 17:08:16 -080097 subclass = experimenter.subtypes.get(subtype)
98 if subclass:
99 return subclass.unpack(reader)
100
101 obj = experimenter()
102 _type = reader.read("!H")[0]
103 assert(_type == 65535)
104 _len = reader.read("!H")[0]
105 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800106 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800107 obj.experimenter = reader.read("!L")[0]
108 obj.data = str(reader.read_all())
109 return obj
110
111 def __eq__(self, other):
112 if type(self) != type(other): return False
113 if self.experimenter != other.experimenter: return False
114 if self.data != other.data: return False
115 return True
116
117 def pretty_print(self, q):
118 q.text("experimenter {")
119 with q.group():
120 with q.indent(2):
121 q.breakable()
122 q.text("data = ");
123 q.pp(self.data)
124 q.breakable()
125 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800126
127action.subtypes[65535] = experimenter
128
129class bsn(experimenter):
130 subtypes = {}
131
Rich Lane95f7fc92014-01-27 17:08:16 -0800132 type = 65535
133 experimenter = 6035143
134
135 def __init__(self, subtype=None):
136 if subtype != None:
137 self.subtype = subtype
138 else:
139 self.subtype = 0
140 return
141
142 def pack(self):
143 packed = []
144 packed.append(struct.pack("!H", self.type))
145 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
146 packed.append(struct.pack("!L", self.experimenter))
147 packed.append(struct.pack("!L", self.subtype))
148 packed.append('\x00' * 4)
149 length = sum([len(x) for x in packed])
150 packed[1] = struct.pack("!H", length)
151 return ''.join(packed)
152
Rich Lane7dcdf022013-12-11 14:45:27 -0800153 @staticmethod
154 def unpack(reader):
155 subtype, = reader.peek('!L', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800156 subclass = bsn.subtypes.get(subtype)
157 if subclass:
158 return subclass.unpack(reader)
159
160 obj = bsn()
161 _type = reader.read("!H")[0]
162 assert(_type == 65535)
163 _len = reader.read("!H")[0]
164 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800165 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800166 _experimenter = reader.read("!L")[0]
167 assert(_experimenter == 6035143)
168 obj.subtype = reader.read("!L")[0]
169 reader.skip(4)
170 return obj
171
172 def __eq__(self, other):
173 if type(self) != type(other): return False
174 if self.subtype != other.subtype: return False
175 return True
176
177 def pretty_print(self, q):
178 q.text("bsn {")
179 with q.group():
180 with q.indent(2):
181 q.breakable()
182 q.breakable()
183 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800184
185experimenter.subtypes[6035143] = bsn
186
Rich Lane5587ab12014-06-30 11:19:09 -0700187class bsn_checksum(bsn):
188 type = 65535
189 experimenter = 6035143
190 subtype = 4
191
192 def __init__(self, checksum=None):
193 if checksum != None:
194 self.checksum = checksum
195 else:
196 self.checksum = 0
197 return
198
199 def pack(self):
200 packed = []
201 packed.append(struct.pack("!H", self.type))
202 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
203 packed.append(struct.pack("!L", self.experimenter))
204 packed.append(struct.pack("!L", self.subtype))
205 packed.append(util.pack_checksum_128(self.checksum))
206 length = sum([len(x) for x in packed])
207 packed[1] = struct.pack("!H", length)
208 return ''.join(packed)
209
210 @staticmethod
211 def unpack(reader):
212 obj = bsn_checksum()
213 _type = reader.read("!H")[0]
214 assert(_type == 65535)
215 _len = reader.read("!H")[0]
216 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800217 reader = orig_reader.slice(_len, 4)
Rich Lane5587ab12014-06-30 11:19:09 -0700218 _experimenter = reader.read("!L")[0]
219 assert(_experimenter == 6035143)
220 _subtype = reader.read("!L")[0]
221 assert(_subtype == 4)
222 obj.checksum = util.unpack_checksum_128(reader)
223 return obj
224
225 def __eq__(self, other):
226 if type(self) != type(other): return False
227 if self.checksum != other.checksum: return False
228 return True
229
230 def pretty_print(self, q):
231 q.text("bsn_checksum {")
232 with q.group():
233 with q.indent(2):
234 q.breakable()
235 q.text("checksum = ");
236 q.pp(self.checksum)
237 q.breakable()
238 q.text('}')
239
240bsn.subtypes[4] = bsn_checksum
241
Rich Lane7dcdf022013-12-11 14:45:27 -0800242class bsn_mirror(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700243 type = 65535
244 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -0700245 subtype = 1
246
247 def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None):
248 if dest_port != None:
249 self.dest_port = dest_port
250 else:
251 self.dest_port = 0
252 if vlan_tag != None:
253 self.vlan_tag = vlan_tag
254 else:
255 self.vlan_tag = 0
256 if copy_stage != None:
257 self.copy_stage = copy_stage
258 else:
259 self.copy_stage = 0
260 return
261
262 def pack(self):
263 packed = []
264 packed.append(struct.pack("!H", self.type))
265 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
266 packed.append(struct.pack("!L", self.experimenter))
267 packed.append(struct.pack("!L", self.subtype))
268 packed.append(struct.pack("!L", self.dest_port))
269 packed.append(struct.pack("!L", self.vlan_tag))
270 packed.append(struct.pack("!B", self.copy_stage))
271 packed.append('\x00' * 3)
272 length = sum([len(x) for x in packed])
273 packed[1] = struct.pack("!H", length)
274 return ''.join(packed)
275
276 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800277 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700278 obj = bsn_mirror()
Dan Talaycof6202252013-07-02 01:00:29 -0700279 _type = reader.read("!H")[0]
280 assert(_type == 65535)
281 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800282 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800283 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700284 _experimenter = reader.read("!L")[0]
285 assert(_experimenter == 6035143)
286 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700287 assert(_subtype == 1)
Dan Talaycof6202252013-07-02 01:00:29 -0700288 obj.dest_port = reader.read("!L")[0]
289 obj.vlan_tag = reader.read("!L")[0]
290 obj.copy_stage = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700291 reader.skip(3)
292 return obj
293
294 def __eq__(self, other):
295 if type(self) != type(other): return False
296 if self.dest_port != other.dest_port: return False
297 if self.vlan_tag != other.vlan_tag: return False
298 if self.copy_stage != other.copy_stage: return False
299 return True
300
Rich Lanec2ee4b82013-04-24 17:12:38 -0700301 def pretty_print(self, q):
302 q.text("bsn_mirror {")
303 with q.group():
304 with q.indent(2):
305 q.breakable()
306 q.text("dest_port = ");
307 q.text("%#x" % self.dest_port)
308 q.text(","); q.breakable()
309 q.text("vlan_tag = ");
310 q.text("%#x" % self.vlan_tag)
311 q.text(","); q.breakable()
312 q.text("copy_stage = ");
313 q.text("%#x" % self.copy_stage)
314 q.breakable()
315 q.text('}')
316
Rich Lane7dcdf022013-12-11 14:45:27 -0800317bsn.subtypes[1] = bsn_mirror
318
319class bsn_set_tunnel_dst(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700320 type = 65535
321 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -0700322 subtype = 2
323
324 def __init__(self, dst=None):
325 if dst != None:
326 self.dst = dst
327 else:
328 self.dst = 0
329 return
330
331 def pack(self):
332 packed = []
333 packed.append(struct.pack("!H", self.type))
334 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
335 packed.append(struct.pack("!L", self.experimenter))
336 packed.append(struct.pack("!L", self.subtype))
337 packed.append(struct.pack("!L", self.dst))
338 length = sum([len(x) for x in packed])
339 packed[1] = struct.pack("!H", length)
340 return ''.join(packed)
341
342 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800343 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700344 obj = bsn_set_tunnel_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700345 _type = reader.read("!H")[0]
346 assert(_type == 65535)
347 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800348 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800349 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700350 _experimenter = reader.read("!L")[0]
351 assert(_experimenter == 6035143)
352 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700353 assert(_subtype == 2)
Dan Talaycof6202252013-07-02 01:00:29 -0700354 obj.dst = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700355 return obj
356
357 def __eq__(self, other):
358 if type(self) != type(other): return False
359 if self.dst != other.dst: return False
360 return True
361
Rich Lanec2ee4b82013-04-24 17:12:38 -0700362 def pretty_print(self, q):
363 q.text("bsn_set_tunnel_dst {")
364 with q.group():
365 with q.indent(2):
366 q.breakable()
367 q.text("dst = ");
368 q.text("%#x" % self.dst)
369 q.breakable()
370 q.text('}')
371
Rich Lane7dcdf022013-12-11 14:45:27 -0800372bsn.subtypes[2] = bsn_set_tunnel_dst
373
374class copy_ttl_in(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700375 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -0700376
377 def __init__(self):
378 return
379
380 def pack(self):
381 packed = []
382 packed.append(struct.pack("!H", self.type))
383 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
384 packed.append('\x00' * 4)
385 length = sum([len(x) for x in packed])
386 packed[1] = struct.pack("!H", length)
387 return ''.join(packed)
388
389 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800390 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700391 obj = copy_ttl_in()
Dan Talaycof6202252013-07-02 01:00:29 -0700392 _type = reader.read("!H")[0]
393 assert(_type == 12)
394 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800395 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800396 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700397 reader.skip(4)
398 return obj
399
400 def __eq__(self, other):
401 if type(self) != type(other): return False
402 return True
403
Rich Lanec2ee4b82013-04-24 17:12:38 -0700404 def pretty_print(self, q):
405 q.text("copy_ttl_in {")
406 with q.group():
407 with q.indent(2):
408 q.breakable()
409 q.breakable()
410 q.text('}')
411
Rich Lane7dcdf022013-12-11 14:45:27 -0800412action.subtypes[12] = copy_ttl_in
413
414class copy_ttl_out(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700415 type = 11
Rich Lanec2ee4b82013-04-24 17:12:38 -0700416
417 def __init__(self):
418 return
419
420 def pack(self):
421 packed = []
422 packed.append(struct.pack("!H", self.type))
423 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
424 packed.append('\x00' * 4)
425 length = sum([len(x) for x in packed])
426 packed[1] = struct.pack("!H", length)
427 return ''.join(packed)
428
429 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800430 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700431 obj = copy_ttl_out()
Dan Talaycof6202252013-07-02 01:00:29 -0700432 _type = reader.read("!H")[0]
433 assert(_type == 11)
434 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800435 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800436 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700437 reader.skip(4)
438 return obj
439
440 def __eq__(self, other):
441 if type(self) != type(other): return False
442 return True
443
Rich Lanec2ee4b82013-04-24 17:12:38 -0700444 def pretty_print(self, q):
445 q.text("copy_ttl_out {")
446 with q.group():
447 with q.indent(2):
448 q.breakable()
449 q.breakable()
450 q.text('}')
451
Rich Lane7dcdf022013-12-11 14:45:27 -0800452action.subtypes[11] = copy_ttl_out
453
454class dec_mpls_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700455 type = 16
Rich Lanec2ee4b82013-04-24 17:12:38 -0700456
457 def __init__(self):
458 return
459
460 def pack(self):
461 packed = []
462 packed.append(struct.pack("!H", self.type))
463 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
464 packed.append('\x00' * 4)
465 length = sum([len(x) for x in packed])
466 packed[1] = struct.pack("!H", length)
467 return ''.join(packed)
468
469 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800470 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700471 obj = dec_mpls_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700472 _type = reader.read("!H")[0]
473 assert(_type == 16)
474 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800475 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800476 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700477 reader.skip(4)
478 return obj
479
480 def __eq__(self, other):
481 if type(self) != type(other): return False
482 return True
483
Rich Lanec2ee4b82013-04-24 17:12:38 -0700484 def pretty_print(self, q):
485 q.text("dec_mpls_ttl {")
486 with q.group():
487 with q.indent(2):
488 q.breakable()
489 q.breakable()
490 q.text('}')
491
Rich Lane7dcdf022013-12-11 14:45:27 -0800492action.subtypes[16] = dec_mpls_ttl
493
494class dec_nw_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700495 type = 24
Rich Lanec2ee4b82013-04-24 17:12:38 -0700496
497 def __init__(self):
498 return
499
500 def pack(self):
501 packed = []
502 packed.append(struct.pack("!H", self.type))
503 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
504 packed.append('\x00' * 4)
505 length = sum([len(x) for x in packed])
506 packed[1] = struct.pack("!H", length)
507 return ''.join(packed)
508
509 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800510 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700511 obj = dec_nw_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700512 _type = reader.read("!H")[0]
513 assert(_type == 24)
514 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800515 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800516 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700517 reader.skip(4)
518 return obj
519
520 def __eq__(self, other):
521 if type(self) != type(other): return False
522 return True
523
Rich Lanec2ee4b82013-04-24 17:12:38 -0700524 def pretty_print(self, q):
525 q.text("dec_nw_ttl {")
526 with q.group():
527 with q.indent(2):
528 q.breakable()
529 q.breakable()
530 q.text('}')
531
Rich Lane7dcdf022013-12-11 14:45:27 -0800532action.subtypes[24] = dec_nw_ttl
533
534class group(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700535 type = 22
Rich Lanec2ee4b82013-04-24 17:12:38 -0700536
537 def __init__(self, group_id=None):
538 if group_id != None:
539 self.group_id = group_id
540 else:
541 self.group_id = 0
542 return
543
544 def pack(self):
545 packed = []
546 packed.append(struct.pack("!H", self.type))
547 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
548 packed.append(struct.pack("!L", self.group_id))
549 length = sum([len(x) for x in packed])
550 packed[1] = struct.pack("!H", length)
551 return ''.join(packed)
552
553 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800554 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700555 obj = group()
Dan Talaycof6202252013-07-02 01:00:29 -0700556 _type = reader.read("!H")[0]
557 assert(_type == 22)
558 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800559 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800560 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700561 obj.group_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700562 return obj
563
564 def __eq__(self, other):
565 if type(self) != type(other): return False
566 if self.group_id != other.group_id: return False
567 return True
568
Rich Lanec2ee4b82013-04-24 17:12:38 -0700569 def pretty_print(self, q):
570 q.text("group {")
571 with q.group():
572 with q.indent(2):
573 q.breakable()
574 q.text("group_id = ");
575 q.text("%#x" % self.group_id)
576 q.breakable()
577 q.text('}')
578
Rich Lane7dcdf022013-12-11 14:45:27 -0800579action.subtypes[22] = group
580
581class nicira(experimenter):
582 subtypes = {}
583
Rich Lane95f7fc92014-01-27 17:08:16 -0800584 type = 65535
585 experimenter = 8992
586
587 def __init__(self, subtype=None):
588 if subtype != None:
589 self.subtype = subtype
590 else:
591 self.subtype = 0
592 return
593
594 def pack(self):
595 packed = []
596 packed.append(struct.pack("!H", self.type))
597 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
598 packed.append(struct.pack("!L", self.experimenter))
599 packed.append(struct.pack("!H", self.subtype))
600 packed.append('\x00' * 2)
601 packed.append('\x00' * 4)
602 length = sum([len(x) for x in packed])
603 packed[1] = struct.pack("!H", length)
604 return ''.join(packed)
605
Rich Lane7dcdf022013-12-11 14:45:27 -0800606 @staticmethod
607 def unpack(reader):
608 subtype, = reader.peek('!H', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800609 subclass = nicira.subtypes.get(subtype)
610 if subclass:
611 return subclass.unpack(reader)
612
613 obj = nicira()
614 _type = reader.read("!H")[0]
615 assert(_type == 65535)
616 _len = reader.read("!H")[0]
617 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800618 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800619 _experimenter = reader.read("!L")[0]
620 assert(_experimenter == 8992)
621 obj.subtype = reader.read("!H")[0]
622 reader.skip(2)
623 reader.skip(4)
624 return obj
625
626 def __eq__(self, other):
627 if type(self) != type(other): return False
628 if self.subtype != other.subtype: return False
629 return True
630
631 def pretty_print(self, q):
632 q.text("nicira {")
633 with q.group():
634 with q.indent(2):
635 q.breakable()
636 q.breakable()
637 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800638
639experimenter.subtypes[8992] = nicira
640
641class nicira_dec_ttl(nicira):
Dan Talaycof6202252013-07-02 01:00:29 -0700642 type = 65535
643 experimenter = 8992
Rich Lanec2ee4b82013-04-24 17:12:38 -0700644 subtype = 18
645
646 def __init__(self):
647 return
648
649 def pack(self):
650 packed = []
651 packed.append(struct.pack("!H", self.type))
652 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
653 packed.append(struct.pack("!L", self.experimenter))
654 packed.append(struct.pack("!H", self.subtype))
655 packed.append('\x00' * 2)
656 packed.append('\x00' * 4)
657 length = sum([len(x) for x in packed])
658 packed[1] = struct.pack("!H", length)
659 return ''.join(packed)
660
661 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800662 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700663 obj = nicira_dec_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700664 _type = reader.read("!H")[0]
665 assert(_type == 65535)
666 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800667 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800668 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700669 _experimenter = reader.read("!L")[0]
670 assert(_experimenter == 8992)
671 _subtype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700672 assert(_subtype == 18)
673 reader.skip(2)
674 reader.skip(4)
675 return obj
676
677 def __eq__(self, other):
678 if type(self) != type(other): return False
679 return True
680
Rich Lanec2ee4b82013-04-24 17:12:38 -0700681 def pretty_print(self, q):
682 q.text("nicira_dec_ttl {")
683 with q.group():
684 with q.indent(2):
685 q.breakable()
686 q.breakable()
687 q.text('}')
688
Rich Lane7dcdf022013-12-11 14:45:27 -0800689nicira.subtypes[18] = nicira_dec_ttl
690
691class output(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700692 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700693
694 def __init__(self, port=None, max_len=None):
695 if port != None:
696 self.port = port
697 else:
698 self.port = 0
699 if max_len != None:
700 self.max_len = max_len
701 else:
702 self.max_len = 0
703 return
704
705 def pack(self):
706 packed = []
707 packed.append(struct.pack("!H", self.type))
708 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700709 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700710 packed.append(struct.pack("!H", self.max_len))
711 packed.append('\x00' * 6)
712 length = sum([len(x) for x in packed])
713 packed[1] = struct.pack("!H", length)
714 return ''.join(packed)
715
716 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800717 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700718 obj = output()
Dan Talaycof6202252013-07-02 01:00:29 -0700719 _type = reader.read("!H")[0]
720 assert(_type == 0)
721 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800722 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800723 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700724 obj.port = util.unpack_port_no(reader)
725 obj.max_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700726 reader.skip(6)
727 return obj
728
729 def __eq__(self, other):
730 if type(self) != type(other): return False
731 if self.port != other.port: return False
732 if self.max_len != other.max_len: return False
733 return True
734
Rich Lanec2ee4b82013-04-24 17:12:38 -0700735 def pretty_print(self, q):
736 q.text("output {")
737 with q.group():
738 with q.indent(2):
739 q.breakable()
740 q.text("port = ");
741 q.text(util.pretty_port(self.port))
742 q.text(","); q.breakable()
743 q.text("max_len = ");
744 q.text("%#x" % self.max_len)
745 q.breakable()
746 q.text('}')
747
Rich Lane7dcdf022013-12-11 14:45:27 -0800748action.subtypes[0] = output
749
750class pop_mpls(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700751 type = 20
Rich Lanec2ee4b82013-04-24 17:12:38 -0700752
753 def __init__(self, ethertype=None):
754 if ethertype != None:
755 self.ethertype = ethertype
756 else:
757 self.ethertype = 0
758 return
759
760 def pack(self):
761 packed = []
762 packed.append(struct.pack("!H", self.type))
763 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
764 packed.append(struct.pack("!H", self.ethertype))
765 packed.append('\x00' * 2)
766 length = sum([len(x) for x in packed])
767 packed[1] = struct.pack("!H", length)
768 return ''.join(packed)
769
770 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800771 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700772 obj = pop_mpls()
Dan Talaycof6202252013-07-02 01:00:29 -0700773 _type = reader.read("!H")[0]
774 assert(_type == 20)
775 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800776 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800777 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700778 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700779 reader.skip(2)
780 return obj
781
782 def __eq__(self, other):
783 if type(self) != type(other): return False
784 if self.ethertype != other.ethertype: return False
785 return True
786
Rich Lanec2ee4b82013-04-24 17:12:38 -0700787 def pretty_print(self, q):
788 q.text("pop_mpls {")
789 with q.group():
790 with q.indent(2):
791 q.breakable()
792 q.text("ethertype = ");
793 q.text("%#x" % self.ethertype)
794 q.breakable()
795 q.text('}')
796
Rich Lane7dcdf022013-12-11 14:45:27 -0800797action.subtypes[20] = pop_mpls
798
799class pop_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700800 type = 18
Rich Lanec2ee4b82013-04-24 17:12:38 -0700801
802 def __init__(self):
803 return
804
805 def pack(self):
806 packed = []
807 packed.append(struct.pack("!H", self.type))
808 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
809 packed.append('\x00' * 4)
810 length = sum([len(x) for x in packed])
811 packed[1] = struct.pack("!H", length)
812 return ''.join(packed)
813
814 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800815 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700816 obj = pop_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -0700817 _type = reader.read("!H")[0]
818 assert(_type == 18)
819 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800820 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800821 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700822 reader.skip(4)
823 return obj
824
825 def __eq__(self, other):
826 if type(self) != type(other): return False
827 return True
828
Rich Lanec2ee4b82013-04-24 17:12:38 -0700829 def pretty_print(self, q):
830 q.text("pop_vlan {")
831 with q.group():
832 with q.indent(2):
833 q.breakable()
834 q.breakable()
835 q.text('}')
836
Rich Lane7dcdf022013-12-11 14:45:27 -0800837action.subtypes[18] = pop_vlan
838
839class push_mpls(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700840 type = 19
Rich Lanec2ee4b82013-04-24 17:12:38 -0700841
842 def __init__(self, ethertype=None):
843 if ethertype != None:
844 self.ethertype = ethertype
845 else:
846 self.ethertype = 0
847 return
848
849 def pack(self):
850 packed = []
851 packed.append(struct.pack("!H", self.type))
852 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
853 packed.append(struct.pack("!H", self.ethertype))
854 packed.append('\x00' * 2)
855 length = sum([len(x) for x in packed])
856 packed[1] = struct.pack("!H", length)
857 return ''.join(packed)
858
859 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800860 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700861 obj = push_mpls()
Dan Talaycof6202252013-07-02 01:00:29 -0700862 _type = reader.read("!H")[0]
863 assert(_type == 19)
864 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800865 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800866 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700867 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700868 reader.skip(2)
869 return obj
870
871 def __eq__(self, other):
872 if type(self) != type(other): return False
873 if self.ethertype != other.ethertype: return False
874 return True
875
Rich Lanec2ee4b82013-04-24 17:12:38 -0700876 def pretty_print(self, q):
877 q.text("push_mpls {")
878 with q.group():
879 with q.indent(2):
880 q.breakable()
881 q.text("ethertype = ");
882 q.text("%#x" % self.ethertype)
883 q.breakable()
884 q.text('}')
885
Rich Lane7dcdf022013-12-11 14:45:27 -0800886action.subtypes[19] = push_mpls
887
888class push_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700889 type = 17
Rich Lanec2ee4b82013-04-24 17:12:38 -0700890
891 def __init__(self, ethertype=None):
892 if ethertype != None:
893 self.ethertype = ethertype
894 else:
895 self.ethertype = 0
896 return
897
898 def pack(self):
899 packed = []
900 packed.append(struct.pack("!H", self.type))
901 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
902 packed.append(struct.pack("!H", self.ethertype))
903 packed.append('\x00' * 2)
904 length = sum([len(x) for x in packed])
905 packed[1] = struct.pack("!H", length)
906 return ''.join(packed)
907
908 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800909 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700910 obj = push_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -0700911 _type = reader.read("!H")[0]
912 assert(_type == 17)
913 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800914 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800915 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700916 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700917 reader.skip(2)
918 return obj
919
920 def __eq__(self, other):
921 if type(self) != type(other): return False
922 if self.ethertype != other.ethertype: return False
923 return True
924
Rich Lanec2ee4b82013-04-24 17:12:38 -0700925 def pretty_print(self, q):
926 q.text("push_vlan {")
927 with q.group():
928 with q.indent(2):
929 q.breakable()
930 q.text("ethertype = ");
931 q.text("%#x" % self.ethertype)
932 q.breakable()
933 q.text('}')
934
Rich Lane7dcdf022013-12-11 14:45:27 -0800935action.subtypes[17] = push_vlan
936
937class set_field(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700938 type = 25
Rich Lanec2ee4b82013-04-24 17:12:38 -0700939
940 def __init__(self, field=None):
941 if field != None:
942 self.field = field
943 else:
Rich Laned53156a2013-08-05 17:17:33 -0700944 self.field = None
Rich Lanec2ee4b82013-04-24 17:12:38 -0700945 return
946
947 def pack(self):
948 packed = []
949 packed.append(struct.pack("!H", self.type))
950 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Rich Laned53156a2013-08-05 17:17:33 -0700951 packed.append(self.field.pack())
Rich Lanec2ee4b82013-04-24 17:12:38 -0700952 length = sum([len(x) for x in packed])
Rich Laned53156a2013-08-05 17:17:33 -0700953 packed.append(loxi.generic_util.pad_to(8, length))
954 length += len(packed[-1])
Rich Lanec2ee4b82013-04-24 17:12:38 -0700955 packed[1] = struct.pack("!H", length)
956 return ''.join(packed)
957
958 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800959 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700960 obj = set_field()
Dan Talaycof6202252013-07-02 01:00:29 -0700961 _type = reader.read("!H")[0]
962 assert(_type == 25)
963 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800964 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800965 reader = orig_reader.slice(_len, 4)
Rich Lanee2567702015-01-26 15:04:35 -0800966 obj.field = ofp.oxm.oxm.unpack(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700967 return obj
968
969 def __eq__(self, other):
970 if type(self) != type(other): return False
971 if self.field != other.field: return False
972 return True
973
Rich Lanec2ee4b82013-04-24 17:12:38 -0700974 def pretty_print(self, q):
975 q.text("set_field {")
976 with q.group():
977 with q.indent(2):
978 q.breakable()
979 q.text("field = ");
980 q.pp(self.field)
981 q.breakable()
982 q.text('}')
983
Rich Lane7dcdf022013-12-11 14:45:27 -0800984action.subtypes[25] = set_field
985
986class set_mpls_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700987 type = 15
Rich Lanec2ee4b82013-04-24 17:12:38 -0700988
989 def __init__(self, mpls_ttl=None):
990 if mpls_ttl != None:
991 self.mpls_ttl = mpls_ttl
992 else:
993 self.mpls_ttl = 0
994 return
995
996 def pack(self):
997 packed = []
998 packed.append(struct.pack("!H", self.type))
999 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1000 packed.append(struct.pack("!B", self.mpls_ttl))
1001 packed.append('\x00' * 3)
1002 length = sum([len(x) for x in packed])
1003 packed[1] = struct.pack("!H", length)
1004 return ''.join(packed)
1005
1006 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001007 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001008 obj = set_mpls_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -07001009 _type = reader.read("!H")[0]
1010 assert(_type == 15)
1011 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001012 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001013 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001014 obj.mpls_ttl = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001015 reader.skip(3)
1016 return obj
1017
1018 def __eq__(self, other):
1019 if type(self) != type(other): return False
1020 if self.mpls_ttl != other.mpls_ttl: return False
1021 return True
1022
Rich Lanec2ee4b82013-04-24 17:12:38 -07001023 def pretty_print(self, q):
1024 q.text("set_mpls_ttl {")
1025 with q.group():
1026 with q.indent(2):
1027 q.breakable()
1028 q.text("mpls_ttl = ");
1029 q.text("%#x" % self.mpls_ttl)
1030 q.breakable()
1031 q.text('}')
1032
Rich Lane7dcdf022013-12-11 14:45:27 -08001033action.subtypes[15] = set_mpls_ttl
1034
1035class set_nw_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001036 type = 23
Rich Lanec2ee4b82013-04-24 17:12:38 -07001037
1038 def __init__(self, nw_ttl=None):
1039 if nw_ttl != None:
1040 self.nw_ttl = nw_ttl
1041 else:
1042 self.nw_ttl = 0
1043 return
1044
1045 def pack(self):
1046 packed = []
1047 packed.append(struct.pack("!H", self.type))
1048 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1049 packed.append(struct.pack("!B", self.nw_ttl))
1050 packed.append('\x00' * 3)
1051 length = sum([len(x) for x in packed])
1052 packed[1] = struct.pack("!H", length)
1053 return ''.join(packed)
1054
1055 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001056 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001057 obj = set_nw_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -07001058 _type = reader.read("!H")[0]
1059 assert(_type == 23)
1060 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001061 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001062 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001063 obj.nw_ttl = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001064 reader.skip(3)
1065 return obj
1066
1067 def __eq__(self, other):
1068 if type(self) != type(other): return False
1069 if self.nw_ttl != other.nw_ttl: return False
1070 return True
1071
Rich Lanec2ee4b82013-04-24 17:12:38 -07001072 def pretty_print(self, q):
1073 q.text("set_nw_ttl {")
1074 with q.group():
1075 with q.indent(2):
1076 q.breakable()
1077 q.text("nw_ttl = ");
1078 q.text("%#x" % self.nw_ttl)
1079 q.breakable()
1080 q.text('}')
1081
Rich Lane7dcdf022013-12-11 14:45:27 -08001082action.subtypes[23] = set_nw_ttl
1083
1084class set_queue(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001085 type = 21
Rich Lanec2ee4b82013-04-24 17:12:38 -07001086
1087 def __init__(self, queue_id=None):
1088 if queue_id != None:
1089 self.queue_id = queue_id
1090 else:
1091 self.queue_id = 0
1092 return
1093
1094 def pack(self):
1095 packed = []
1096 packed.append(struct.pack("!H", self.type))
1097 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1098 packed.append(struct.pack("!L", self.queue_id))
1099 length = sum([len(x) for x in packed])
1100 packed[1] = struct.pack("!H", length)
1101 return ''.join(packed)
1102
1103 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001104 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001105 obj = set_queue()
Dan Talaycof6202252013-07-02 01:00:29 -07001106 _type = reader.read("!H")[0]
1107 assert(_type == 21)
1108 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001109 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001110 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001111 obj.queue_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001112 return obj
1113
1114 def __eq__(self, other):
1115 if type(self) != type(other): return False
1116 if self.queue_id != other.queue_id: return False
1117 return True
1118
Rich Lanec2ee4b82013-04-24 17:12:38 -07001119 def pretty_print(self, q):
1120 q.text("set_queue {")
1121 with q.group():
1122 with q.indent(2):
1123 q.breakable()
1124 q.text("queue_id = ");
1125 q.text("%#x" % self.queue_id)
1126 q.breakable()
1127 q.text('}')
1128
Rich Lane7dcdf022013-12-11 14:45:27 -08001129action.subtypes[21] = set_queue
Rich Lanec2ee4b82013-04-24 17:12:38 -07001130
Rich Lanec2ee4b82013-04-24 17:12:38 -07001131