blob: 3ad2c90c0abbe4caa9fd805da331a6699ffbce24 [file] [log] [blame]
Matteo Scandoloa229eca2017-08-08 13:05:28 -07001
2# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
Rich Lanec2ee4b82013-04-24 17:12:38 -070017# Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
18# Copyright (c) 2011, 2012 Open Networking Foundation
19# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
Dan Talaycof6202252013-07-02 01:00:29 -070020# See the file LICENSE.pyloxi which should have been included in the source distribution
Rich Lanec2ee4b82013-04-24 17:12:38 -070021
Rich Lane7dcdf022013-12-11 14:45:27 -080022# Automatically generated by LOXI from template module.py
Rich Lanec2ee4b82013-04-24 17:12:38 -070023# Do not modify
24
25import struct
Rich Lane7dcdf022013-12-11 14:45:27 -080026import loxi
Rich Lanec2ee4b82013-04-24 17:12:38 -070027import util
28import loxi.generic_util
Rich Lanec2ee4b82013-04-24 17:12:38 -070029
Rich Lanee2567702015-01-26 15:04:35 -080030import sys
31ofp = sys.modules['loxi.of11']
32
Rich Lane7dcdf022013-12-11 14:45:27 -080033class action(loxi.OFObject):
34 subtypes = {}
Rich Lanec2ee4b82013-04-24 17:12:38 -070035
Rich Lane95f7fc92014-01-27 17:08:16 -080036
37 def __init__(self, type=None):
38 if type != None:
39 self.type = type
40 else:
41 self.type = 0
42 return
43
44 def pack(self):
45 packed = []
46 packed.append(struct.pack("!H", self.type))
47 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
48 packed.append('\x00' * 4)
49 length = sum([len(x) for x in packed])
50 packed[1] = struct.pack("!H", length)
51 return ''.join(packed)
52
Rich Lane7dcdf022013-12-11 14:45:27 -080053 @staticmethod
54 def unpack(reader):
55 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -080056 subclass = action.subtypes.get(subtype)
57 if subclass:
58 return subclass.unpack(reader)
59
60 obj = action()
61 obj.type = reader.read("!H")[0]
62 _len = reader.read("!H")[0]
63 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -080064 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -080065 reader.skip(4)
66 return obj
67
68 def __eq__(self, other):
69 if type(self) != type(other): return False
70 if self.type != other.type: return False
71 return True
72
73 def pretty_print(self, q):
74 q.text("action {")
75 with q.group():
76 with q.indent(2):
77 q.breakable()
78 q.breakable()
79 q.text('}')
Rich Lanec2ee4b82013-04-24 17:12:38 -070080
Rich Lane7dcdf022013-12-11 14:45:27 -080081
82class experimenter(action):
83 subtypes = {}
84
Rich Lane95f7fc92014-01-27 17:08:16 -080085 type = 65535
86
87 def __init__(self, experimenter=None, data=None):
88 if experimenter != None:
89 self.experimenter = experimenter
90 else:
91 self.experimenter = 0
92 if data != None:
93 self.data = data
94 else:
95 self.data = ''
96 return
97
98 def pack(self):
99 packed = []
100 packed.append(struct.pack("!H", self.type))
101 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
102 packed.append(struct.pack("!L", self.experimenter))
103 packed.append(self.data)
104 length = sum([len(x) for x in packed])
105 packed[1] = struct.pack("!H", length)
106 return ''.join(packed)
107
Rich Lane7dcdf022013-12-11 14:45:27 -0800108 @staticmethod
109 def unpack(reader):
110 subtype, = reader.peek('!L', 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800111 subclass = experimenter.subtypes.get(subtype)
112 if subclass:
113 return subclass.unpack(reader)
114
115 obj = experimenter()
116 _type = reader.read("!H")[0]
117 assert(_type == 65535)
118 _len = reader.read("!H")[0]
119 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800120 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800121 obj.experimenter = reader.read("!L")[0]
122 obj.data = str(reader.read_all())
123 return obj
124
125 def __eq__(self, other):
126 if type(self) != type(other): return False
127 if self.experimenter != other.experimenter: return False
128 if self.data != other.data: return False
129 return True
130
131 def pretty_print(self, q):
132 q.text("experimenter {")
133 with q.group():
134 with q.indent(2):
135 q.breakable()
136 q.text("data = ");
137 q.pp(self.data)
138 q.breakable()
139 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800140
141action.subtypes[65535] = experimenter
142
143class bsn(experimenter):
144 subtypes = {}
145
Rich Lane95f7fc92014-01-27 17:08:16 -0800146 type = 65535
147 experimenter = 6035143
148
149 def __init__(self, subtype=None):
150 if subtype != None:
151 self.subtype = subtype
152 else:
153 self.subtype = 0
154 return
155
156 def pack(self):
157 packed = []
158 packed.append(struct.pack("!H", self.type))
159 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
160 packed.append(struct.pack("!L", self.experimenter))
161 packed.append(struct.pack("!L", self.subtype))
162 packed.append('\x00' * 4)
163 length = sum([len(x) for x in packed])
164 packed[1] = struct.pack("!H", length)
165 return ''.join(packed)
166
Rich Lane7dcdf022013-12-11 14:45:27 -0800167 @staticmethod
168 def unpack(reader):
169 subtype, = reader.peek('!L', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800170 subclass = bsn.subtypes.get(subtype)
171 if subclass:
172 return subclass.unpack(reader)
173
174 obj = bsn()
175 _type = reader.read("!H")[0]
176 assert(_type == 65535)
177 _len = reader.read("!H")[0]
178 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800179 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800180 _experimenter = reader.read("!L")[0]
181 assert(_experimenter == 6035143)
182 obj.subtype = reader.read("!L")[0]
183 reader.skip(4)
184 return obj
185
186 def __eq__(self, other):
187 if type(self) != type(other): return False
188 if self.subtype != other.subtype: return False
189 return True
190
191 def pretty_print(self, q):
192 q.text("bsn {")
193 with q.group():
194 with q.indent(2):
195 q.breakable()
196 q.breakable()
197 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800198
199experimenter.subtypes[6035143] = bsn
200
Rich Lane5587ab12014-06-30 11:19:09 -0700201class bsn_checksum(bsn):
202 type = 65535
203 experimenter = 6035143
204 subtype = 4
205
206 def __init__(self, checksum=None):
207 if checksum != None:
208 self.checksum = checksum
209 else:
210 self.checksum = 0
211 return
212
213 def pack(self):
214 packed = []
215 packed.append(struct.pack("!H", self.type))
216 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
217 packed.append(struct.pack("!L", self.experimenter))
218 packed.append(struct.pack("!L", self.subtype))
219 packed.append(util.pack_checksum_128(self.checksum))
220 length = sum([len(x) for x in packed])
221 packed[1] = struct.pack("!H", length)
222 return ''.join(packed)
223
224 @staticmethod
225 def unpack(reader):
226 obj = bsn_checksum()
227 _type = reader.read("!H")[0]
228 assert(_type == 65535)
229 _len = reader.read("!H")[0]
230 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800231 reader = orig_reader.slice(_len, 4)
Rich Lane5587ab12014-06-30 11:19:09 -0700232 _experimenter = reader.read("!L")[0]
233 assert(_experimenter == 6035143)
234 _subtype = reader.read("!L")[0]
235 assert(_subtype == 4)
236 obj.checksum = util.unpack_checksum_128(reader)
237 return obj
238
239 def __eq__(self, other):
240 if type(self) != type(other): return False
241 if self.checksum != other.checksum: return False
242 return True
243
244 def pretty_print(self, q):
245 q.text("bsn_checksum {")
246 with q.group():
247 with q.indent(2):
248 q.breakable()
249 q.text("checksum = ");
250 q.pp(self.checksum)
251 q.breakable()
252 q.text('}')
253
254bsn.subtypes[4] = bsn_checksum
255
Rich Lane7dcdf022013-12-11 14:45:27 -0800256class bsn_mirror(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700257 type = 65535
258 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -0700259 subtype = 1
260
261 def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None):
262 if dest_port != None:
263 self.dest_port = dest_port
264 else:
265 self.dest_port = 0
266 if vlan_tag != None:
267 self.vlan_tag = vlan_tag
268 else:
269 self.vlan_tag = 0
270 if copy_stage != None:
271 self.copy_stage = copy_stage
272 else:
273 self.copy_stage = 0
274 return
275
276 def pack(self):
277 packed = []
278 packed.append(struct.pack("!H", self.type))
279 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
280 packed.append(struct.pack("!L", self.experimenter))
281 packed.append(struct.pack("!L", self.subtype))
282 packed.append(struct.pack("!L", self.dest_port))
283 packed.append(struct.pack("!L", self.vlan_tag))
284 packed.append(struct.pack("!B", self.copy_stage))
285 packed.append('\x00' * 3)
286 length = sum([len(x) for x in packed])
287 packed[1] = struct.pack("!H", length)
288 return ''.join(packed)
289
290 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800291 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700292 obj = bsn_mirror()
Dan Talaycof6202252013-07-02 01:00:29 -0700293 _type = reader.read("!H")[0]
294 assert(_type == 65535)
295 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800296 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800297 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700298 _experimenter = reader.read("!L")[0]
299 assert(_experimenter == 6035143)
300 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700301 assert(_subtype == 1)
Dan Talaycof6202252013-07-02 01:00:29 -0700302 obj.dest_port = reader.read("!L")[0]
303 obj.vlan_tag = reader.read("!L")[0]
304 obj.copy_stage = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700305 reader.skip(3)
306 return obj
307
308 def __eq__(self, other):
309 if type(self) != type(other): return False
310 if self.dest_port != other.dest_port: return False
311 if self.vlan_tag != other.vlan_tag: return False
312 if self.copy_stage != other.copy_stage: return False
313 return True
314
Rich Lanec2ee4b82013-04-24 17:12:38 -0700315 def pretty_print(self, q):
316 q.text("bsn_mirror {")
317 with q.group():
318 with q.indent(2):
319 q.breakable()
320 q.text("dest_port = ");
321 q.text("%#x" % self.dest_port)
322 q.text(","); q.breakable()
323 q.text("vlan_tag = ");
324 q.text("%#x" % self.vlan_tag)
325 q.text(","); q.breakable()
326 q.text("copy_stage = ");
327 q.text("%#x" % self.copy_stage)
328 q.breakable()
329 q.text('}')
330
Rich Lane7dcdf022013-12-11 14:45:27 -0800331bsn.subtypes[1] = bsn_mirror
332
333class bsn_set_tunnel_dst(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700334 type = 65535
335 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -0700336 subtype = 2
337
338 def __init__(self, dst=None):
339 if dst != None:
340 self.dst = dst
341 else:
342 self.dst = 0
343 return
344
345 def pack(self):
346 packed = []
347 packed.append(struct.pack("!H", self.type))
348 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
349 packed.append(struct.pack("!L", self.experimenter))
350 packed.append(struct.pack("!L", self.subtype))
351 packed.append(struct.pack("!L", self.dst))
352 length = sum([len(x) for x in packed])
353 packed[1] = struct.pack("!H", length)
354 return ''.join(packed)
355
356 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800357 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700358 obj = bsn_set_tunnel_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700359 _type = reader.read("!H")[0]
360 assert(_type == 65535)
361 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800362 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800363 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700364 _experimenter = reader.read("!L")[0]
365 assert(_experimenter == 6035143)
366 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700367 assert(_subtype == 2)
Dan Talaycof6202252013-07-02 01:00:29 -0700368 obj.dst = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700369 return obj
370
371 def __eq__(self, other):
372 if type(self) != type(other): return False
373 if self.dst != other.dst: return False
374 return True
375
Rich Lanec2ee4b82013-04-24 17:12:38 -0700376 def pretty_print(self, q):
377 q.text("bsn_set_tunnel_dst {")
378 with q.group():
379 with q.indent(2):
380 q.breakable()
381 q.text("dst = ");
382 q.text("%#x" % self.dst)
383 q.breakable()
384 q.text('}')
385
Rich Lane7dcdf022013-12-11 14:45:27 -0800386bsn.subtypes[2] = bsn_set_tunnel_dst
387
388class copy_ttl_in(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700389 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -0700390
391 def __init__(self):
392 return
393
394 def pack(self):
395 packed = []
396 packed.append(struct.pack("!H", self.type))
397 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
398 packed.append('\x00' * 4)
399 length = sum([len(x) for x in packed])
400 packed[1] = struct.pack("!H", length)
401 return ''.join(packed)
402
403 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800404 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700405 obj = copy_ttl_in()
Dan Talaycof6202252013-07-02 01:00:29 -0700406 _type = reader.read("!H")[0]
407 assert(_type == 12)
408 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800409 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800410 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700411 reader.skip(4)
412 return obj
413
414 def __eq__(self, other):
415 if type(self) != type(other): return False
416 return True
417
Rich Lanec2ee4b82013-04-24 17:12:38 -0700418 def pretty_print(self, q):
419 q.text("copy_ttl_in {")
420 with q.group():
421 with q.indent(2):
422 q.breakable()
423 q.breakable()
424 q.text('}')
425
Rich Lane7dcdf022013-12-11 14:45:27 -0800426action.subtypes[12] = copy_ttl_in
427
428class copy_ttl_out(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700429 type = 11
Rich Lanec2ee4b82013-04-24 17:12:38 -0700430
431 def __init__(self):
432 return
433
434 def pack(self):
435 packed = []
436 packed.append(struct.pack("!H", self.type))
437 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
438 packed.append('\x00' * 4)
439 length = sum([len(x) for x in packed])
440 packed[1] = struct.pack("!H", length)
441 return ''.join(packed)
442
443 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800444 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700445 obj = copy_ttl_out()
Dan Talaycof6202252013-07-02 01:00:29 -0700446 _type = reader.read("!H")[0]
447 assert(_type == 11)
448 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800449 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800450 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700451 reader.skip(4)
452 return obj
453
454 def __eq__(self, other):
455 if type(self) != type(other): return False
456 return True
457
Rich Lanec2ee4b82013-04-24 17:12:38 -0700458 def pretty_print(self, q):
459 q.text("copy_ttl_out {")
460 with q.group():
461 with q.indent(2):
462 q.breakable()
463 q.breakable()
464 q.text('}')
465
Rich Lane7dcdf022013-12-11 14:45:27 -0800466action.subtypes[11] = copy_ttl_out
467
468class dec_mpls_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700469 type = 16
Rich Lanec2ee4b82013-04-24 17:12:38 -0700470
471 def __init__(self):
472 return
473
474 def pack(self):
475 packed = []
476 packed.append(struct.pack("!H", self.type))
477 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
478 packed.append('\x00' * 4)
479 length = sum([len(x) for x in packed])
480 packed[1] = struct.pack("!H", length)
481 return ''.join(packed)
482
483 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800484 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700485 obj = dec_mpls_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700486 _type = reader.read("!H")[0]
487 assert(_type == 16)
488 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800489 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800490 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700491 reader.skip(4)
492 return obj
493
494 def __eq__(self, other):
495 if type(self) != type(other): return False
496 return True
497
Rich Lanec2ee4b82013-04-24 17:12:38 -0700498 def pretty_print(self, q):
499 q.text("dec_mpls_ttl {")
500 with q.group():
501 with q.indent(2):
502 q.breakable()
503 q.breakable()
504 q.text('}')
505
Rich Lane7dcdf022013-12-11 14:45:27 -0800506action.subtypes[16] = dec_mpls_ttl
507
508class dec_nw_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700509 type = 24
Rich Lanec2ee4b82013-04-24 17:12:38 -0700510
511 def __init__(self):
512 return
513
514 def pack(self):
515 packed = []
516 packed.append(struct.pack("!H", self.type))
517 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
518 packed.append('\x00' * 4)
519 length = sum([len(x) for x in packed])
520 packed[1] = struct.pack("!H", length)
521 return ''.join(packed)
522
523 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800524 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700525 obj = dec_nw_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700526 _type = reader.read("!H")[0]
527 assert(_type == 24)
528 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800529 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800530 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700531 reader.skip(4)
532 return obj
533
534 def __eq__(self, other):
535 if type(self) != type(other): return False
536 return True
537
Rich Lanec2ee4b82013-04-24 17:12:38 -0700538 def pretty_print(self, q):
539 q.text("dec_nw_ttl {")
540 with q.group():
541 with q.indent(2):
542 q.breakable()
543 q.breakable()
544 q.text('}')
545
Rich Lane7dcdf022013-12-11 14:45:27 -0800546action.subtypes[24] = dec_nw_ttl
547
548class group(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700549 type = 22
Rich Lanec2ee4b82013-04-24 17:12:38 -0700550
551 def __init__(self, group_id=None):
552 if group_id != None:
553 self.group_id = group_id
554 else:
555 self.group_id = 0
556 return
557
558 def pack(self):
559 packed = []
560 packed.append(struct.pack("!H", self.type))
561 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
562 packed.append(struct.pack("!L", self.group_id))
563 length = sum([len(x) for x in packed])
564 packed[1] = struct.pack("!H", length)
565 return ''.join(packed)
566
567 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800568 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700569 obj = group()
Dan Talaycof6202252013-07-02 01:00:29 -0700570 _type = reader.read("!H")[0]
571 assert(_type == 22)
572 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800573 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800574 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700575 obj.group_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700576 return obj
577
578 def __eq__(self, other):
579 if type(self) != type(other): return False
580 if self.group_id != other.group_id: return False
581 return True
582
Rich Lanec2ee4b82013-04-24 17:12:38 -0700583 def pretty_print(self, q):
584 q.text("group {")
585 with q.group():
586 with q.indent(2):
587 q.breakable()
588 q.text("group_id = ");
589 q.text("%#x" % self.group_id)
590 q.breakable()
591 q.text('}')
592
Rich Lane7dcdf022013-12-11 14:45:27 -0800593action.subtypes[22] = group
594
595class nicira(experimenter):
596 subtypes = {}
597
Rich Lane95f7fc92014-01-27 17:08:16 -0800598 type = 65535
599 experimenter = 8992
600
601 def __init__(self, subtype=None):
602 if subtype != None:
603 self.subtype = subtype
604 else:
605 self.subtype = 0
606 return
607
608 def pack(self):
609 packed = []
610 packed.append(struct.pack("!H", self.type))
611 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
612 packed.append(struct.pack("!L", self.experimenter))
613 packed.append(struct.pack("!H", self.subtype))
614 packed.append('\x00' * 2)
615 packed.append('\x00' * 4)
616 length = sum([len(x) for x in packed])
617 packed[1] = struct.pack("!H", length)
618 return ''.join(packed)
619
Rich Lane7dcdf022013-12-11 14:45:27 -0800620 @staticmethod
621 def unpack(reader):
622 subtype, = reader.peek('!H', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800623 subclass = nicira.subtypes.get(subtype)
624 if subclass:
625 return subclass.unpack(reader)
626
627 obj = nicira()
628 _type = reader.read("!H")[0]
629 assert(_type == 65535)
630 _len = reader.read("!H")[0]
631 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800632 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800633 _experimenter = reader.read("!L")[0]
634 assert(_experimenter == 8992)
635 obj.subtype = reader.read("!H")[0]
636 reader.skip(2)
637 reader.skip(4)
638 return obj
639
640 def __eq__(self, other):
641 if type(self) != type(other): return False
642 if self.subtype != other.subtype: return False
643 return True
644
645 def pretty_print(self, q):
646 q.text("nicira {")
647 with q.group():
648 with q.indent(2):
649 q.breakable()
650 q.breakable()
651 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800652
653experimenter.subtypes[8992] = nicira
654
655class nicira_dec_ttl(nicira):
Dan Talaycof6202252013-07-02 01:00:29 -0700656 type = 65535
657 experimenter = 8992
Rich Lanec2ee4b82013-04-24 17:12:38 -0700658 subtype = 18
659
660 def __init__(self):
661 return
662
663 def pack(self):
664 packed = []
665 packed.append(struct.pack("!H", self.type))
666 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
667 packed.append(struct.pack("!L", self.experimenter))
668 packed.append(struct.pack("!H", self.subtype))
669 packed.append('\x00' * 2)
670 packed.append('\x00' * 4)
671 length = sum([len(x) for x in packed])
672 packed[1] = struct.pack("!H", length)
673 return ''.join(packed)
674
675 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800676 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700677 obj = nicira_dec_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700678 _type = reader.read("!H")[0]
679 assert(_type == 65535)
680 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800681 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800682 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700683 _experimenter = reader.read("!L")[0]
684 assert(_experimenter == 8992)
685 _subtype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700686 assert(_subtype == 18)
687 reader.skip(2)
688 reader.skip(4)
689 return obj
690
691 def __eq__(self, other):
692 if type(self) != type(other): return False
693 return True
694
Rich Lanec2ee4b82013-04-24 17:12:38 -0700695 def pretty_print(self, q):
696 q.text("nicira_dec_ttl {")
697 with q.group():
698 with q.indent(2):
699 q.breakable()
700 q.breakable()
701 q.text('}')
702
Rich Lane7dcdf022013-12-11 14:45:27 -0800703nicira.subtypes[18] = nicira_dec_ttl
704
705class output(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700706 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700707
708 def __init__(self, port=None, max_len=None):
709 if port != None:
710 self.port = port
711 else:
712 self.port = 0
713 if max_len != None:
714 self.max_len = max_len
715 else:
716 self.max_len = 0
717 return
718
719 def pack(self):
720 packed = []
721 packed.append(struct.pack("!H", self.type))
722 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700723 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700724 packed.append(struct.pack("!H", self.max_len))
725 packed.append('\x00' * 6)
726 length = sum([len(x) for x in packed])
727 packed[1] = struct.pack("!H", length)
728 return ''.join(packed)
729
730 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800731 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700732 obj = output()
Dan Talaycof6202252013-07-02 01:00:29 -0700733 _type = reader.read("!H")[0]
734 assert(_type == 0)
735 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800736 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800737 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700738 obj.port = util.unpack_port_no(reader)
739 obj.max_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700740 reader.skip(6)
741 return obj
742
743 def __eq__(self, other):
744 if type(self) != type(other): return False
745 if self.port != other.port: return False
746 if self.max_len != other.max_len: return False
747 return True
748
Rich Lanec2ee4b82013-04-24 17:12:38 -0700749 def pretty_print(self, q):
750 q.text("output {")
751 with q.group():
752 with q.indent(2):
753 q.breakable()
754 q.text("port = ");
755 q.text(util.pretty_port(self.port))
756 q.text(","); q.breakable()
757 q.text("max_len = ");
758 q.text("%#x" % self.max_len)
759 q.breakable()
760 q.text('}')
761
Rich Lane7dcdf022013-12-11 14:45:27 -0800762action.subtypes[0] = output
763
764class pop_mpls(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700765 type = 20
Rich Lanec2ee4b82013-04-24 17:12:38 -0700766
767 def __init__(self, ethertype=None):
768 if ethertype != None:
769 self.ethertype = ethertype
770 else:
771 self.ethertype = 0
772 return
773
774 def pack(self):
775 packed = []
776 packed.append(struct.pack("!H", self.type))
777 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
778 packed.append(struct.pack("!H", self.ethertype))
779 packed.append('\x00' * 2)
780 length = sum([len(x) for x in packed])
781 packed[1] = struct.pack("!H", length)
782 return ''.join(packed)
783
784 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800785 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700786 obj = pop_mpls()
Dan Talaycof6202252013-07-02 01:00:29 -0700787 _type = reader.read("!H")[0]
788 assert(_type == 20)
789 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800790 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800791 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700792 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700793 reader.skip(2)
794 return obj
795
796 def __eq__(self, other):
797 if type(self) != type(other): return False
798 if self.ethertype != other.ethertype: return False
799 return True
800
Rich Lanec2ee4b82013-04-24 17:12:38 -0700801 def pretty_print(self, q):
802 q.text("pop_mpls {")
803 with q.group():
804 with q.indent(2):
805 q.breakable()
806 q.text("ethertype = ");
807 q.text("%#x" % self.ethertype)
808 q.breakable()
809 q.text('}')
810
Rich Lane7dcdf022013-12-11 14:45:27 -0800811action.subtypes[20] = pop_mpls
812
813class pop_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700814 type = 18
Rich Lanec2ee4b82013-04-24 17:12:38 -0700815
816 def __init__(self):
817 return
818
819 def pack(self):
820 packed = []
821 packed.append(struct.pack("!H", self.type))
822 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
823 packed.append('\x00' * 4)
824 length = sum([len(x) for x in packed])
825 packed[1] = struct.pack("!H", length)
826 return ''.join(packed)
827
828 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800829 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700830 obj = pop_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -0700831 _type = reader.read("!H")[0]
832 assert(_type == 18)
833 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800834 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800835 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700836 reader.skip(4)
837 return obj
838
839 def __eq__(self, other):
840 if type(self) != type(other): return False
841 return True
842
Rich Lanec2ee4b82013-04-24 17:12:38 -0700843 def pretty_print(self, q):
844 q.text("pop_vlan {")
845 with q.group():
846 with q.indent(2):
847 q.breakable()
848 q.breakable()
849 q.text('}')
850
Rich Lane7dcdf022013-12-11 14:45:27 -0800851action.subtypes[18] = pop_vlan
852
853class push_mpls(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700854 type = 19
Rich Lanec2ee4b82013-04-24 17:12:38 -0700855
856 def __init__(self, ethertype=None):
857 if ethertype != None:
858 self.ethertype = ethertype
859 else:
860 self.ethertype = 0
861 return
862
863 def pack(self):
864 packed = []
865 packed.append(struct.pack("!H", self.type))
866 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
867 packed.append(struct.pack("!H", self.ethertype))
868 packed.append('\x00' * 2)
869 length = sum([len(x) for x in packed])
870 packed[1] = struct.pack("!H", length)
871 return ''.join(packed)
872
873 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800874 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700875 obj = push_mpls()
Dan Talaycof6202252013-07-02 01:00:29 -0700876 _type = reader.read("!H")[0]
877 assert(_type == 19)
878 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800879 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800880 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700881 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700882 reader.skip(2)
883 return obj
884
885 def __eq__(self, other):
886 if type(self) != type(other): return False
887 if self.ethertype != other.ethertype: return False
888 return True
889
Rich Lanec2ee4b82013-04-24 17:12:38 -0700890 def pretty_print(self, q):
891 q.text("push_mpls {")
892 with q.group():
893 with q.indent(2):
894 q.breakable()
895 q.text("ethertype = ");
896 q.text("%#x" % self.ethertype)
897 q.breakable()
898 q.text('}')
899
Rich Lane7dcdf022013-12-11 14:45:27 -0800900action.subtypes[19] = push_mpls
901
902class push_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700903 type = 17
Rich Lanec2ee4b82013-04-24 17:12:38 -0700904
905 def __init__(self, ethertype=None):
906 if ethertype != None:
907 self.ethertype = ethertype
908 else:
909 self.ethertype = 0
910 return
911
912 def pack(self):
913 packed = []
914 packed.append(struct.pack("!H", self.type))
915 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
916 packed.append(struct.pack("!H", self.ethertype))
917 packed.append('\x00' * 2)
918 length = sum([len(x) for x in packed])
919 packed[1] = struct.pack("!H", length)
920 return ''.join(packed)
921
922 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800923 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700924 obj = push_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -0700925 _type = reader.read("!H")[0]
926 assert(_type == 17)
927 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800928 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800929 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700930 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700931 reader.skip(2)
932 return obj
933
934 def __eq__(self, other):
935 if type(self) != type(other): return False
936 if self.ethertype != other.ethertype: return False
937 return True
938
Rich Lanec2ee4b82013-04-24 17:12:38 -0700939 def pretty_print(self, q):
940 q.text("push_vlan {")
941 with q.group():
942 with q.indent(2):
943 q.breakable()
944 q.text("ethertype = ");
945 q.text("%#x" % self.ethertype)
946 q.breakable()
947 q.text('}')
948
Rich Lane7dcdf022013-12-11 14:45:27 -0800949action.subtypes[17] = push_vlan
950
951class set_dl_dst(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700952 type = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -0700953
954 def __init__(self, dl_addr=None):
955 if dl_addr != None:
956 self.dl_addr = dl_addr
957 else:
958 self.dl_addr = [0,0,0,0,0,0]
959 return
960
961 def pack(self):
962 packed = []
963 packed.append(struct.pack("!H", self.type))
964 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
965 packed.append(struct.pack("!6B", *self.dl_addr))
966 packed.append('\x00' * 6)
967 length = sum([len(x) for x in packed])
968 packed[1] = struct.pack("!H", length)
969 return ''.join(packed)
970
971 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800972 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700973 obj = set_dl_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700974 _type = reader.read("!H")[0]
975 assert(_type == 4)
976 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800977 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800978 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700979 obj.dl_addr = list(reader.read('!6B'))
980 reader.skip(6)
981 return obj
982
983 def __eq__(self, other):
984 if type(self) != type(other): return False
985 if self.dl_addr != other.dl_addr: return False
986 return True
987
Rich Lanec2ee4b82013-04-24 17:12:38 -0700988 def pretty_print(self, q):
989 q.text("set_dl_dst {")
990 with q.group():
991 with q.indent(2):
992 q.breakable()
993 q.text("dl_addr = ");
994 q.text(util.pretty_mac(self.dl_addr))
995 q.breakable()
996 q.text('}')
997
Rich Lane7dcdf022013-12-11 14:45:27 -0800998action.subtypes[4] = set_dl_dst
999
1000class set_dl_src(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001001 type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -07001002
1003 def __init__(self, dl_addr=None):
1004 if dl_addr != None:
1005 self.dl_addr = dl_addr
1006 else:
1007 self.dl_addr = [0,0,0,0,0,0]
1008 return
1009
1010 def pack(self):
1011 packed = []
1012 packed.append(struct.pack("!H", self.type))
1013 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1014 packed.append(struct.pack("!6B", *self.dl_addr))
1015 packed.append('\x00' * 6)
1016 length = sum([len(x) for x in packed])
1017 packed[1] = struct.pack("!H", length)
1018 return ''.join(packed)
1019
1020 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001021 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001022 obj = set_dl_src()
Dan Talaycof6202252013-07-02 01:00:29 -07001023 _type = reader.read("!H")[0]
1024 assert(_type == 3)
1025 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001026 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001027 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001028 obj.dl_addr = list(reader.read('!6B'))
1029 reader.skip(6)
1030 return obj
1031
1032 def __eq__(self, other):
1033 if type(self) != type(other): return False
1034 if self.dl_addr != other.dl_addr: return False
1035 return True
1036
Rich Lanec2ee4b82013-04-24 17:12:38 -07001037 def pretty_print(self, q):
1038 q.text("set_dl_src {")
1039 with q.group():
1040 with q.indent(2):
1041 q.breakable()
1042 q.text("dl_addr = ");
1043 q.text(util.pretty_mac(self.dl_addr))
1044 q.breakable()
1045 q.text('}')
1046
Rich Lane7dcdf022013-12-11 14:45:27 -08001047action.subtypes[3] = set_dl_src
1048
1049class set_mpls_label(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001050 type = 13
Rich Lanec2ee4b82013-04-24 17:12:38 -07001051
1052 def __init__(self, mpls_label=None):
1053 if mpls_label != None:
1054 self.mpls_label = mpls_label
1055 else:
1056 self.mpls_label = 0
1057 return
1058
1059 def pack(self):
1060 packed = []
1061 packed.append(struct.pack("!H", self.type))
1062 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1063 packed.append(struct.pack("!L", self.mpls_label))
1064 length = sum([len(x) for x in packed])
1065 packed[1] = struct.pack("!H", length)
1066 return ''.join(packed)
1067
1068 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001069 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001070 obj = set_mpls_label()
Dan Talaycof6202252013-07-02 01:00:29 -07001071 _type = reader.read("!H")[0]
1072 assert(_type == 13)
1073 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001074 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001075 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001076 obj.mpls_label = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001077 return obj
1078
1079 def __eq__(self, other):
1080 if type(self) != type(other): return False
1081 if self.mpls_label != other.mpls_label: return False
1082 return True
1083
Rich Lanec2ee4b82013-04-24 17:12:38 -07001084 def pretty_print(self, q):
1085 q.text("set_mpls_label {")
1086 with q.group():
1087 with q.indent(2):
1088 q.breakable()
1089 q.text("mpls_label = ");
1090 q.text("%#x" % self.mpls_label)
1091 q.breakable()
1092 q.text('}')
1093
Rich Lane7dcdf022013-12-11 14:45:27 -08001094action.subtypes[13] = set_mpls_label
1095
1096class set_mpls_tc(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001097 type = 14
Rich Lanec2ee4b82013-04-24 17:12:38 -07001098
1099 def __init__(self, mpls_tc=None):
1100 if mpls_tc != None:
1101 self.mpls_tc = mpls_tc
1102 else:
1103 self.mpls_tc = 0
1104 return
1105
1106 def pack(self):
1107 packed = []
1108 packed.append(struct.pack("!H", self.type))
1109 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1110 packed.append(struct.pack("!B", self.mpls_tc))
1111 packed.append('\x00' * 3)
1112 length = sum([len(x) for x in packed])
1113 packed[1] = struct.pack("!H", length)
1114 return ''.join(packed)
1115
1116 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001117 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001118 obj = set_mpls_tc()
Dan Talaycof6202252013-07-02 01:00:29 -07001119 _type = reader.read("!H")[0]
1120 assert(_type == 14)
1121 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001122 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001123 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001124 obj.mpls_tc = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001125 reader.skip(3)
1126 return obj
1127
1128 def __eq__(self, other):
1129 if type(self) != type(other): return False
1130 if self.mpls_tc != other.mpls_tc: return False
1131 return True
1132
Rich Lanec2ee4b82013-04-24 17:12:38 -07001133 def pretty_print(self, q):
1134 q.text("set_mpls_tc {")
1135 with q.group():
1136 with q.indent(2):
1137 q.breakable()
1138 q.text("mpls_tc = ");
1139 q.text("%#x" % self.mpls_tc)
1140 q.breakable()
1141 q.text('}')
1142
Rich Lane7dcdf022013-12-11 14:45:27 -08001143action.subtypes[14] = set_mpls_tc
1144
1145class set_mpls_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001146 type = 15
Rich Lanec2ee4b82013-04-24 17:12:38 -07001147
1148 def __init__(self, mpls_ttl=None):
1149 if mpls_ttl != None:
1150 self.mpls_ttl = mpls_ttl
1151 else:
1152 self.mpls_ttl = 0
1153 return
1154
1155 def pack(self):
1156 packed = []
1157 packed.append(struct.pack("!H", self.type))
1158 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1159 packed.append(struct.pack("!B", self.mpls_ttl))
1160 packed.append('\x00' * 3)
1161 length = sum([len(x) for x in packed])
1162 packed[1] = struct.pack("!H", length)
1163 return ''.join(packed)
1164
1165 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001166 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001167 obj = set_mpls_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -07001168 _type = reader.read("!H")[0]
1169 assert(_type == 15)
1170 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001171 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001172 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001173 obj.mpls_ttl = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001174 reader.skip(3)
1175 return obj
1176
1177 def __eq__(self, other):
1178 if type(self) != type(other): return False
1179 if self.mpls_ttl != other.mpls_ttl: return False
1180 return True
1181
Rich Lanec2ee4b82013-04-24 17:12:38 -07001182 def pretty_print(self, q):
1183 q.text("set_mpls_ttl {")
1184 with q.group():
1185 with q.indent(2):
1186 q.breakable()
1187 q.text("mpls_ttl = ");
1188 q.text("%#x" % self.mpls_ttl)
1189 q.breakable()
1190 q.text('}')
1191
Rich Lane7dcdf022013-12-11 14:45:27 -08001192action.subtypes[15] = set_mpls_ttl
1193
1194class set_nw_dst(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001195 type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07001196
1197 def __init__(self, nw_addr=None):
1198 if nw_addr != None:
1199 self.nw_addr = nw_addr
1200 else:
1201 self.nw_addr = 0
1202 return
1203
1204 def pack(self):
1205 packed = []
1206 packed.append(struct.pack("!H", self.type))
1207 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1208 packed.append(struct.pack("!L", self.nw_addr))
1209 length = sum([len(x) for x in packed])
1210 packed[1] = struct.pack("!H", length)
1211 return ''.join(packed)
1212
1213 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001214 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001215 obj = set_nw_dst()
Dan Talaycof6202252013-07-02 01:00:29 -07001216 _type = reader.read("!H")[0]
1217 assert(_type == 6)
1218 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001219 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001220 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001221 obj.nw_addr = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001222 return obj
1223
1224 def __eq__(self, other):
1225 if type(self) != type(other): return False
1226 if self.nw_addr != other.nw_addr: return False
1227 return True
1228
Rich Lanec2ee4b82013-04-24 17:12:38 -07001229 def pretty_print(self, q):
1230 q.text("set_nw_dst {")
1231 with q.group():
1232 with q.indent(2):
1233 q.breakable()
1234 q.text("nw_addr = ");
1235 q.text("%#x" % self.nw_addr)
1236 q.breakable()
1237 q.text('}')
1238
Rich Lane7dcdf022013-12-11 14:45:27 -08001239action.subtypes[6] = set_nw_dst
1240
1241class set_nw_ecn(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001242 type = 8
Rich Lanec2ee4b82013-04-24 17:12:38 -07001243
1244 def __init__(self, nw_ecn=None):
1245 if nw_ecn != None:
1246 self.nw_ecn = nw_ecn
1247 else:
1248 self.nw_ecn = 0
1249 return
1250
1251 def pack(self):
1252 packed = []
1253 packed.append(struct.pack("!H", self.type))
1254 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1255 packed.append(struct.pack("!B", self.nw_ecn))
1256 packed.append('\x00' * 3)
1257 length = sum([len(x) for x in packed])
1258 packed[1] = struct.pack("!H", length)
1259 return ''.join(packed)
1260
1261 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001262 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001263 obj = set_nw_ecn()
Dan Talaycof6202252013-07-02 01:00:29 -07001264 _type = reader.read("!H")[0]
1265 assert(_type == 8)
1266 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001267 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001268 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001269 obj.nw_ecn = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001270 reader.skip(3)
1271 return obj
1272
1273 def __eq__(self, other):
1274 if type(self) != type(other): return False
1275 if self.nw_ecn != other.nw_ecn: return False
1276 return True
1277
Rich Lanec2ee4b82013-04-24 17:12:38 -07001278 def pretty_print(self, q):
1279 q.text("set_nw_ecn {")
1280 with q.group():
1281 with q.indent(2):
1282 q.breakable()
1283 q.text("nw_ecn = ");
1284 q.text("%#x" % self.nw_ecn)
1285 q.breakable()
1286 q.text('}')
1287
Rich Lane7dcdf022013-12-11 14:45:27 -08001288action.subtypes[8] = set_nw_ecn
1289
1290class set_nw_src(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001291 type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07001292
1293 def __init__(self, nw_addr=None):
1294 if nw_addr != None:
1295 self.nw_addr = nw_addr
1296 else:
1297 self.nw_addr = 0
1298 return
1299
1300 def pack(self):
1301 packed = []
1302 packed.append(struct.pack("!H", self.type))
1303 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1304 packed.append(struct.pack("!L", self.nw_addr))
1305 length = sum([len(x) for x in packed])
1306 packed[1] = struct.pack("!H", length)
1307 return ''.join(packed)
1308
1309 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001310 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001311 obj = set_nw_src()
Dan Talaycof6202252013-07-02 01:00:29 -07001312 _type = reader.read("!H")[0]
1313 assert(_type == 5)
1314 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001315 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001316 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001317 obj.nw_addr = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001318 return obj
1319
1320 def __eq__(self, other):
1321 if type(self) != type(other): return False
1322 if self.nw_addr != other.nw_addr: return False
1323 return True
1324
Rich Lanec2ee4b82013-04-24 17:12:38 -07001325 def pretty_print(self, q):
1326 q.text("set_nw_src {")
1327 with q.group():
1328 with q.indent(2):
1329 q.breakable()
1330 q.text("nw_addr = ");
1331 q.text("%#x" % self.nw_addr)
1332 q.breakable()
1333 q.text('}')
1334
Rich Lane7dcdf022013-12-11 14:45:27 -08001335action.subtypes[5] = set_nw_src
1336
1337class set_nw_tos(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001338 type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07001339
1340 def __init__(self, nw_tos=None):
1341 if nw_tos != None:
1342 self.nw_tos = nw_tos
1343 else:
1344 self.nw_tos = 0
1345 return
1346
1347 def pack(self):
1348 packed = []
1349 packed.append(struct.pack("!H", self.type))
1350 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1351 packed.append(struct.pack("!B", self.nw_tos))
1352 packed.append('\x00' * 3)
1353 length = sum([len(x) for x in packed])
1354 packed[1] = struct.pack("!H", length)
1355 return ''.join(packed)
1356
1357 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001358 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001359 obj = set_nw_tos()
Dan Talaycof6202252013-07-02 01:00:29 -07001360 _type = reader.read("!H")[0]
1361 assert(_type == 7)
1362 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001363 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001364 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001365 obj.nw_tos = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001366 reader.skip(3)
1367 return obj
1368
1369 def __eq__(self, other):
1370 if type(self) != type(other): return False
1371 if self.nw_tos != other.nw_tos: return False
1372 return True
1373
Rich Lanec2ee4b82013-04-24 17:12:38 -07001374 def pretty_print(self, q):
1375 q.text("set_nw_tos {")
1376 with q.group():
1377 with q.indent(2):
1378 q.breakable()
1379 q.text("nw_tos = ");
1380 q.text("%#x" % self.nw_tos)
1381 q.breakable()
1382 q.text('}')
1383
Rich Lane7dcdf022013-12-11 14:45:27 -08001384action.subtypes[7] = set_nw_tos
1385
1386class set_nw_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001387 type = 23
Rich Lanec2ee4b82013-04-24 17:12:38 -07001388
1389 def __init__(self, nw_ttl=None):
1390 if nw_ttl != None:
1391 self.nw_ttl = nw_ttl
1392 else:
1393 self.nw_ttl = 0
1394 return
1395
1396 def pack(self):
1397 packed = []
1398 packed.append(struct.pack("!H", self.type))
1399 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1400 packed.append(struct.pack("!B", self.nw_ttl))
1401 packed.append('\x00' * 3)
1402 length = sum([len(x) for x in packed])
1403 packed[1] = struct.pack("!H", length)
1404 return ''.join(packed)
1405
1406 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001407 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001408 obj = set_nw_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -07001409 _type = reader.read("!H")[0]
1410 assert(_type == 23)
1411 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001412 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001413 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001414 obj.nw_ttl = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001415 reader.skip(3)
1416 return obj
1417
1418 def __eq__(self, other):
1419 if type(self) != type(other): return False
1420 if self.nw_ttl != other.nw_ttl: return False
1421 return True
1422
Rich Lanec2ee4b82013-04-24 17:12:38 -07001423 def pretty_print(self, q):
1424 q.text("set_nw_ttl {")
1425 with q.group():
1426 with q.indent(2):
1427 q.breakable()
1428 q.text("nw_ttl = ");
1429 q.text("%#x" % self.nw_ttl)
1430 q.breakable()
1431 q.text('}')
1432
Rich Lane7dcdf022013-12-11 14:45:27 -08001433action.subtypes[23] = set_nw_ttl
1434
1435class set_queue(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001436 type = 21
Rich Lanec2ee4b82013-04-24 17:12:38 -07001437
1438 def __init__(self, queue_id=None):
1439 if queue_id != None:
1440 self.queue_id = queue_id
1441 else:
1442 self.queue_id = 0
1443 return
1444
1445 def pack(self):
1446 packed = []
1447 packed.append(struct.pack("!H", self.type))
1448 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1449 packed.append(struct.pack("!L", self.queue_id))
1450 length = sum([len(x) for x in packed])
1451 packed[1] = struct.pack("!H", length)
1452 return ''.join(packed)
1453
1454 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001455 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001456 obj = set_queue()
Dan Talaycof6202252013-07-02 01:00:29 -07001457 _type = reader.read("!H")[0]
1458 assert(_type == 21)
1459 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001460 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001461 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001462 obj.queue_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001463 return obj
1464
1465 def __eq__(self, other):
1466 if type(self) != type(other): return False
1467 if self.queue_id != other.queue_id: return False
1468 return True
1469
Rich Lanec2ee4b82013-04-24 17:12:38 -07001470 def pretty_print(self, q):
1471 q.text("set_queue {")
1472 with q.group():
1473 with q.indent(2):
1474 q.breakable()
1475 q.text("queue_id = ");
1476 q.text("%#x" % self.queue_id)
1477 q.breakable()
1478 q.text('}')
1479
Rich Lane7dcdf022013-12-11 14:45:27 -08001480action.subtypes[21] = set_queue
1481
1482class set_tp_dst(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001483 type = 10
Rich Lanec2ee4b82013-04-24 17:12:38 -07001484
1485 def __init__(self, tp_port=None):
1486 if tp_port != None:
1487 self.tp_port = tp_port
1488 else:
1489 self.tp_port = 0
1490 return
1491
1492 def pack(self):
1493 packed = []
1494 packed.append(struct.pack("!H", self.type))
1495 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1496 packed.append(struct.pack("!H", self.tp_port))
1497 packed.append('\x00' * 2)
1498 length = sum([len(x) for x in packed])
1499 packed[1] = struct.pack("!H", length)
1500 return ''.join(packed)
1501
1502 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001503 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001504 obj = set_tp_dst()
Dan Talaycof6202252013-07-02 01:00:29 -07001505 _type = reader.read("!H")[0]
1506 assert(_type == 10)
1507 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001508 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001509 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001510 obj.tp_port = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001511 reader.skip(2)
1512 return obj
1513
1514 def __eq__(self, other):
1515 if type(self) != type(other): return False
1516 if self.tp_port != other.tp_port: return False
1517 return True
1518
Rich Lanec2ee4b82013-04-24 17:12:38 -07001519 def pretty_print(self, q):
1520 q.text("set_tp_dst {")
1521 with q.group():
1522 with q.indent(2):
1523 q.breakable()
1524 q.text("tp_port = ");
1525 q.text("%#x" % self.tp_port)
1526 q.breakable()
1527 q.text('}')
1528
Rich Lane7dcdf022013-12-11 14:45:27 -08001529action.subtypes[10] = set_tp_dst
1530
1531class set_tp_src(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001532 type = 9
Rich Lanec2ee4b82013-04-24 17:12:38 -07001533
1534 def __init__(self, tp_port=None):
1535 if tp_port != None:
1536 self.tp_port = tp_port
1537 else:
1538 self.tp_port = 0
1539 return
1540
1541 def pack(self):
1542 packed = []
1543 packed.append(struct.pack("!H", self.type))
1544 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1545 packed.append(struct.pack("!H", self.tp_port))
1546 packed.append('\x00' * 2)
1547 length = sum([len(x) for x in packed])
1548 packed[1] = struct.pack("!H", length)
1549 return ''.join(packed)
1550
1551 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001552 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001553 obj = set_tp_src()
Dan Talaycof6202252013-07-02 01:00:29 -07001554 _type = reader.read("!H")[0]
1555 assert(_type == 9)
1556 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001557 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001558 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001559 obj.tp_port = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001560 reader.skip(2)
1561 return obj
1562
1563 def __eq__(self, other):
1564 if type(self) != type(other): return False
1565 if self.tp_port != other.tp_port: return False
1566 return True
1567
Rich Lanec2ee4b82013-04-24 17:12:38 -07001568 def pretty_print(self, q):
1569 q.text("set_tp_src {")
1570 with q.group():
1571 with q.indent(2):
1572 q.breakable()
1573 q.text("tp_port = ");
1574 q.text("%#x" % self.tp_port)
1575 q.breakable()
1576 q.text('}')
1577
Rich Lane7dcdf022013-12-11 14:45:27 -08001578action.subtypes[9] = set_tp_src
1579
1580class set_vlan_pcp(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001581 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07001582
1583 def __init__(self, vlan_pcp=None):
1584 if vlan_pcp != None:
1585 self.vlan_pcp = vlan_pcp
1586 else:
1587 self.vlan_pcp = 0
1588 return
1589
1590 def pack(self):
1591 packed = []
1592 packed.append(struct.pack("!H", self.type))
1593 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1594 packed.append(struct.pack("!B", self.vlan_pcp))
1595 packed.append('\x00' * 3)
1596 length = sum([len(x) for x in packed])
1597 packed[1] = struct.pack("!H", length)
1598 return ''.join(packed)
1599
1600 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001601 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001602 obj = set_vlan_pcp()
Dan Talaycof6202252013-07-02 01:00:29 -07001603 _type = reader.read("!H")[0]
1604 assert(_type == 2)
1605 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001606 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001607 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001608 obj.vlan_pcp = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001609 reader.skip(3)
1610 return obj
1611
1612 def __eq__(self, other):
1613 if type(self) != type(other): return False
1614 if self.vlan_pcp != other.vlan_pcp: return False
1615 return True
1616
Rich Lanec2ee4b82013-04-24 17:12:38 -07001617 def pretty_print(self, q):
1618 q.text("set_vlan_pcp {")
1619 with q.group():
1620 with q.indent(2):
1621 q.breakable()
1622 q.text("vlan_pcp = ");
1623 q.text("%#x" % self.vlan_pcp)
1624 q.breakable()
1625 q.text('}')
1626
Rich Lane7dcdf022013-12-11 14:45:27 -08001627action.subtypes[2] = set_vlan_pcp
1628
1629class set_vlan_vid(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001630 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07001631
1632 def __init__(self, vlan_vid=None):
1633 if vlan_vid != None:
1634 self.vlan_vid = vlan_vid
1635 else:
1636 self.vlan_vid = 0
1637 return
1638
1639 def pack(self):
1640 packed = []
1641 packed.append(struct.pack("!H", self.type))
1642 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1643 packed.append(struct.pack("!H", self.vlan_vid))
1644 packed.append('\x00' * 2)
1645 length = sum([len(x) for x in packed])
1646 packed[1] = struct.pack("!H", length)
1647 return ''.join(packed)
1648
1649 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001650 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001651 obj = set_vlan_vid()
Dan Talaycof6202252013-07-02 01:00:29 -07001652 _type = reader.read("!H")[0]
1653 assert(_type == 1)
1654 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001655 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001656 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001657 obj.vlan_vid = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001658 reader.skip(2)
1659 return obj
1660
1661 def __eq__(self, other):
1662 if type(self) != type(other): return False
1663 if self.vlan_vid != other.vlan_vid: return False
1664 return True
1665
Rich Lanec2ee4b82013-04-24 17:12:38 -07001666 def pretty_print(self, q):
1667 q.text("set_vlan_vid {")
1668 with q.group():
1669 with q.indent(2):
1670 q.breakable()
1671 q.text("vlan_vid = ");
1672 q.text("%#x" % self.vlan_vid)
1673 q.breakable()
1674 q.text('}')
1675
Rich Lane7dcdf022013-12-11 14:45:27 -08001676action.subtypes[1] = set_vlan_vid
Rich Lanec2ee4b82013-04-24 17:12:38 -07001677
Rich Lanec2ee4b82013-04-24 17:12:38 -07001678