blob: 7cf5acb488f4f5947e6807e20ab095883dba82a4 [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.of11']
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[1] = struct.pack("!H", length)
90 return ''.join(packed)
91
Rich Lane7dcdf022013-12-11 14:45:27 -080092 @staticmethod
93 def unpack(reader):
94 subtype, = reader.peek('!L', 4)
Rich Lane95f7fc92014-01-27 17:08:16 -080095 subclass = experimenter.subtypes.get(subtype)
96 if subclass:
97 return subclass.unpack(reader)
98
99 obj = experimenter()
100 _type = reader.read("!H")[0]
101 assert(_type == 65535)
102 _len = reader.read("!H")[0]
103 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800104 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800105 obj.experimenter = reader.read("!L")[0]
106 obj.data = str(reader.read_all())
107 return obj
108
109 def __eq__(self, other):
110 if type(self) != type(other): return False
111 if self.experimenter != other.experimenter: return False
112 if self.data != other.data: return False
113 return True
114
115 def pretty_print(self, q):
116 q.text("experimenter {")
117 with q.group():
118 with q.indent(2):
119 q.breakable()
120 q.text("data = ");
121 q.pp(self.data)
122 q.breakable()
123 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800124
125action.subtypes[65535] = experimenter
126
127class bsn(experimenter):
128 subtypes = {}
129
Rich Lane95f7fc92014-01-27 17:08:16 -0800130 type = 65535
131 experimenter = 6035143
132
133 def __init__(self, subtype=None):
134 if subtype != None:
135 self.subtype = subtype
136 else:
137 self.subtype = 0
138 return
139
140 def pack(self):
141 packed = []
142 packed.append(struct.pack("!H", self.type))
143 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
144 packed.append(struct.pack("!L", self.experimenter))
145 packed.append(struct.pack("!L", self.subtype))
146 packed.append('\x00' * 4)
147 length = sum([len(x) for x in packed])
148 packed[1] = struct.pack("!H", length)
149 return ''.join(packed)
150
Rich Lane7dcdf022013-12-11 14:45:27 -0800151 @staticmethod
152 def unpack(reader):
153 subtype, = reader.peek('!L', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800154 subclass = bsn.subtypes.get(subtype)
155 if subclass:
156 return subclass.unpack(reader)
157
158 obj = bsn()
159 _type = reader.read("!H")[0]
160 assert(_type == 65535)
161 _len = reader.read("!H")[0]
162 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800163 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800164 _experimenter = reader.read("!L")[0]
165 assert(_experimenter == 6035143)
166 obj.subtype = reader.read("!L")[0]
167 reader.skip(4)
168 return obj
169
170 def __eq__(self, other):
171 if type(self) != type(other): return False
172 if self.subtype != other.subtype: return False
173 return True
174
175 def pretty_print(self, q):
176 q.text("bsn {")
177 with q.group():
178 with q.indent(2):
179 q.breakable()
180 q.breakable()
181 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800182
183experimenter.subtypes[6035143] = bsn
184
Rich Lane5587ab12014-06-30 11:19:09 -0700185class bsn_checksum(bsn):
186 type = 65535
187 experimenter = 6035143
188 subtype = 4
189
190 def __init__(self, checksum=None):
191 if checksum != None:
192 self.checksum = checksum
193 else:
194 self.checksum = 0
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(struct.pack("!L", self.experimenter))
202 packed.append(struct.pack("!L", self.subtype))
203 packed.append(util.pack_checksum_128(self.checksum))
204 length = sum([len(x) for x in packed])
205 packed[1] = struct.pack("!H", length)
206 return ''.join(packed)
207
208 @staticmethod
209 def unpack(reader):
210 obj = bsn_checksum()
211 _type = reader.read("!H")[0]
212 assert(_type == 65535)
213 _len = reader.read("!H")[0]
214 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800215 reader = orig_reader.slice(_len, 4)
Rich Lane5587ab12014-06-30 11:19:09 -0700216 _experimenter = reader.read("!L")[0]
217 assert(_experimenter == 6035143)
218 _subtype = reader.read("!L")[0]
219 assert(_subtype == 4)
220 obj.checksum = util.unpack_checksum_128(reader)
221 return obj
222
223 def __eq__(self, other):
224 if type(self) != type(other): return False
225 if self.checksum != other.checksum: return False
226 return True
227
228 def pretty_print(self, q):
229 q.text("bsn_checksum {")
230 with q.group():
231 with q.indent(2):
232 q.breakable()
233 q.text("checksum = ");
234 q.pp(self.checksum)
235 q.breakable()
236 q.text('}')
237
238bsn.subtypes[4] = bsn_checksum
239
Rich Lane7dcdf022013-12-11 14:45:27 -0800240class bsn_mirror(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700241 type = 65535
242 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -0700243 subtype = 1
244
245 def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None):
246 if dest_port != None:
247 self.dest_port = dest_port
248 else:
249 self.dest_port = 0
250 if vlan_tag != None:
251 self.vlan_tag = vlan_tag
252 else:
253 self.vlan_tag = 0
254 if copy_stage != None:
255 self.copy_stage = copy_stage
256 else:
257 self.copy_stage = 0
258 return
259
260 def pack(self):
261 packed = []
262 packed.append(struct.pack("!H", self.type))
263 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
264 packed.append(struct.pack("!L", self.experimenter))
265 packed.append(struct.pack("!L", self.subtype))
266 packed.append(struct.pack("!L", self.dest_port))
267 packed.append(struct.pack("!L", self.vlan_tag))
268 packed.append(struct.pack("!B", self.copy_stage))
269 packed.append('\x00' * 3)
270 length = sum([len(x) for x in packed])
271 packed[1] = struct.pack("!H", length)
272 return ''.join(packed)
273
274 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800275 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700276 obj = bsn_mirror()
Dan Talaycof6202252013-07-02 01:00:29 -0700277 _type = reader.read("!H")[0]
278 assert(_type == 65535)
279 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800280 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800281 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700282 _experimenter = reader.read("!L")[0]
283 assert(_experimenter == 6035143)
284 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700285 assert(_subtype == 1)
Dan Talaycof6202252013-07-02 01:00:29 -0700286 obj.dest_port = reader.read("!L")[0]
287 obj.vlan_tag = reader.read("!L")[0]
288 obj.copy_stage = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700289 reader.skip(3)
290 return obj
291
292 def __eq__(self, other):
293 if type(self) != type(other): return False
294 if self.dest_port != other.dest_port: return False
295 if self.vlan_tag != other.vlan_tag: return False
296 if self.copy_stage != other.copy_stage: return False
297 return True
298
Rich Lanec2ee4b82013-04-24 17:12:38 -0700299 def pretty_print(self, q):
300 q.text("bsn_mirror {")
301 with q.group():
302 with q.indent(2):
303 q.breakable()
304 q.text("dest_port = ");
305 q.text("%#x" % self.dest_port)
306 q.text(","); q.breakable()
307 q.text("vlan_tag = ");
308 q.text("%#x" % self.vlan_tag)
309 q.text(","); q.breakable()
310 q.text("copy_stage = ");
311 q.text("%#x" % self.copy_stage)
312 q.breakable()
313 q.text('}')
314
Rich Lane7dcdf022013-12-11 14:45:27 -0800315bsn.subtypes[1] = bsn_mirror
316
317class bsn_set_tunnel_dst(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700318 type = 65535
319 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -0700320 subtype = 2
321
322 def __init__(self, dst=None):
323 if dst != None:
324 self.dst = dst
325 else:
326 self.dst = 0
327 return
328
329 def pack(self):
330 packed = []
331 packed.append(struct.pack("!H", self.type))
332 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
333 packed.append(struct.pack("!L", self.experimenter))
334 packed.append(struct.pack("!L", self.subtype))
335 packed.append(struct.pack("!L", self.dst))
336 length = sum([len(x) for x in packed])
337 packed[1] = struct.pack("!H", length)
338 return ''.join(packed)
339
340 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800341 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700342 obj = bsn_set_tunnel_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700343 _type = reader.read("!H")[0]
344 assert(_type == 65535)
345 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800346 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800347 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700348 _experimenter = reader.read("!L")[0]
349 assert(_experimenter == 6035143)
350 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700351 assert(_subtype == 2)
Dan Talaycof6202252013-07-02 01:00:29 -0700352 obj.dst = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700353 return obj
354
355 def __eq__(self, other):
356 if type(self) != type(other): return False
357 if self.dst != other.dst: return False
358 return True
359
Rich Lanec2ee4b82013-04-24 17:12:38 -0700360 def pretty_print(self, q):
361 q.text("bsn_set_tunnel_dst {")
362 with q.group():
363 with q.indent(2):
364 q.breakable()
365 q.text("dst = ");
366 q.text("%#x" % self.dst)
367 q.breakable()
368 q.text('}')
369
Rich Lane7dcdf022013-12-11 14:45:27 -0800370bsn.subtypes[2] = bsn_set_tunnel_dst
371
372class copy_ttl_in(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700373 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -0700374
375 def __init__(self):
376 return
377
378 def pack(self):
379 packed = []
380 packed.append(struct.pack("!H", self.type))
381 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
382 packed.append('\x00' * 4)
383 length = sum([len(x) for x in packed])
384 packed[1] = struct.pack("!H", length)
385 return ''.join(packed)
386
387 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800388 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700389 obj = copy_ttl_in()
Dan Talaycof6202252013-07-02 01:00:29 -0700390 _type = reader.read("!H")[0]
391 assert(_type == 12)
392 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800393 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800394 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700395 reader.skip(4)
396 return obj
397
398 def __eq__(self, other):
399 if type(self) != type(other): return False
400 return True
401
Rich Lanec2ee4b82013-04-24 17:12:38 -0700402 def pretty_print(self, q):
403 q.text("copy_ttl_in {")
404 with q.group():
405 with q.indent(2):
406 q.breakable()
407 q.breakable()
408 q.text('}')
409
Rich Lane7dcdf022013-12-11 14:45:27 -0800410action.subtypes[12] = copy_ttl_in
411
412class copy_ttl_out(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700413 type = 11
Rich Lanec2ee4b82013-04-24 17:12:38 -0700414
415 def __init__(self):
416 return
417
418 def pack(self):
419 packed = []
420 packed.append(struct.pack("!H", self.type))
421 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
422 packed.append('\x00' * 4)
423 length = sum([len(x) for x in packed])
424 packed[1] = struct.pack("!H", length)
425 return ''.join(packed)
426
427 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800428 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700429 obj = copy_ttl_out()
Dan Talaycof6202252013-07-02 01:00:29 -0700430 _type = reader.read("!H")[0]
431 assert(_type == 11)
432 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800433 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800434 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700435 reader.skip(4)
436 return obj
437
438 def __eq__(self, other):
439 if type(self) != type(other): return False
440 return True
441
Rich Lanec2ee4b82013-04-24 17:12:38 -0700442 def pretty_print(self, q):
443 q.text("copy_ttl_out {")
444 with q.group():
445 with q.indent(2):
446 q.breakable()
447 q.breakable()
448 q.text('}')
449
Rich Lane7dcdf022013-12-11 14:45:27 -0800450action.subtypes[11] = copy_ttl_out
451
452class dec_mpls_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700453 type = 16
Rich Lanec2ee4b82013-04-24 17:12:38 -0700454
455 def __init__(self):
456 return
457
458 def pack(self):
459 packed = []
460 packed.append(struct.pack("!H", self.type))
461 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
462 packed.append('\x00' * 4)
463 length = sum([len(x) for x in packed])
464 packed[1] = struct.pack("!H", length)
465 return ''.join(packed)
466
467 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800468 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700469 obj = dec_mpls_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700470 _type = reader.read("!H")[0]
471 assert(_type == 16)
472 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800473 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800474 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700475 reader.skip(4)
476 return obj
477
478 def __eq__(self, other):
479 if type(self) != type(other): return False
480 return True
481
Rich Lanec2ee4b82013-04-24 17:12:38 -0700482 def pretty_print(self, q):
483 q.text("dec_mpls_ttl {")
484 with q.group():
485 with q.indent(2):
486 q.breakable()
487 q.breakable()
488 q.text('}')
489
Rich Lane7dcdf022013-12-11 14:45:27 -0800490action.subtypes[16] = dec_mpls_ttl
491
492class dec_nw_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700493 type = 24
Rich Lanec2ee4b82013-04-24 17:12:38 -0700494
495 def __init__(self):
496 return
497
498 def pack(self):
499 packed = []
500 packed.append(struct.pack("!H", self.type))
501 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
502 packed.append('\x00' * 4)
503 length = sum([len(x) for x in packed])
504 packed[1] = struct.pack("!H", length)
505 return ''.join(packed)
506
507 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800508 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700509 obj = dec_nw_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700510 _type = reader.read("!H")[0]
511 assert(_type == 24)
512 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800513 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800514 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700515 reader.skip(4)
516 return obj
517
518 def __eq__(self, other):
519 if type(self) != type(other): return False
520 return True
521
Rich Lanec2ee4b82013-04-24 17:12:38 -0700522 def pretty_print(self, q):
523 q.text("dec_nw_ttl {")
524 with q.group():
525 with q.indent(2):
526 q.breakable()
527 q.breakable()
528 q.text('}')
529
Rich Lane7dcdf022013-12-11 14:45:27 -0800530action.subtypes[24] = dec_nw_ttl
531
532class group(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700533 type = 22
Rich Lanec2ee4b82013-04-24 17:12:38 -0700534
535 def __init__(self, group_id=None):
536 if group_id != None:
537 self.group_id = group_id
538 else:
539 self.group_id = 0
540 return
541
542 def pack(self):
543 packed = []
544 packed.append(struct.pack("!H", self.type))
545 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
546 packed.append(struct.pack("!L", self.group_id))
547 length = sum([len(x) for x in packed])
548 packed[1] = struct.pack("!H", length)
549 return ''.join(packed)
550
551 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800552 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700553 obj = group()
Dan Talaycof6202252013-07-02 01:00:29 -0700554 _type = reader.read("!H")[0]
555 assert(_type == 22)
556 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800557 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800558 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700559 obj.group_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700560 return obj
561
562 def __eq__(self, other):
563 if type(self) != type(other): return False
564 if self.group_id != other.group_id: return False
565 return True
566
Rich Lanec2ee4b82013-04-24 17:12:38 -0700567 def pretty_print(self, q):
568 q.text("group {")
569 with q.group():
570 with q.indent(2):
571 q.breakable()
572 q.text("group_id = ");
573 q.text("%#x" % self.group_id)
574 q.breakable()
575 q.text('}')
576
Rich Lane7dcdf022013-12-11 14:45:27 -0800577action.subtypes[22] = group
578
579class nicira(experimenter):
580 subtypes = {}
581
Rich Lane95f7fc92014-01-27 17:08:16 -0800582 type = 65535
583 experimenter = 8992
584
585 def __init__(self, subtype=None):
586 if subtype != None:
587 self.subtype = subtype
588 else:
589 self.subtype = 0
590 return
591
592 def pack(self):
593 packed = []
594 packed.append(struct.pack("!H", self.type))
595 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
596 packed.append(struct.pack("!L", self.experimenter))
597 packed.append(struct.pack("!H", self.subtype))
598 packed.append('\x00' * 2)
599 packed.append('\x00' * 4)
600 length = sum([len(x) for x in packed])
601 packed[1] = struct.pack("!H", length)
602 return ''.join(packed)
603
Rich Lane7dcdf022013-12-11 14:45:27 -0800604 @staticmethod
605 def unpack(reader):
606 subtype, = reader.peek('!H', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800607 subclass = nicira.subtypes.get(subtype)
608 if subclass:
609 return subclass.unpack(reader)
610
611 obj = nicira()
612 _type = reader.read("!H")[0]
613 assert(_type == 65535)
614 _len = reader.read("!H")[0]
615 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800616 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800617 _experimenter = reader.read("!L")[0]
618 assert(_experimenter == 8992)
619 obj.subtype = reader.read("!H")[0]
620 reader.skip(2)
621 reader.skip(4)
622 return obj
623
624 def __eq__(self, other):
625 if type(self) != type(other): return False
626 if self.subtype != other.subtype: return False
627 return True
628
629 def pretty_print(self, q):
630 q.text("nicira {")
631 with q.group():
632 with q.indent(2):
633 q.breakable()
634 q.breakable()
635 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800636
637experimenter.subtypes[8992] = nicira
638
639class nicira_dec_ttl(nicira):
Dan Talaycof6202252013-07-02 01:00:29 -0700640 type = 65535
641 experimenter = 8992
Rich Lanec2ee4b82013-04-24 17:12:38 -0700642 subtype = 18
643
644 def __init__(self):
645 return
646
647 def pack(self):
648 packed = []
649 packed.append(struct.pack("!H", self.type))
650 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
651 packed.append(struct.pack("!L", self.experimenter))
652 packed.append(struct.pack("!H", self.subtype))
653 packed.append('\x00' * 2)
654 packed.append('\x00' * 4)
655 length = sum([len(x) for x in packed])
656 packed[1] = struct.pack("!H", length)
657 return ''.join(packed)
658
659 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800660 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700661 obj = nicira_dec_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700662 _type = reader.read("!H")[0]
663 assert(_type == 65535)
664 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800665 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800666 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700667 _experimenter = reader.read("!L")[0]
668 assert(_experimenter == 8992)
669 _subtype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700670 assert(_subtype == 18)
671 reader.skip(2)
672 reader.skip(4)
673 return obj
674
675 def __eq__(self, other):
676 if type(self) != type(other): return False
677 return True
678
Rich Lanec2ee4b82013-04-24 17:12:38 -0700679 def pretty_print(self, q):
680 q.text("nicira_dec_ttl {")
681 with q.group():
682 with q.indent(2):
683 q.breakable()
684 q.breakable()
685 q.text('}')
686
Rich Lane7dcdf022013-12-11 14:45:27 -0800687nicira.subtypes[18] = nicira_dec_ttl
688
689class output(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700690 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700691
692 def __init__(self, port=None, max_len=None):
693 if port != None:
694 self.port = port
695 else:
696 self.port = 0
697 if max_len != None:
698 self.max_len = max_len
699 else:
700 self.max_len = 0
701 return
702
703 def pack(self):
704 packed = []
705 packed.append(struct.pack("!H", self.type))
706 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700707 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700708 packed.append(struct.pack("!H", self.max_len))
709 packed.append('\x00' * 6)
710 length = sum([len(x) for x in packed])
711 packed[1] = struct.pack("!H", length)
712 return ''.join(packed)
713
714 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800715 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700716 obj = output()
Dan Talaycof6202252013-07-02 01:00:29 -0700717 _type = reader.read("!H")[0]
718 assert(_type == 0)
719 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800720 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800721 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700722 obj.port = util.unpack_port_no(reader)
723 obj.max_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700724 reader.skip(6)
725 return obj
726
727 def __eq__(self, other):
728 if type(self) != type(other): return False
729 if self.port != other.port: return False
730 if self.max_len != other.max_len: return False
731 return True
732
Rich Lanec2ee4b82013-04-24 17:12:38 -0700733 def pretty_print(self, q):
734 q.text("output {")
735 with q.group():
736 with q.indent(2):
737 q.breakable()
738 q.text("port = ");
739 q.text(util.pretty_port(self.port))
740 q.text(","); q.breakable()
741 q.text("max_len = ");
742 q.text("%#x" % self.max_len)
743 q.breakable()
744 q.text('}')
745
Rich Lane7dcdf022013-12-11 14:45:27 -0800746action.subtypes[0] = output
747
748class pop_mpls(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700749 type = 20
Rich Lanec2ee4b82013-04-24 17:12:38 -0700750
751 def __init__(self, ethertype=None):
752 if ethertype != None:
753 self.ethertype = ethertype
754 else:
755 self.ethertype = 0
756 return
757
758 def pack(self):
759 packed = []
760 packed.append(struct.pack("!H", self.type))
761 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
762 packed.append(struct.pack("!H", self.ethertype))
763 packed.append('\x00' * 2)
764 length = sum([len(x) for x in packed])
765 packed[1] = struct.pack("!H", length)
766 return ''.join(packed)
767
768 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800769 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700770 obj = pop_mpls()
Dan Talaycof6202252013-07-02 01:00:29 -0700771 _type = reader.read("!H")[0]
772 assert(_type == 20)
773 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800774 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800775 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700776 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700777 reader.skip(2)
778 return obj
779
780 def __eq__(self, other):
781 if type(self) != type(other): return False
782 if self.ethertype != other.ethertype: return False
783 return True
784
Rich Lanec2ee4b82013-04-24 17:12:38 -0700785 def pretty_print(self, q):
786 q.text("pop_mpls {")
787 with q.group():
788 with q.indent(2):
789 q.breakable()
790 q.text("ethertype = ");
791 q.text("%#x" % self.ethertype)
792 q.breakable()
793 q.text('}')
794
Rich Lane7dcdf022013-12-11 14:45:27 -0800795action.subtypes[20] = pop_mpls
796
797class pop_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700798 type = 18
Rich Lanec2ee4b82013-04-24 17:12:38 -0700799
800 def __init__(self):
801 return
802
803 def pack(self):
804 packed = []
805 packed.append(struct.pack("!H", self.type))
806 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
807 packed.append('\x00' * 4)
808 length = sum([len(x) for x in packed])
809 packed[1] = struct.pack("!H", length)
810 return ''.join(packed)
811
812 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800813 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700814 obj = pop_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -0700815 _type = reader.read("!H")[0]
816 assert(_type == 18)
817 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800818 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800819 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700820 reader.skip(4)
821 return obj
822
823 def __eq__(self, other):
824 if type(self) != type(other): return False
825 return True
826
Rich Lanec2ee4b82013-04-24 17:12:38 -0700827 def pretty_print(self, q):
828 q.text("pop_vlan {")
829 with q.group():
830 with q.indent(2):
831 q.breakable()
832 q.breakable()
833 q.text('}')
834
Rich Lane7dcdf022013-12-11 14:45:27 -0800835action.subtypes[18] = pop_vlan
836
837class push_mpls(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700838 type = 19
Rich Lanec2ee4b82013-04-24 17:12:38 -0700839
840 def __init__(self, ethertype=None):
841 if ethertype != None:
842 self.ethertype = ethertype
843 else:
844 self.ethertype = 0
845 return
846
847 def pack(self):
848 packed = []
849 packed.append(struct.pack("!H", self.type))
850 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
851 packed.append(struct.pack("!H", self.ethertype))
852 packed.append('\x00' * 2)
853 length = sum([len(x) for x in packed])
854 packed[1] = struct.pack("!H", length)
855 return ''.join(packed)
856
857 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800858 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700859 obj = push_mpls()
Dan Talaycof6202252013-07-02 01:00:29 -0700860 _type = reader.read("!H")[0]
861 assert(_type == 19)
862 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800863 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800864 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700865 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700866 reader.skip(2)
867 return obj
868
869 def __eq__(self, other):
870 if type(self) != type(other): return False
871 if self.ethertype != other.ethertype: return False
872 return True
873
Rich Lanec2ee4b82013-04-24 17:12:38 -0700874 def pretty_print(self, q):
875 q.text("push_mpls {")
876 with q.group():
877 with q.indent(2):
878 q.breakable()
879 q.text("ethertype = ");
880 q.text("%#x" % self.ethertype)
881 q.breakable()
882 q.text('}')
883
Rich Lane7dcdf022013-12-11 14:45:27 -0800884action.subtypes[19] = push_mpls
885
886class push_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700887 type = 17
Rich Lanec2ee4b82013-04-24 17:12:38 -0700888
889 def __init__(self, ethertype=None):
890 if ethertype != None:
891 self.ethertype = ethertype
892 else:
893 self.ethertype = 0
894 return
895
896 def pack(self):
897 packed = []
898 packed.append(struct.pack("!H", self.type))
899 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
900 packed.append(struct.pack("!H", self.ethertype))
901 packed.append('\x00' * 2)
902 length = sum([len(x) for x in packed])
903 packed[1] = struct.pack("!H", length)
904 return ''.join(packed)
905
906 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800907 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700908 obj = push_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -0700909 _type = reader.read("!H")[0]
910 assert(_type == 17)
911 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800912 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800913 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700914 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700915 reader.skip(2)
916 return obj
917
918 def __eq__(self, other):
919 if type(self) != type(other): return False
920 if self.ethertype != other.ethertype: return False
921 return True
922
Rich Lanec2ee4b82013-04-24 17:12:38 -0700923 def pretty_print(self, q):
924 q.text("push_vlan {")
925 with q.group():
926 with q.indent(2):
927 q.breakable()
928 q.text("ethertype = ");
929 q.text("%#x" % self.ethertype)
930 q.breakable()
931 q.text('}')
932
Rich Lane7dcdf022013-12-11 14:45:27 -0800933action.subtypes[17] = push_vlan
934
935class set_dl_dst(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700936 type = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -0700937
938 def __init__(self, dl_addr=None):
939 if dl_addr != None:
940 self.dl_addr = dl_addr
941 else:
942 self.dl_addr = [0,0,0,0,0,0]
943 return
944
945 def pack(self):
946 packed = []
947 packed.append(struct.pack("!H", self.type))
948 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
949 packed.append(struct.pack("!6B", *self.dl_addr))
950 packed.append('\x00' * 6)
951 length = sum([len(x) for x in packed])
952 packed[1] = struct.pack("!H", length)
953 return ''.join(packed)
954
955 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800956 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700957 obj = set_dl_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700958 _type = reader.read("!H")[0]
959 assert(_type == 4)
960 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800961 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800962 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700963 obj.dl_addr = list(reader.read('!6B'))
964 reader.skip(6)
965 return obj
966
967 def __eq__(self, other):
968 if type(self) != type(other): return False
969 if self.dl_addr != other.dl_addr: return False
970 return True
971
Rich Lanec2ee4b82013-04-24 17:12:38 -0700972 def pretty_print(self, q):
973 q.text("set_dl_dst {")
974 with q.group():
975 with q.indent(2):
976 q.breakable()
977 q.text("dl_addr = ");
978 q.text(util.pretty_mac(self.dl_addr))
979 q.breakable()
980 q.text('}')
981
Rich Lane7dcdf022013-12-11 14:45:27 -0800982action.subtypes[4] = set_dl_dst
983
984class set_dl_src(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700985 type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -0700986
987 def __init__(self, dl_addr=None):
988 if dl_addr != None:
989 self.dl_addr = dl_addr
990 else:
991 self.dl_addr = [0,0,0,0,0,0]
992 return
993
994 def pack(self):
995 packed = []
996 packed.append(struct.pack("!H", self.type))
997 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
998 packed.append(struct.pack("!6B", *self.dl_addr))
999 packed.append('\x00' * 6)
1000 length = sum([len(x) for x in packed])
1001 packed[1] = struct.pack("!H", length)
1002 return ''.join(packed)
1003
1004 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001005 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001006 obj = set_dl_src()
Dan Talaycof6202252013-07-02 01:00:29 -07001007 _type = reader.read("!H")[0]
1008 assert(_type == 3)
1009 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001010 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001011 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001012 obj.dl_addr = list(reader.read('!6B'))
1013 reader.skip(6)
1014 return obj
1015
1016 def __eq__(self, other):
1017 if type(self) != type(other): return False
1018 if self.dl_addr != other.dl_addr: return False
1019 return True
1020
Rich Lanec2ee4b82013-04-24 17:12:38 -07001021 def pretty_print(self, q):
1022 q.text("set_dl_src {")
1023 with q.group():
1024 with q.indent(2):
1025 q.breakable()
1026 q.text("dl_addr = ");
1027 q.text(util.pretty_mac(self.dl_addr))
1028 q.breakable()
1029 q.text('}')
1030
Rich Lane7dcdf022013-12-11 14:45:27 -08001031action.subtypes[3] = set_dl_src
1032
1033class set_mpls_label(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001034 type = 13
Rich Lanec2ee4b82013-04-24 17:12:38 -07001035
1036 def __init__(self, mpls_label=None):
1037 if mpls_label != None:
1038 self.mpls_label = mpls_label
1039 else:
1040 self.mpls_label = 0
1041 return
1042
1043 def pack(self):
1044 packed = []
1045 packed.append(struct.pack("!H", self.type))
1046 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1047 packed.append(struct.pack("!L", self.mpls_label))
1048 length = sum([len(x) for x in packed])
1049 packed[1] = struct.pack("!H", length)
1050 return ''.join(packed)
1051
1052 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001053 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001054 obj = set_mpls_label()
Dan Talaycof6202252013-07-02 01:00:29 -07001055 _type = reader.read("!H")[0]
1056 assert(_type == 13)
1057 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001058 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001059 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001060 obj.mpls_label = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001061 return obj
1062
1063 def __eq__(self, other):
1064 if type(self) != type(other): return False
1065 if self.mpls_label != other.mpls_label: return False
1066 return True
1067
Rich Lanec2ee4b82013-04-24 17:12:38 -07001068 def pretty_print(self, q):
1069 q.text("set_mpls_label {")
1070 with q.group():
1071 with q.indent(2):
1072 q.breakable()
1073 q.text("mpls_label = ");
1074 q.text("%#x" % self.mpls_label)
1075 q.breakable()
1076 q.text('}')
1077
Rich Lane7dcdf022013-12-11 14:45:27 -08001078action.subtypes[13] = set_mpls_label
1079
1080class set_mpls_tc(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001081 type = 14
Rich Lanec2ee4b82013-04-24 17:12:38 -07001082
1083 def __init__(self, mpls_tc=None):
1084 if mpls_tc != None:
1085 self.mpls_tc = mpls_tc
1086 else:
1087 self.mpls_tc = 0
1088 return
1089
1090 def pack(self):
1091 packed = []
1092 packed.append(struct.pack("!H", self.type))
1093 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1094 packed.append(struct.pack("!B", self.mpls_tc))
1095 packed.append('\x00' * 3)
1096 length = sum([len(x) for x in packed])
1097 packed[1] = struct.pack("!H", length)
1098 return ''.join(packed)
1099
1100 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001101 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001102 obj = set_mpls_tc()
Dan Talaycof6202252013-07-02 01:00:29 -07001103 _type = reader.read("!H")[0]
1104 assert(_type == 14)
1105 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001106 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001107 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001108 obj.mpls_tc = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001109 reader.skip(3)
1110 return obj
1111
1112 def __eq__(self, other):
1113 if type(self) != type(other): return False
1114 if self.mpls_tc != other.mpls_tc: return False
1115 return True
1116
Rich Lanec2ee4b82013-04-24 17:12:38 -07001117 def pretty_print(self, q):
1118 q.text("set_mpls_tc {")
1119 with q.group():
1120 with q.indent(2):
1121 q.breakable()
1122 q.text("mpls_tc = ");
1123 q.text("%#x" % self.mpls_tc)
1124 q.breakable()
1125 q.text('}')
1126
Rich Lane7dcdf022013-12-11 14:45:27 -08001127action.subtypes[14] = set_mpls_tc
1128
1129class set_mpls_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001130 type = 15
Rich Lanec2ee4b82013-04-24 17:12:38 -07001131
1132 def __init__(self, mpls_ttl=None):
1133 if mpls_ttl != None:
1134 self.mpls_ttl = mpls_ttl
1135 else:
1136 self.mpls_ttl = 0
1137 return
1138
1139 def pack(self):
1140 packed = []
1141 packed.append(struct.pack("!H", self.type))
1142 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1143 packed.append(struct.pack("!B", self.mpls_ttl))
1144 packed.append('\x00' * 3)
1145 length = sum([len(x) for x in packed])
1146 packed[1] = struct.pack("!H", length)
1147 return ''.join(packed)
1148
1149 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001150 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001151 obj = set_mpls_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -07001152 _type = reader.read("!H")[0]
1153 assert(_type == 15)
1154 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001155 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001156 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001157 obj.mpls_ttl = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001158 reader.skip(3)
1159 return obj
1160
1161 def __eq__(self, other):
1162 if type(self) != type(other): return False
1163 if self.mpls_ttl != other.mpls_ttl: return False
1164 return True
1165
Rich Lanec2ee4b82013-04-24 17:12:38 -07001166 def pretty_print(self, q):
1167 q.text("set_mpls_ttl {")
1168 with q.group():
1169 with q.indent(2):
1170 q.breakable()
1171 q.text("mpls_ttl = ");
1172 q.text("%#x" % self.mpls_ttl)
1173 q.breakable()
1174 q.text('}')
1175
Rich Lane7dcdf022013-12-11 14:45:27 -08001176action.subtypes[15] = set_mpls_ttl
1177
1178class set_nw_dst(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001179 type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07001180
1181 def __init__(self, nw_addr=None):
1182 if nw_addr != None:
1183 self.nw_addr = nw_addr
1184 else:
1185 self.nw_addr = 0
1186 return
1187
1188 def pack(self):
1189 packed = []
1190 packed.append(struct.pack("!H", self.type))
1191 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1192 packed.append(struct.pack("!L", self.nw_addr))
1193 length = sum([len(x) for x in packed])
1194 packed[1] = struct.pack("!H", length)
1195 return ''.join(packed)
1196
1197 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001198 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001199 obj = set_nw_dst()
Dan Talaycof6202252013-07-02 01:00:29 -07001200 _type = reader.read("!H")[0]
1201 assert(_type == 6)
1202 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001203 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001204 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001205 obj.nw_addr = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001206 return obj
1207
1208 def __eq__(self, other):
1209 if type(self) != type(other): return False
1210 if self.nw_addr != other.nw_addr: return False
1211 return True
1212
Rich Lanec2ee4b82013-04-24 17:12:38 -07001213 def pretty_print(self, q):
1214 q.text("set_nw_dst {")
1215 with q.group():
1216 with q.indent(2):
1217 q.breakable()
1218 q.text("nw_addr = ");
1219 q.text("%#x" % self.nw_addr)
1220 q.breakable()
1221 q.text('}')
1222
Rich Lane7dcdf022013-12-11 14:45:27 -08001223action.subtypes[6] = set_nw_dst
1224
1225class set_nw_ecn(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001226 type = 8
Rich Lanec2ee4b82013-04-24 17:12:38 -07001227
1228 def __init__(self, nw_ecn=None):
1229 if nw_ecn != None:
1230 self.nw_ecn = nw_ecn
1231 else:
1232 self.nw_ecn = 0
1233 return
1234
1235 def pack(self):
1236 packed = []
1237 packed.append(struct.pack("!H", self.type))
1238 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1239 packed.append(struct.pack("!B", self.nw_ecn))
1240 packed.append('\x00' * 3)
1241 length = sum([len(x) for x in packed])
1242 packed[1] = struct.pack("!H", length)
1243 return ''.join(packed)
1244
1245 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001246 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001247 obj = set_nw_ecn()
Dan Talaycof6202252013-07-02 01:00:29 -07001248 _type = reader.read("!H")[0]
1249 assert(_type == 8)
1250 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001251 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001252 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001253 obj.nw_ecn = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001254 reader.skip(3)
1255 return obj
1256
1257 def __eq__(self, other):
1258 if type(self) != type(other): return False
1259 if self.nw_ecn != other.nw_ecn: return False
1260 return True
1261
Rich Lanec2ee4b82013-04-24 17:12:38 -07001262 def pretty_print(self, q):
1263 q.text("set_nw_ecn {")
1264 with q.group():
1265 with q.indent(2):
1266 q.breakable()
1267 q.text("nw_ecn = ");
1268 q.text("%#x" % self.nw_ecn)
1269 q.breakable()
1270 q.text('}')
1271
Rich Lane7dcdf022013-12-11 14:45:27 -08001272action.subtypes[8] = set_nw_ecn
1273
1274class set_nw_src(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001275 type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07001276
1277 def __init__(self, nw_addr=None):
1278 if nw_addr != None:
1279 self.nw_addr = nw_addr
1280 else:
1281 self.nw_addr = 0
1282 return
1283
1284 def pack(self):
1285 packed = []
1286 packed.append(struct.pack("!H", self.type))
1287 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1288 packed.append(struct.pack("!L", self.nw_addr))
1289 length = sum([len(x) for x in packed])
1290 packed[1] = struct.pack("!H", length)
1291 return ''.join(packed)
1292
1293 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001294 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001295 obj = set_nw_src()
Dan Talaycof6202252013-07-02 01:00:29 -07001296 _type = reader.read("!H")[0]
1297 assert(_type == 5)
1298 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001299 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001300 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001301 obj.nw_addr = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001302 return obj
1303
1304 def __eq__(self, other):
1305 if type(self) != type(other): return False
1306 if self.nw_addr != other.nw_addr: return False
1307 return True
1308
Rich Lanec2ee4b82013-04-24 17:12:38 -07001309 def pretty_print(self, q):
1310 q.text("set_nw_src {")
1311 with q.group():
1312 with q.indent(2):
1313 q.breakable()
1314 q.text("nw_addr = ");
1315 q.text("%#x" % self.nw_addr)
1316 q.breakable()
1317 q.text('}')
1318
Rich Lane7dcdf022013-12-11 14:45:27 -08001319action.subtypes[5] = set_nw_src
1320
1321class set_nw_tos(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001322 type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07001323
1324 def __init__(self, nw_tos=None):
1325 if nw_tos != None:
1326 self.nw_tos = nw_tos
1327 else:
1328 self.nw_tos = 0
1329 return
1330
1331 def pack(self):
1332 packed = []
1333 packed.append(struct.pack("!H", self.type))
1334 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1335 packed.append(struct.pack("!B", self.nw_tos))
1336 packed.append('\x00' * 3)
1337 length = sum([len(x) for x in packed])
1338 packed[1] = struct.pack("!H", length)
1339 return ''.join(packed)
1340
1341 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001342 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001343 obj = set_nw_tos()
Dan Talaycof6202252013-07-02 01:00:29 -07001344 _type = reader.read("!H")[0]
1345 assert(_type == 7)
1346 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001347 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001348 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001349 obj.nw_tos = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001350 reader.skip(3)
1351 return obj
1352
1353 def __eq__(self, other):
1354 if type(self) != type(other): return False
1355 if self.nw_tos != other.nw_tos: return False
1356 return True
1357
Rich Lanec2ee4b82013-04-24 17:12:38 -07001358 def pretty_print(self, q):
1359 q.text("set_nw_tos {")
1360 with q.group():
1361 with q.indent(2):
1362 q.breakable()
1363 q.text("nw_tos = ");
1364 q.text("%#x" % self.nw_tos)
1365 q.breakable()
1366 q.text('}')
1367
Rich Lane7dcdf022013-12-11 14:45:27 -08001368action.subtypes[7] = set_nw_tos
1369
1370class set_nw_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001371 type = 23
Rich Lanec2ee4b82013-04-24 17:12:38 -07001372
1373 def __init__(self, nw_ttl=None):
1374 if nw_ttl != None:
1375 self.nw_ttl = nw_ttl
1376 else:
1377 self.nw_ttl = 0
1378 return
1379
1380 def pack(self):
1381 packed = []
1382 packed.append(struct.pack("!H", self.type))
1383 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1384 packed.append(struct.pack("!B", self.nw_ttl))
1385 packed.append('\x00' * 3)
1386 length = sum([len(x) for x in packed])
1387 packed[1] = struct.pack("!H", length)
1388 return ''.join(packed)
1389
1390 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001391 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001392 obj = set_nw_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -07001393 _type = reader.read("!H")[0]
1394 assert(_type == 23)
1395 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001396 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001397 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001398 obj.nw_ttl = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001399 reader.skip(3)
1400 return obj
1401
1402 def __eq__(self, other):
1403 if type(self) != type(other): return False
1404 if self.nw_ttl != other.nw_ttl: return False
1405 return True
1406
Rich Lanec2ee4b82013-04-24 17:12:38 -07001407 def pretty_print(self, q):
1408 q.text("set_nw_ttl {")
1409 with q.group():
1410 with q.indent(2):
1411 q.breakable()
1412 q.text("nw_ttl = ");
1413 q.text("%#x" % self.nw_ttl)
1414 q.breakable()
1415 q.text('}')
1416
Rich Lane7dcdf022013-12-11 14:45:27 -08001417action.subtypes[23] = set_nw_ttl
1418
1419class set_queue(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001420 type = 21
Rich Lanec2ee4b82013-04-24 17:12:38 -07001421
1422 def __init__(self, queue_id=None):
1423 if queue_id != None:
1424 self.queue_id = queue_id
1425 else:
1426 self.queue_id = 0
1427 return
1428
1429 def pack(self):
1430 packed = []
1431 packed.append(struct.pack("!H", self.type))
1432 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1433 packed.append(struct.pack("!L", self.queue_id))
1434 length = sum([len(x) for x in packed])
1435 packed[1] = struct.pack("!H", length)
1436 return ''.join(packed)
1437
1438 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001439 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001440 obj = set_queue()
Dan Talaycof6202252013-07-02 01:00:29 -07001441 _type = reader.read("!H")[0]
1442 assert(_type == 21)
1443 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001444 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001445 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001446 obj.queue_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001447 return obj
1448
1449 def __eq__(self, other):
1450 if type(self) != type(other): return False
1451 if self.queue_id != other.queue_id: return False
1452 return True
1453
Rich Lanec2ee4b82013-04-24 17:12:38 -07001454 def pretty_print(self, q):
1455 q.text("set_queue {")
1456 with q.group():
1457 with q.indent(2):
1458 q.breakable()
1459 q.text("queue_id = ");
1460 q.text("%#x" % self.queue_id)
1461 q.breakable()
1462 q.text('}')
1463
Rich Lane7dcdf022013-12-11 14:45:27 -08001464action.subtypes[21] = set_queue
1465
1466class set_tp_dst(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001467 type = 10
Rich Lanec2ee4b82013-04-24 17:12:38 -07001468
1469 def __init__(self, tp_port=None):
1470 if tp_port != None:
1471 self.tp_port = tp_port
1472 else:
1473 self.tp_port = 0
1474 return
1475
1476 def pack(self):
1477 packed = []
1478 packed.append(struct.pack("!H", self.type))
1479 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1480 packed.append(struct.pack("!H", self.tp_port))
1481 packed.append('\x00' * 2)
1482 length = sum([len(x) for x in packed])
1483 packed[1] = struct.pack("!H", length)
1484 return ''.join(packed)
1485
1486 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001487 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001488 obj = set_tp_dst()
Dan Talaycof6202252013-07-02 01:00:29 -07001489 _type = reader.read("!H")[0]
1490 assert(_type == 10)
1491 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001492 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001493 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001494 obj.tp_port = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001495 reader.skip(2)
1496 return obj
1497
1498 def __eq__(self, other):
1499 if type(self) != type(other): return False
1500 if self.tp_port != other.tp_port: return False
1501 return True
1502
Rich Lanec2ee4b82013-04-24 17:12:38 -07001503 def pretty_print(self, q):
1504 q.text("set_tp_dst {")
1505 with q.group():
1506 with q.indent(2):
1507 q.breakable()
1508 q.text("tp_port = ");
1509 q.text("%#x" % self.tp_port)
1510 q.breakable()
1511 q.text('}')
1512
Rich Lane7dcdf022013-12-11 14:45:27 -08001513action.subtypes[10] = set_tp_dst
1514
1515class set_tp_src(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001516 type = 9
Rich Lanec2ee4b82013-04-24 17:12:38 -07001517
1518 def __init__(self, tp_port=None):
1519 if tp_port != None:
1520 self.tp_port = tp_port
1521 else:
1522 self.tp_port = 0
1523 return
1524
1525 def pack(self):
1526 packed = []
1527 packed.append(struct.pack("!H", self.type))
1528 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1529 packed.append(struct.pack("!H", self.tp_port))
1530 packed.append('\x00' * 2)
1531 length = sum([len(x) for x in packed])
1532 packed[1] = struct.pack("!H", length)
1533 return ''.join(packed)
1534
1535 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001536 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001537 obj = set_tp_src()
Dan Talaycof6202252013-07-02 01:00:29 -07001538 _type = reader.read("!H")[0]
1539 assert(_type == 9)
1540 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001541 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001542 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001543 obj.tp_port = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001544 reader.skip(2)
1545 return obj
1546
1547 def __eq__(self, other):
1548 if type(self) != type(other): return False
1549 if self.tp_port != other.tp_port: return False
1550 return True
1551
Rich Lanec2ee4b82013-04-24 17:12:38 -07001552 def pretty_print(self, q):
1553 q.text("set_tp_src {")
1554 with q.group():
1555 with q.indent(2):
1556 q.breakable()
1557 q.text("tp_port = ");
1558 q.text("%#x" % self.tp_port)
1559 q.breakable()
1560 q.text('}')
1561
Rich Lane7dcdf022013-12-11 14:45:27 -08001562action.subtypes[9] = set_tp_src
1563
1564class set_vlan_pcp(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001565 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07001566
1567 def __init__(self, vlan_pcp=None):
1568 if vlan_pcp != None:
1569 self.vlan_pcp = vlan_pcp
1570 else:
1571 self.vlan_pcp = 0
1572 return
1573
1574 def pack(self):
1575 packed = []
1576 packed.append(struct.pack("!H", self.type))
1577 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1578 packed.append(struct.pack("!B", self.vlan_pcp))
1579 packed.append('\x00' * 3)
1580 length = sum([len(x) for x in packed])
1581 packed[1] = struct.pack("!H", length)
1582 return ''.join(packed)
1583
1584 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001585 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001586 obj = set_vlan_pcp()
Dan Talaycof6202252013-07-02 01:00:29 -07001587 _type = reader.read("!H")[0]
1588 assert(_type == 2)
1589 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001590 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001591 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001592 obj.vlan_pcp = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001593 reader.skip(3)
1594 return obj
1595
1596 def __eq__(self, other):
1597 if type(self) != type(other): return False
1598 if self.vlan_pcp != other.vlan_pcp: return False
1599 return True
1600
Rich Lanec2ee4b82013-04-24 17:12:38 -07001601 def pretty_print(self, q):
1602 q.text("set_vlan_pcp {")
1603 with q.group():
1604 with q.indent(2):
1605 q.breakable()
1606 q.text("vlan_pcp = ");
1607 q.text("%#x" % self.vlan_pcp)
1608 q.breakable()
1609 q.text('}')
1610
Rich Lane7dcdf022013-12-11 14:45:27 -08001611action.subtypes[2] = set_vlan_pcp
1612
1613class set_vlan_vid(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001614 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07001615
1616 def __init__(self, vlan_vid=None):
1617 if vlan_vid != None:
1618 self.vlan_vid = vlan_vid
1619 else:
1620 self.vlan_vid = 0
1621 return
1622
1623 def pack(self):
1624 packed = []
1625 packed.append(struct.pack("!H", self.type))
1626 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1627 packed.append(struct.pack("!H", self.vlan_vid))
1628 packed.append('\x00' * 2)
1629 length = sum([len(x) for x in packed])
1630 packed[1] = struct.pack("!H", length)
1631 return ''.join(packed)
1632
1633 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001634 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001635 obj = set_vlan_vid()
Dan Talaycof6202252013-07-02 01:00:29 -07001636 _type = reader.read("!H")[0]
1637 assert(_type == 1)
1638 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001639 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001640 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001641 obj.vlan_vid = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001642 reader.skip(2)
1643 return obj
1644
1645 def __eq__(self, other):
1646 if type(self) != type(other): return False
1647 if self.vlan_vid != other.vlan_vid: return False
1648 return True
1649
Rich Lanec2ee4b82013-04-24 17:12:38 -07001650 def pretty_print(self, q):
1651 q.text("set_vlan_vid {")
1652 with q.group():
1653 with q.indent(2):
1654 q.breakable()
1655 q.text("vlan_vid = ");
1656 q.text("%#x" % self.vlan_vid)
1657 q.breakable()
1658 q.text('}')
1659
Rich Lane7dcdf022013-12-11 14:45:27 -08001660action.subtypes[1] = set_vlan_vid
Rich Lanec2ee4b82013-04-24 17:12:38 -07001661
Rich Lanec2ee4b82013-04-24 17:12:38 -07001662