blob: 261170a2f75b2d7d9bf3b89d445ea96681b5f979 [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.of12']
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.append(loxi.generic_util.pad_to(8, length))
106 length += len(packed[-1])
107 packed[1] = struct.pack("!H", length)
108 return ''.join(packed)
109
Rich Lane7dcdf022013-12-11 14:45:27 -0800110 @staticmethod
111 def unpack(reader):
112 subtype, = reader.peek('!L', 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800113 subclass = experimenter.subtypes.get(subtype)
114 if subclass:
115 return subclass.unpack(reader)
116
117 obj = experimenter()
118 _type = reader.read("!H")[0]
119 assert(_type == 65535)
120 _len = reader.read("!H")[0]
121 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800122 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800123 obj.experimenter = reader.read("!L")[0]
124 obj.data = str(reader.read_all())
125 return obj
126
127 def __eq__(self, other):
128 if type(self) != type(other): return False
129 if self.experimenter != other.experimenter: return False
130 if self.data != other.data: return False
131 return True
132
133 def pretty_print(self, q):
134 q.text("experimenter {")
135 with q.group():
136 with q.indent(2):
137 q.breakable()
138 q.text("data = ");
139 q.pp(self.data)
140 q.breakable()
141 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800142
143action.subtypes[65535] = experimenter
144
145class bsn(experimenter):
146 subtypes = {}
147
Rich Lane95f7fc92014-01-27 17:08:16 -0800148 type = 65535
149 experimenter = 6035143
150
151 def __init__(self, subtype=None):
152 if subtype != None:
153 self.subtype = subtype
154 else:
155 self.subtype = 0
156 return
157
158 def pack(self):
159 packed = []
160 packed.append(struct.pack("!H", self.type))
161 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
162 packed.append(struct.pack("!L", self.experimenter))
163 packed.append(struct.pack("!L", self.subtype))
164 packed.append('\x00' * 4)
165 length = sum([len(x) for x in packed])
166 packed[1] = struct.pack("!H", length)
167 return ''.join(packed)
168
Rich Lane7dcdf022013-12-11 14:45:27 -0800169 @staticmethod
170 def unpack(reader):
171 subtype, = reader.peek('!L', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800172 subclass = bsn.subtypes.get(subtype)
173 if subclass:
174 return subclass.unpack(reader)
175
176 obj = bsn()
177 _type = reader.read("!H")[0]
178 assert(_type == 65535)
179 _len = reader.read("!H")[0]
180 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800181 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800182 _experimenter = reader.read("!L")[0]
183 assert(_experimenter == 6035143)
184 obj.subtype = reader.read("!L")[0]
185 reader.skip(4)
186 return obj
187
188 def __eq__(self, other):
189 if type(self) != type(other): return False
190 if self.subtype != other.subtype: return False
191 return True
192
193 def pretty_print(self, q):
194 q.text("bsn {")
195 with q.group():
196 with q.indent(2):
197 q.breakable()
198 q.breakable()
199 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800200
201experimenter.subtypes[6035143] = bsn
202
Rich Lane5587ab12014-06-30 11:19:09 -0700203class bsn_checksum(bsn):
204 type = 65535
205 experimenter = 6035143
206 subtype = 4
207
208 def __init__(self, checksum=None):
209 if checksum != None:
210 self.checksum = checksum
211 else:
212 self.checksum = 0
213 return
214
215 def pack(self):
216 packed = []
217 packed.append(struct.pack("!H", self.type))
218 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
219 packed.append(struct.pack("!L", self.experimenter))
220 packed.append(struct.pack("!L", self.subtype))
221 packed.append(util.pack_checksum_128(self.checksum))
222 length = sum([len(x) for x in packed])
223 packed[1] = struct.pack("!H", length)
224 return ''.join(packed)
225
226 @staticmethod
227 def unpack(reader):
228 obj = bsn_checksum()
229 _type = reader.read("!H")[0]
230 assert(_type == 65535)
231 _len = reader.read("!H")[0]
232 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800233 reader = orig_reader.slice(_len, 4)
Rich Lane5587ab12014-06-30 11:19:09 -0700234 _experimenter = reader.read("!L")[0]
235 assert(_experimenter == 6035143)
236 _subtype = reader.read("!L")[0]
237 assert(_subtype == 4)
238 obj.checksum = util.unpack_checksum_128(reader)
239 return obj
240
241 def __eq__(self, other):
242 if type(self) != type(other): return False
243 if self.checksum != other.checksum: return False
244 return True
245
246 def pretty_print(self, q):
247 q.text("bsn_checksum {")
248 with q.group():
249 with q.indent(2):
250 q.breakable()
251 q.text("checksum = ");
252 q.pp(self.checksum)
253 q.breakable()
254 q.text('}')
255
256bsn.subtypes[4] = bsn_checksum
257
Rich Lane7dcdf022013-12-11 14:45:27 -0800258class bsn_mirror(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700259 type = 65535
260 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -0700261 subtype = 1
262
263 def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None):
264 if dest_port != None:
265 self.dest_port = dest_port
266 else:
267 self.dest_port = 0
268 if vlan_tag != None:
269 self.vlan_tag = vlan_tag
270 else:
271 self.vlan_tag = 0
272 if copy_stage != None:
273 self.copy_stage = copy_stage
274 else:
275 self.copy_stage = 0
276 return
277
278 def pack(self):
279 packed = []
280 packed.append(struct.pack("!H", self.type))
281 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
282 packed.append(struct.pack("!L", self.experimenter))
283 packed.append(struct.pack("!L", self.subtype))
284 packed.append(struct.pack("!L", self.dest_port))
285 packed.append(struct.pack("!L", self.vlan_tag))
286 packed.append(struct.pack("!B", self.copy_stage))
287 packed.append('\x00' * 3)
288 length = sum([len(x) for x in packed])
289 packed[1] = struct.pack("!H", length)
290 return ''.join(packed)
291
292 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800293 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700294 obj = bsn_mirror()
Dan Talaycof6202252013-07-02 01:00:29 -0700295 _type = reader.read("!H")[0]
296 assert(_type == 65535)
297 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800298 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800299 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700300 _experimenter = reader.read("!L")[0]
301 assert(_experimenter == 6035143)
302 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700303 assert(_subtype == 1)
Dan Talaycof6202252013-07-02 01:00:29 -0700304 obj.dest_port = reader.read("!L")[0]
305 obj.vlan_tag = reader.read("!L")[0]
306 obj.copy_stage = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700307 reader.skip(3)
308 return obj
309
310 def __eq__(self, other):
311 if type(self) != type(other): return False
312 if self.dest_port != other.dest_port: return False
313 if self.vlan_tag != other.vlan_tag: return False
314 if self.copy_stage != other.copy_stage: return False
315 return True
316
Rich Lanec2ee4b82013-04-24 17:12:38 -0700317 def pretty_print(self, q):
318 q.text("bsn_mirror {")
319 with q.group():
320 with q.indent(2):
321 q.breakable()
322 q.text("dest_port = ");
323 q.text("%#x" % self.dest_port)
324 q.text(","); q.breakable()
325 q.text("vlan_tag = ");
326 q.text("%#x" % self.vlan_tag)
327 q.text(","); q.breakable()
328 q.text("copy_stage = ");
329 q.text("%#x" % self.copy_stage)
330 q.breakable()
331 q.text('}')
332
Rich Lane7dcdf022013-12-11 14:45:27 -0800333bsn.subtypes[1] = bsn_mirror
334
335class bsn_set_tunnel_dst(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700336 type = 65535
337 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -0700338 subtype = 2
339
340 def __init__(self, dst=None):
341 if dst != None:
342 self.dst = dst
343 else:
344 self.dst = 0
345 return
346
347 def pack(self):
348 packed = []
349 packed.append(struct.pack("!H", self.type))
350 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
351 packed.append(struct.pack("!L", self.experimenter))
352 packed.append(struct.pack("!L", self.subtype))
353 packed.append(struct.pack("!L", self.dst))
354 length = sum([len(x) for x in packed])
355 packed[1] = struct.pack("!H", length)
356 return ''.join(packed)
357
358 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800359 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700360 obj = bsn_set_tunnel_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700361 _type = reader.read("!H")[0]
362 assert(_type == 65535)
363 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800364 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800365 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700366 _experimenter = reader.read("!L")[0]
367 assert(_experimenter == 6035143)
368 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700369 assert(_subtype == 2)
Dan Talaycof6202252013-07-02 01:00:29 -0700370 obj.dst = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700371 return obj
372
373 def __eq__(self, other):
374 if type(self) != type(other): return False
375 if self.dst != other.dst: return False
376 return True
377
Rich Lanec2ee4b82013-04-24 17:12:38 -0700378 def pretty_print(self, q):
379 q.text("bsn_set_tunnel_dst {")
380 with q.group():
381 with q.indent(2):
382 q.breakable()
383 q.text("dst = ");
384 q.text("%#x" % self.dst)
385 q.breakable()
386 q.text('}')
387
Rich Lane7dcdf022013-12-11 14:45:27 -0800388bsn.subtypes[2] = bsn_set_tunnel_dst
389
390class copy_ttl_in(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700391 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -0700392
393 def __init__(self):
394 return
395
396 def pack(self):
397 packed = []
398 packed.append(struct.pack("!H", self.type))
399 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
400 packed.append('\x00' * 4)
401 length = sum([len(x) for x in packed])
402 packed[1] = struct.pack("!H", length)
403 return ''.join(packed)
404
405 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800406 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700407 obj = copy_ttl_in()
Dan Talaycof6202252013-07-02 01:00:29 -0700408 _type = reader.read("!H")[0]
409 assert(_type == 12)
410 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800411 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800412 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700413 reader.skip(4)
414 return obj
415
416 def __eq__(self, other):
417 if type(self) != type(other): return False
418 return True
419
Rich Lanec2ee4b82013-04-24 17:12:38 -0700420 def pretty_print(self, q):
421 q.text("copy_ttl_in {")
422 with q.group():
423 with q.indent(2):
424 q.breakable()
425 q.breakable()
426 q.text('}')
427
Rich Lane7dcdf022013-12-11 14:45:27 -0800428action.subtypes[12] = copy_ttl_in
429
430class copy_ttl_out(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700431 type = 11
Rich Lanec2ee4b82013-04-24 17:12:38 -0700432
433 def __init__(self):
434 return
435
436 def pack(self):
437 packed = []
438 packed.append(struct.pack("!H", self.type))
439 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
440 packed.append('\x00' * 4)
441 length = sum([len(x) for x in packed])
442 packed[1] = struct.pack("!H", length)
443 return ''.join(packed)
444
445 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800446 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700447 obj = copy_ttl_out()
Dan Talaycof6202252013-07-02 01:00:29 -0700448 _type = reader.read("!H")[0]
449 assert(_type == 11)
450 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800451 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800452 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700453 reader.skip(4)
454 return obj
455
456 def __eq__(self, other):
457 if type(self) != type(other): return False
458 return True
459
Rich Lanec2ee4b82013-04-24 17:12:38 -0700460 def pretty_print(self, q):
461 q.text("copy_ttl_out {")
462 with q.group():
463 with q.indent(2):
464 q.breakable()
465 q.breakable()
466 q.text('}')
467
Rich Lane7dcdf022013-12-11 14:45:27 -0800468action.subtypes[11] = copy_ttl_out
469
470class dec_mpls_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700471 type = 16
Rich Lanec2ee4b82013-04-24 17:12:38 -0700472
473 def __init__(self):
474 return
475
476 def pack(self):
477 packed = []
478 packed.append(struct.pack("!H", self.type))
479 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
480 packed.append('\x00' * 4)
481 length = sum([len(x) for x in packed])
482 packed[1] = struct.pack("!H", length)
483 return ''.join(packed)
484
485 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800486 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700487 obj = dec_mpls_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700488 _type = reader.read("!H")[0]
489 assert(_type == 16)
490 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800491 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800492 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700493 reader.skip(4)
494 return obj
495
496 def __eq__(self, other):
497 if type(self) != type(other): return False
498 return True
499
Rich Lanec2ee4b82013-04-24 17:12:38 -0700500 def pretty_print(self, q):
501 q.text("dec_mpls_ttl {")
502 with q.group():
503 with q.indent(2):
504 q.breakable()
505 q.breakable()
506 q.text('}')
507
Rich Lane7dcdf022013-12-11 14:45:27 -0800508action.subtypes[16] = dec_mpls_ttl
509
510class dec_nw_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700511 type = 24
Rich Lanec2ee4b82013-04-24 17:12:38 -0700512
513 def __init__(self):
514 return
515
516 def pack(self):
517 packed = []
518 packed.append(struct.pack("!H", self.type))
519 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
520 packed.append('\x00' * 4)
521 length = sum([len(x) for x in packed])
522 packed[1] = struct.pack("!H", length)
523 return ''.join(packed)
524
525 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800526 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700527 obj = dec_nw_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700528 _type = reader.read("!H")[0]
529 assert(_type == 24)
530 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800531 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800532 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700533 reader.skip(4)
534 return obj
535
536 def __eq__(self, other):
537 if type(self) != type(other): return False
538 return True
539
Rich Lanec2ee4b82013-04-24 17:12:38 -0700540 def pretty_print(self, q):
541 q.text("dec_nw_ttl {")
542 with q.group():
543 with q.indent(2):
544 q.breakable()
545 q.breakable()
546 q.text('}')
547
Rich Lane7dcdf022013-12-11 14:45:27 -0800548action.subtypes[24] = dec_nw_ttl
549
550class group(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700551 type = 22
Rich Lanec2ee4b82013-04-24 17:12:38 -0700552
553 def __init__(self, group_id=None):
554 if group_id != None:
555 self.group_id = group_id
556 else:
557 self.group_id = 0
558 return
559
560 def pack(self):
561 packed = []
562 packed.append(struct.pack("!H", self.type))
563 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
564 packed.append(struct.pack("!L", self.group_id))
565 length = sum([len(x) for x in packed])
566 packed[1] = struct.pack("!H", length)
567 return ''.join(packed)
568
569 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800570 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700571 obj = group()
Dan Talaycof6202252013-07-02 01:00:29 -0700572 _type = reader.read("!H")[0]
573 assert(_type == 22)
574 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800575 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800576 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700577 obj.group_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700578 return obj
579
580 def __eq__(self, other):
581 if type(self) != type(other): return False
582 if self.group_id != other.group_id: return False
583 return True
584
Rich Lanec2ee4b82013-04-24 17:12:38 -0700585 def pretty_print(self, q):
586 q.text("group {")
587 with q.group():
588 with q.indent(2):
589 q.breakable()
590 q.text("group_id = ");
591 q.text("%#x" % self.group_id)
592 q.breakable()
593 q.text('}')
594
Rich Lane7dcdf022013-12-11 14:45:27 -0800595action.subtypes[22] = group
596
597class nicira(experimenter):
598 subtypes = {}
599
Rich Lane95f7fc92014-01-27 17:08:16 -0800600 type = 65535
601 experimenter = 8992
602
603 def __init__(self, subtype=None):
604 if subtype != None:
605 self.subtype = subtype
606 else:
607 self.subtype = 0
608 return
609
610 def pack(self):
611 packed = []
612 packed.append(struct.pack("!H", self.type))
613 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
614 packed.append(struct.pack("!L", self.experimenter))
615 packed.append(struct.pack("!H", self.subtype))
616 packed.append('\x00' * 2)
617 packed.append('\x00' * 4)
618 length = sum([len(x) for x in packed])
619 packed[1] = struct.pack("!H", length)
620 return ''.join(packed)
621
Rich Lane7dcdf022013-12-11 14:45:27 -0800622 @staticmethod
623 def unpack(reader):
624 subtype, = reader.peek('!H', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800625 subclass = nicira.subtypes.get(subtype)
626 if subclass:
627 return subclass.unpack(reader)
628
629 obj = nicira()
630 _type = reader.read("!H")[0]
631 assert(_type == 65535)
632 _len = reader.read("!H")[0]
633 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800634 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800635 _experimenter = reader.read("!L")[0]
636 assert(_experimenter == 8992)
637 obj.subtype = reader.read("!H")[0]
638 reader.skip(2)
639 reader.skip(4)
640 return obj
641
642 def __eq__(self, other):
643 if type(self) != type(other): return False
644 if self.subtype != other.subtype: return False
645 return True
646
647 def pretty_print(self, q):
648 q.text("nicira {")
649 with q.group():
650 with q.indent(2):
651 q.breakable()
652 q.breakable()
653 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800654
655experimenter.subtypes[8992] = nicira
656
657class nicira_dec_ttl(nicira):
Dan Talaycof6202252013-07-02 01:00:29 -0700658 type = 65535
659 experimenter = 8992
Rich Lanec2ee4b82013-04-24 17:12:38 -0700660 subtype = 18
661
662 def __init__(self):
663 return
664
665 def pack(self):
666 packed = []
667 packed.append(struct.pack("!H", self.type))
668 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
669 packed.append(struct.pack("!L", self.experimenter))
670 packed.append(struct.pack("!H", self.subtype))
671 packed.append('\x00' * 2)
672 packed.append('\x00' * 4)
673 length = sum([len(x) for x in packed])
674 packed[1] = struct.pack("!H", length)
675 return ''.join(packed)
676
677 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800678 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700679 obj = nicira_dec_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700680 _type = reader.read("!H")[0]
681 assert(_type == 65535)
682 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800683 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800684 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700685 _experimenter = reader.read("!L")[0]
686 assert(_experimenter == 8992)
687 _subtype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700688 assert(_subtype == 18)
689 reader.skip(2)
690 reader.skip(4)
691 return obj
692
693 def __eq__(self, other):
694 if type(self) != type(other): return False
695 return True
696
Rich Lanec2ee4b82013-04-24 17:12:38 -0700697 def pretty_print(self, q):
698 q.text("nicira_dec_ttl {")
699 with q.group():
700 with q.indent(2):
701 q.breakable()
702 q.breakable()
703 q.text('}')
704
Rich Lane7dcdf022013-12-11 14:45:27 -0800705nicira.subtypes[18] = nicira_dec_ttl
706
707class output(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700708 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700709
710 def __init__(self, port=None, max_len=None):
711 if port != None:
712 self.port = port
713 else:
714 self.port = 0
715 if max_len != None:
716 self.max_len = max_len
717 else:
718 self.max_len = 0
719 return
720
721 def pack(self):
722 packed = []
723 packed.append(struct.pack("!H", self.type))
724 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700725 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700726 packed.append(struct.pack("!H", self.max_len))
727 packed.append('\x00' * 6)
728 length = sum([len(x) for x in packed])
729 packed[1] = struct.pack("!H", length)
730 return ''.join(packed)
731
732 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800733 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700734 obj = output()
Dan Talaycof6202252013-07-02 01:00:29 -0700735 _type = reader.read("!H")[0]
736 assert(_type == 0)
737 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800738 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800739 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700740 obj.port = util.unpack_port_no(reader)
741 obj.max_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700742 reader.skip(6)
743 return obj
744
745 def __eq__(self, other):
746 if type(self) != type(other): return False
747 if self.port != other.port: return False
748 if self.max_len != other.max_len: return False
749 return True
750
Rich Lanec2ee4b82013-04-24 17:12:38 -0700751 def pretty_print(self, q):
752 q.text("output {")
753 with q.group():
754 with q.indent(2):
755 q.breakable()
756 q.text("port = ");
757 q.text(util.pretty_port(self.port))
758 q.text(","); q.breakable()
759 q.text("max_len = ");
760 q.text("%#x" % self.max_len)
761 q.breakable()
762 q.text('}')
763
Rich Lane7dcdf022013-12-11 14:45:27 -0800764action.subtypes[0] = output
765
766class pop_mpls(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700767 type = 20
Rich Lanec2ee4b82013-04-24 17:12:38 -0700768
769 def __init__(self, ethertype=None):
770 if ethertype != None:
771 self.ethertype = ethertype
772 else:
773 self.ethertype = 0
774 return
775
776 def pack(self):
777 packed = []
778 packed.append(struct.pack("!H", self.type))
779 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
780 packed.append(struct.pack("!H", self.ethertype))
781 packed.append('\x00' * 2)
782 length = sum([len(x) for x in packed])
783 packed[1] = struct.pack("!H", length)
784 return ''.join(packed)
785
786 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800787 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700788 obj = pop_mpls()
Dan Talaycof6202252013-07-02 01:00:29 -0700789 _type = reader.read("!H")[0]
790 assert(_type == 20)
791 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800792 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800793 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700794 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700795 reader.skip(2)
796 return obj
797
798 def __eq__(self, other):
799 if type(self) != type(other): return False
800 if self.ethertype != other.ethertype: return False
801 return True
802
Rich Lanec2ee4b82013-04-24 17:12:38 -0700803 def pretty_print(self, q):
804 q.text("pop_mpls {")
805 with q.group():
806 with q.indent(2):
807 q.breakable()
808 q.text("ethertype = ");
809 q.text("%#x" % self.ethertype)
810 q.breakable()
811 q.text('}')
812
Rich Lane7dcdf022013-12-11 14:45:27 -0800813action.subtypes[20] = pop_mpls
814
815class pop_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700816 type = 18
Rich Lanec2ee4b82013-04-24 17:12:38 -0700817
818 def __init__(self):
819 return
820
821 def pack(self):
822 packed = []
823 packed.append(struct.pack("!H", self.type))
824 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
825 packed.append('\x00' * 4)
826 length = sum([len(x) for x in packed])
827 packed[1] = struct.pack("!H", length)
828 return ''.join(packed)
829
830 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800831 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700832 obj = pop_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -0700833 _type = reader.read("!H")[0]
834 assert(_type == 18)
835 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800836 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800837 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700838 reader.skip(4)
839 return obj
840
841 def __eq__(self, other):
842 if type(self) != type(other): return False
843 return True
844
Rich Lanec2ee4b82013-04-24 17:12:38 -0700845 def pretty_print(self, q):
846 q.text("pop_vlan {")
847 with q.group():
848 with q.indent(2):
849 q.breakable()
850 q.breakable()
851 q.text('}')
852
Rich Lane7dcdf022013-12-11 14:45:27 -0800853action.subtypes[18] = pop_vlan
854
855class push_mpls(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700856 type = 19
Rich Lanec2ee4b82013-04-24 17:12:38 -0700857
858 def __init__(self, ethertype=None):
859 if ethertype != None:
860 self.ethertype = ethertype
861 else:
862 self.ethertype = 0
863 return
864
865 def pack(self):
866 packed = []
867 packed.append(struct.pack("!H", self.type))
868 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
869 packed.append(struct.pack("!H", self.ethertype))
870 packed.append('\x00' * 2)
871 length = sum([len(x) for x in packed])
872 packed[1] = struct.pack("!H", length)
873 return ''.join(packed)
874
875 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800876 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700877 obj = push_mpls()
Dan Talaycof6202252013-07-02 01:00:29 -0700878 _type = reader.read("!H")[0]
879 assert(_type == 19)
880 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800881 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800882 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700883 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700884 reader.skip(2)
885 return obj
886
887 def __eq__(self, other):
888 if type(self) != type(other): return False
889 if self.ethertype != other.ethertype: return False
890 return True
891
Rich Lanec2ee4b82013-04-24 17:12:38 -0700892 def pretty_print(self, q):
893 q.text("push_mpls {")
894 with q.group():
895 with q.indent(2):
896 q.breakable()
897 q.text("ethertype = ");
898 q.text("%#x" % self.ethertype)
899 q.breakable()
900 q.text('}')
901
Rich Lane7dcdf022013-12-11 14:45:27 -0800902action.subtypes[19] = push_mpls
903
904class push_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700905 type = 17
Rich Lanec2ee4b82013-04-24 17:12:38 -0700906
907 def __init__(self, ethertype=None):
908 if ethertype != None:
909 self.ethertype = ethertype
910 else:
911 self.ethertype = 0
912 return
913
914 def pack(self):
915 packed = []
916 packed.append(struct.pack("!H", self.type))
917 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
918 packed.append(struct.pack("!H", self.ethertype))
919 packed.append('\x00' * 2)
920 length = sum([len(x) for x in packed])
921 packed[1] = struct.pack("!H", length)
922 return ''.join(packed)
923
924 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800925 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700926 obj = push_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -0700927 _type = reader.read("!H")[0]
928 assert(_type == 17)
929 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800930 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800931 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700932 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700933 reader.skip(2)
934 return obj
935
936 def __eq__(self, other):
937 if type(self) != type(other): return False
938 if self.ethertype != other.ethertype: return False
939 return True
940
Rich Lanec2ee4b82013-04-24 17:12:38 -0700941 def pretty_print(self, q):
942 q.text("push_vlan {")
943 with q.group():
944 with q.indent(2):
945 q.breakable()
946 q.text("ethertype = ");
947 q.text("%#x" % self.ethertype)
948 q.breakable()
949 q.text('}')
950
Rich Lane7dcdf022013-12-11 14:45:27 -0800951action.subtypes[17] = push_vlan
952
953class set_field(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700954 type = 25
Rich Lanec2ee4b82013-04-24 17:12:38 -0700955
956 def __init__(self, field=None):
957 if field != None:
958 self.field = field
959 else:
Rich Laned53156a2013-08-05 17:17:33 -0700960 self.field = None
Rich Lanec2ee4b82013-04-24 17:12:38 -0700961 return
962
963 def pack(self):
964 packed = []
965 packed.append(struct.pack("!H", self.type))
966 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Rich Laned53156a2013-08-05 17:17:33 -0700967 packed.append(self.field.pack())
Rich Lanec2ee4b82013-04-24 17:12:38 -0700968 length = sum([len(x) for x in packed])
Rich Laned53156a2013-08-05 17:17:33 -0700969 packed.append(loxi.generic_util.pad_to(8, length))
970 length += len(packed[-1])
Rich Lanec2ee4b82013-04-24 17:12:38 -0700971 packed[1] = struct.pack("!H", length)
972 return ''.join(packed)
973
974 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800975 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700976 obj = set_field()
Dan Talaycof6202252013-07-02 01:00:29 -0700977 _type = reader.read("!H")[0]
978 assert(_type == 25)
979 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800980 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800981 reader = orig_reader.slice(_len, 4)
Rich Lanee2567702015-01-26 15:04:35 -0800982 obj.field = ofp.oxm.oxm.unpack(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700983 return obj
984
985 def __eq__(self, other):
986 if type(self) != type(other): return False
987 if self.field != other.field: return False
988 return True
989
Rich Lanec2ee4b82013-04-24 17:12:38 -0700990 def pretty_print(self, q):
991 q.text("set_field {")
992 with q.group():
993 with q.indent(2):
994 q.breakable()
995 q.text("field = ");
996 q.pp(self.field)
997 q.breakable()
998 q.text('}')
999
Rich Lane7dcdf022013-12-11 14:45:27 -08001000action.subtypes[25] = set_field
1001
1002class set_mpls_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001003 type = 15
Rich Lanec2ee4b82013-04-24 17:12:38 -07001004
1005 def __init__(self, mpls_ttl=None):
1006 if mpls_ttl != None:
1007 self.mpls_ttl = mpls_ttl
1008 else:
1009 self.mpls_ttl = 0
1010 return
1011
1012 def pack(self):
1013 packed = []
1014 packed.append(struct.pack("!H", self.type))
1015 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1016 packed.append(struct.pack("!B", self.mpls_ttl))
1017 packed.append('\x00' * 3)
1018 length = sum([len(x) for x in packed])
1019 packed[1] = struct.pack("!H", length)
1020 return ''.join(packed)
1021
1022 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001023 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001024 obj = set_mpls_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -07001025 _type = reader.read("!H")[0]
1026 assert(_type == 15)
1027 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001028 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001029 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001030 obj.mpls_ttl = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001031 reader.skip(3)
1032 return obj
1033
1034 def __eq__(self, other):
1035 if type(self) != type(other): return False
1036 if self.mpls_ttl != other.mpls_ttl: return False
1037 return True
1038
Rich Lanec2ee4b82013-04-24 17:12:38 -07001039 def pretty_print(self, q):
1040 q.text("set_mpls_ttl {")
1041 with q.group():
1042 with q.indent(2):
1043 q.breakable()
1044 q.text("mpls_ttl = ");
1045 q.text("%#x" % self.mpls_ttl)
1046 q.breakable()
1047 q.text('}')
1048
Rich Lane7dcdf022013-12-11 14:45:27 -08001049action.subtypes[15] = set_mpls_ttl
1050
1051class set_nw_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001052 type = 23
Rich Lanec2ee4b82013-04-24 17:12:38 -07001053
1054 def __init__(self, nw_ttl=None):
1055 if nw_ttl != None:
1056 self.nw_ttl = nw_ttl
1057 else:
1058 self.nw_ttl = 0
1059 return
1060
1061 def pack(self):
1062 packed = []
1063 packed.append(struct.pack("!H", self.type))
1064 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1065 packed.append(struct.pack("!B", self.nw_ttl))
1066 packed.append('\x00' * 3)
1067 length = sum([len(x) for x in packed])
1068 packed[1] = struct.pack("!H", length)
1069 return ''.join(packed)
1070
1071 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001072 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001073 obj = set_nw_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -07001074 _type = reader.read("!H")[0]
1075 assert(_type == 23)
1076 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001077 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001078 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001079 obj.nw_ttl = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001080 reader.skip(3)
1081 return obj
1082
1083 def __eq__(self, other):
1084 if type(self) != type(other): return False
1085 if self.nw_ttl != other.nw_ttl: return False
1086 return True
1087
Rich Lanec2ee4b82013-04-24 17:12:38 -07001088 def pretty_print(self, q):
1089 q.text("set_nw_ttl {")
1090 with q.group():
1091 with q.indent(2):
1092 q.breakable()
1093 q.text("nw_ttl = ");
1094 q.text("%#x" % self.nw_ttl)
1095 q.breakable()
1096 q.text('}')
1097
Rich Lane7dcdf022013-12-11 14:45:27 -08001098action.subtypes[23] = set_nw_ttl
1099
1100class set_queue(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001101 type = 21
Rich Lanec2ee4b82013-04-24 17:12:38 -07001102
1103 def __init__(self, queue_id=None):
1104 if queue_id != None:
1105 self.queue_id = queue_id
1106 else:
1107 self.queue_id = 0
1108 return
1109
1110 def pack(self):
1111 packed = []
1112 packed.append(struct.pack("!H", self.type))
1113 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1114 packed.append(struct.pack("!L", self.queue_id))
1115 length = sum([len(x) for x in packed])
1116 packed[1] = struct.pack("!H", length)
1117 return ''.join(packed)
1118
1119 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001120 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001121 obj = set_queue()
Dan Talaycof6202252013-07-02 01:00:29 -07001122 _type = reader.read("!H")[0]
1123 assert(_type == 21)
1124 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001125 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001126 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001127 obj.queue_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001128 return obj
1129
1130 def __eq__(self, other):
1131 if type(self) != type(other): return False
1132 if self.queue_id != other.queue_id: return False
1133 return True
1134
Rich Lanec2ee4b82013-04-24 17:12:38 -07001135 def pretty_print(self, q):
1136 q.text("set_queue {")
1137 with q.group():
1138 with q.indent(2):
1139 q.breakable()
1140 q.text("queue_id = ");
1141 q.text("%#x" % self.queue_id)
1142 q.breakable()
1143 q.text('}')
1144
Rich Lane7dcdf022013-12-11 14:45:27 -08001145action.subtypes[21] = set_queue
Rich Lanec2ee4b82013-04-24 17:12:38 -07001146
Rich Lanec2ee4b82013-04-24 17:12:38 -07001147