blob: 4875e746883bb2f16661029eb2003be1e6cb440c [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.of13']
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
macauley_cheng8e0b3ee2015-08-31 15:18:57 +0800144"""
Rich Lane7dcdf022013-12-11 14:45:27 -0800145class 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 Lane2e079da2014-10-29 15:30:24 -0700258class bsn_gentable(bsn):
259 type = 65535
260 experimenter = 6035143
261 subtype = 5
262
263 def __init__(self, table_id=None, key=None):
264 if table_id != None:
265 self.table_id = table_id
266 else:
267 self.table_id = 0
268 if key != None:
269 self.key = key
270 else:
271 self.key = []
272 return
273
274 def pack(self):
275 packed = []
276 packed.append(struct.pack("!H", self.type))
277 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
278 packed.append(struct.pack("!L", self.experimenter))
279 packed.append(struct.pack("!L", self.subtype))
280 packed.append(struct.pack("!L", self.table_id))
281 packed.append(loxi.generic_util.pack_list(self.key))
282 length = sum([len(x) for x in packed])
283 packed[1] = struct.pack("!H", length)
284 return ''.join(packed)
285
286 @staticmethod
287 def unpack(reader):
288 obj = bsn_gentable()
289 _type = reader.read("!H")[0]
290 assert(_type == 65535)
291 _len = reader.read("!H")[0]
292 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800293 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -0700294 _experimenter = reader.read("!L")[0]
295 assert(_experimenter == 6035143)
296 _subtype = reader.read("!L")[0]
297 assert(_subtype == 5)
298 obj.table_id = reader.read("!L")[0]
Rich Lanee2567702015-01-26 15:04:35 -0800299 obj.key = loxi.generic_util.unpack_list(reader, ofp.bsn_tlv.bsn_tlv.unpack)
Rich Lane2e079da2014-10-29 15:30:24 -0700300 return obj
301
302 def __eq__(self, other):
303 if type(self) != type(other): return False
304 if self.table_id != other.table_id: return False
305 if self.key != other.key: return False
306 return True
307
308 def pretty_print(self, q):
309 q.text("bsn_gentable {")
310 with q.group():
311 with q.indent(2):
312 q.breakable()
313 q.text("table_id = ");
314 q.text("%#x" % self.table_id)
315 q.text(","); q.breakable()
316 q.text("key = ");
317 q.pp(self.key)
318 q.breakable()
319 q.text('}')
320
321bsn.subtypes[5] = bsn_gentable
322
Rich Lane7dcdf022013-12-11 14:45:27 -0800323class bsn_mirror(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700324 type = 65535
325 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -0700326 subtype = 1
327
328 def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None):
329 if dest_port != None:
330 self.dest_port = dest_port
331 else:
332 self.dest_port = 0
333 if vlan_tag != None:
334 self.vlan_tag = vlan_tag
335 else:
336 self.vlan_tag = 0
337 if copy_stage != None:
338 self.copy_stage = copy_stage
339 else:
340 self.copy_stage = 0
341 return
342
343 def pack(self):
344 packed = []
345 packed.append(struct.pack("!H", self.type))
346 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
347 packed.append(struct.pack("!L", self.experimenter))
348 packed.append(struct.pack("!L", self.subtype))
349 packed.append(struct.pack("!L", self.dest_port))
350 packed.append(struct.pack("!L", self.vlan_tag))
351 packed.append(struct.pack("!B", self.copy_stage))
352 packed.append('\x00' * 3)
353 length = sum([len(x) for x in packed])
354 packed[1] = struct.pack("!H", length)
355 return ''.join(packed)
356
357 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800358 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700359 obj = bsn_mirror()
Dan Talaycof6202252013-07-02 01:00:29 -0700360 _type = reader.read("!H")[0]
361 assert(_type == 65535)
362 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800363 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800364 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700365 _experimenter = reader.read("!L")[0]
366 assert(_experimenter == 6035143)
367 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700368 assert(_subtype == 1)
Dan Talaycof6202252013-07-02 01:00:29 -0700369 obj.dest_port = reader.read("!L")[0]
370 obj.vlan_tag = reader.read("!L")[0]
371 obj.copy_stage = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700372 reader.skip(3)
373 return obj
374
375 def __eq__(self, other):
376 if type(self) != type(other): return False
377 if self.dest_port != other.dest_port: return False
378 if self.vlan_tag != other.vlan_tag: return False
379 if self.copy_stage != other.copy_stage: return False
380 return True
381
Rich Lanec2ee4b82013-04-24 17:12:38 -0700382 def pretty_print(self, q):
383 q.text("bsn_mirror {")
384 with q.group():
385 with q.indent(2):
386 q.breakable()
387 q.text("dest_port = ");
388 q.text("%#x" % self.dest_port)
389 q.text(","); q.breakable()
390 q.text("vlan_tag = ");
391 q.text("%#x" % self.vlan_tag)
392 q.text(","); q.breakable()
393 q.text("copy_stage = ");
394 q.text("%#x" % self.copy_stage)
395 q.breakable()
396 q.text('}')
397
Rich Lane7dcdf022013-12-11 14:45:27 -0800398bsn.subtypes[1] = bsn_mirror
399
400class bsn_set_tunnel_dst(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700401 type = 65535
402 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -0700403 subtype = 2
404
405 def __init__(self, dst=None):
406 if dst != None:
407 self.dst = dst
408 else:
409 self.dst = 0
410 return
411
412 def pack(self):
413 packed = []
414 packed.append(struct.pack("!H", self.type))
415 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
416 packed.append(struct.pack("!L", self.experimenter))
417 packed.append(struct.pack("!L", self.subtype))
418 packed.append(struct.pack("!L", self.dst))
419 length = sum([len(x) for x in packed])
420 packed[1] = struct.pack("!H", length)
421 return ''.join(packed)
422
423 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800424 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700425 obj = bsn_set_tunnel_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700426 _type = reader.read("!H")[0]
427 assert(_type == 65535)
428 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800429 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800430 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700431 _experimenter = reader.read("!L")[0]
432 assert(_experimenter == 6035143)
433 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700434 assert(_subtype == 2)
Dan Talaycof6202252013-07-02 01:00:29 -0700435 obj.dst = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700436 return obj
437
438 def __eq__(self, other):
439 if type(self) != type(other): return False
440 if self.dst != other.dst: return False
441 return True
442
Rich Lanec2ee4b82013-04-24 17:12:38 -0700443 def pretty_print(self, q):
444 q.text("bsn_set_tunnel_dst {")
445 with q.group():
446 with q.indent(2):
447 q.breakable()
448 q.text("dst = ");
449 q.text("%#x" % self.dst)
450 q.breakable()
451 q.text('}')
452
Rich Lane7dcdf022013-12-11 14:45:27 -0800453bsn.subtypes[2] = bsn_set_tunnel_dst
macauley_cheng8e0b3ee2015-08-31 15:18:57 +0800454"""
Rich Lane7dcdf022013-12-11 14:45:27 -0800455
456class copy_ttl_in(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700457 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -0700458
459 def __init__(self):
460 return
461
462 def pack(self):
463 packed = []
464 packed.append(struct.pack("!H", self.type))
465 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
466 packed.append('\x00' * 4)
467 length = sum([len(x) for x in packed])
468 packed[1] = struct.pack("!H", length)
469 return ''.join(packed)
470
471 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800472 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700473 obj = copy_ttl_in()
Dan Talaycof6202252013-07-02 01:00:29 -0700474 _type = reader.read("!H")[0]
475 assert(_type == 12)
476 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800477 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800478 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700479 reader.skip(4)
480 return obj
481
482 def __eq__(self, other):
483 if type(self) != type(other): return False
484 return True
485
Rich Lanec2ee4b82013-04-24 17:12:38 -0700486 def pretty_print(self, q):
487 q.text("copy_ttl_in {")
488 with q.group():
489 with q.indent(2):
490 q.breakable()
491 q.breakable()
492 q.text('}')
493
Rich Lane7dcdf022013-12-11 14:45:27 -0800494action.subtypes[12] = copy_ttl_in
495
496class copy_ttl_out(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700497 type = 11
Rich Lanec2ee4b82013-04-24 17:12:38 -0700498
499 def __init__(self):
500 return
501
502 def pack(self):
503 packed = []
504 packed.append(struct.pack("!H", self.type))
505 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
506 packed.append('\x00' * 4)
507 length = sum([len(x) for x in packed])
508 packed[1] = struct.pack("!H", length)
509 return ''.join(packed)
510
511 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800512 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700513 obj = copy_ttl_out()
Dan Talaycof6202252013-07-02 01:00:29 -0700514 _type = reader.read("!H")[0]
515 assert(_type == 11)
516 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800517 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800518 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700519 reader.skip(4)
520 return obj
521
522 def __eq__(self, other):
523 if type(self) != type(other): return False
524 return True
525
Rich Lanec2ee4b82013-04-24 17:12:38 -0700526 def pretty_print(self, q):
527 q.text("copy_ttl_out {")
528 with q.group():
529 with q.indent(2):
530 q.breakable()
531 q.breakable()
532 q.text('}')
533
Rich Lane7dcdf022013-12-11 14:45:27 -0800534action.subtypes[11] = copy_ttl_out
535
536class dec_mpls_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700537 type = 16
Rich Lanec2ee4b82013-04-24 17:12:38 -0700538
539 def __init__(self):
540 return
541
542 def pack(self):
543 packed = []
544 packed.append(struct.pack("!H", self.type))
545 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
546 packed.append('\x00' * 4)
547 length = sum([len(x) for x in packed])
548 packed[1] = struct.pack("!H", length)
549 return ''.join(packed)
550
551 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800552 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700553 obj = dec_mpls_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700554 _type = reader.read("!H")[0]
555 assert(_type == 16)
556 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800557 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800558 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700559 reader.skip(4)
560 return obj
561
562 def __eq__(self, other):
563 if type(self) != type(other): return False
564 return True
565
Rich Lanec2ee4b82013-04-24 17:12:38 -0700566 def pretty_print(self, q):
567 q.text("dec_mpls_ttl {")
568 with q.group():
569 with q.indent(2):
570 q.breakable()
571 q.breakable()
572 q.text('}')
573
Rich Lane7dcdf022013-12-11 14:45:27 -0800574action.subtypes[16] = dec_mpls_ttl
575
576class dec_nw_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700577 type = 24
Rich Lanec2ee4b82013-04-24 17:12:38 -0700578
579 def __init__(self):
580 return
581
582 def pack(self):
583 packed = []
584 packed.append(struct.pack("!H", self.type))
585 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
586 packed.append('\x00' * 4)
587 length = sum([len(x) for x in packed])
588 packed[1] = struct.pack("!H", length)
589 return ''.join(packed)
590
591 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800592 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700593 obj = dec_nw_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700594 _type = reader.read("!H")[0]
595 assert(_type == 24)
596 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800597 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800598 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700599 reader.skip(4)
600 return obj
601
602 def __eq__(self, other):
603 if type(self) != type(other): return False
604 return True
605
Rich Lanec2ee4b82013-04-24 17:12:38 -0700606 def pretty_print(self, q):
607 q.text("dec_nw_ttl {")
608 with q.group():
609 with q.indent(2):
610 q.breakable()
611 q.breakable()
612 q.text('}')
613
Rich Lane7dcdf022013-12-11 14:45:27 -0800614action.subtypes[24] = dec_nw_ttl
615
616class group(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700617 type = 22
Rich Lanec2ee4b82013-04-24 17:12:38 -0700618
619 def __init__(self, group_id=None):
620 if group_id != None:
621 self.group_id = group_id
622 else:
623 self.group_id = 0
624 return
625
626 def pack(self):
627 packed = []
628 packed.append(struct.pack("!H", self.type))
629 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
630 packed.append(struct.pack("!L", self.group_id))
631 length = sum([len(x) for x in packed])
632 packed[1] = struct.pack("!H", length)
633 return ''.join(packed)
634
635 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800636 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700637 obj = group()
Dan Talaycof6202252013-07-02 01:00:29 -0700638 _type = reader.read("!H")[0]
639 assert(_type == 22)
640 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800641 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800642 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700643 obj.group_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700644 return obj
645
646 def __eq__(self, other):
647 if type(self) != type(other): return False
648 if self.group_id != other.group_id: return False
649 return True
650
Rich Lanec2ee4b82013-04-24 17:12:38 -0700651 def pretty_print(self, q):
652 q.text("group {")
653 with q.group():
654 with q.indent(2):
655 q.breakable()
656 q.text("group_id = ");
657 q.text("%#x" % self.group_id)
658 q.breakable()
659 q.text('}')
660
Rich Lane7dcdf022013-12-11 14:45:27 -0800661action.subtypes[22] = group
macauley_cheng4ba94772015-08-31 17:46:11 +0800662"""
Rich Lane7dcdf022013-12-11 14:45:27 -0800663class nicira(experimenter):
664 subtypes = {}
665
Rich Lane95f7fc92014-01-27 17:08:16 -0800666 type = 65535
667 experimenter = 8992
668
669 def __init__(self, subtype=None):
670 if subtype != None:
671 self.subtype = subtype
672 else:
673 self.subtype = 0
674 return
675
676 def pack(self):
677 packed = []
678 packed.append(struct.pack("!H", self.type))
679 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
680 packed.append(struct.pack("!L", self.experimenter))
681 packed.append(struct.pack("!H", self.subtype))
682 packed.append('\x00' * 2)
683 packed.append('\x00' * 4)
684 length = sum([len(x) for x in packed])
685 packed[1] = struct.pack("!H", length)
686 return ''.join(packed)
687
Rich Lane7dcdf022013-12-11 14:45:27 -0800688 @staticmethod
689 def unpack(reader):
690 subtype, = reader.peek('!H', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800691 subclass = nicira.subtypes.get(subtype)
692 if subclass:
693 return subclass.unpack(reader)
694
695 obj = nicira()
696 _type = reader.read("!H")[0]
697 assert(_type == 65535)
698 _len = reader.read("!H")[0]
699 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800700 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800701 _experimenter = reader.read("!L")[0]
702 assert(_experimenter == 8992)
703 obj.subtype = reader.read("!H")[0]
704 reader.skip(2)
705 reader.skip(4)
706 return obj
707
708 def __eq__(self, other):
709 if type(self) != type(other): return False
710 if self.subtype != other.subtype: return False
711 return True
712
713 def pretty_print(self, q):
714 q.text("nicira {")
715 with q.group():
716 with q.indent(2):
717 q.breakable()
718 q.breakable()
719 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800720
721experimenter.subtypes[8992] = nicira
722
723class nicira_dec_ttl(nicira):
Dan Talaycof6202252013-07-02 01:00:29 -0700724 type = 65535
725 experimenter = 8992
Rich Lanec2ee4b82013-04-24 17:12:38 -0700726 subtype = 18
727
728 def __init__(self):
729 return
730
731 def pack(self):
732 packed = []
733 packed.append(struct.pack("!H", self.type))
734 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
735 packed.append(struct.pack("!L", self.experimenter))
736 packed.append(struct.pack("!H", self.subtype))
737 packed.append('\x00' * 2)
738 packed.append('\x00' * 4)
739 length = sum([len(x) for x in packed])
740 packed[1] = struct.pack("!H", length)
741 return ''.join(packed)
742
743 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800744 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700745 obj = nicira_dec_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700746 _type = reader.read("!H")[0]
747 assert(_type == 65535)
748 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800749 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800750 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700751 _experimenter = reader.read("!L")[0]
752 assert(_experimenter == 8992)
753 _subtype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700754 assert(_subtype == 18)
755 reader.skip(2)
756 reader.skip(4)
757 return obj
758
759 def __eq__(self, other):
760 if type(self) != type(other): return False
761 return True
762
Rich Lanec2ee4b82013-04-24 17:12:38 -0700763 def pretty_print(self, q):
764 q.text("nicira_dec_ttl {")
765 with q.group():
766 with q.indent(2):
767 q.breakable()
768 q.breakable()
769 q.text('}')
770
Rich Lane7dcdf022013-12-11 14:45:27 -0800771nicira.subtypes[18] = nicira_dec_ttl
macauley_cheng4ba94772015-08-31 17:46:11 +0800772"""
Rich Lane7dcdf022013-12-11 14:45:27 -0800773class output(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700774 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700775
776 def __init__(self, port=None, max_len=None):
777 if port != None:
778 self.port = port
779 else:
780 self.port = 0
781 if max_len != None:
782 self.max_len = max_len
783 else:
784 self.max_len = 0
785 return
786
787 def pack(self):
788 packed = []
789 packed.append(struct.pack("!H", self.type))
790 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700791 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700792 packed.append(struct.pack("!H", self.max_len))
793 packed.append('\x00' * 6)
794 length = sum([len(x) for x in packed])
795 packed[1] = struct.pack("!H", length)
796 return ''.join(packed)
797
798 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800799 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700800 obj = output()
Dan Talaycof6202252013-07-02 01:00:29 -0700801 _type = reader.read("!H")[0]
802 assert(_type == 0)
803 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800804 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800805 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700806 obj.port = util.unpack_port_no(reader)
807 obj.max_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700808 reader.skip(6)
809 return obj
810
811 def __eq__(self, other):
812 if type(self) != type(other): return False
813 if self.port != other.port: return False
814 if self.max_len != other.max_len: return False
815 return True
816
Rich Lanec2ee4b82013-04-24 17:12:38 -0700817 def pretty_print(self, q):
818 q.text("output {")
819 with q.group():
820 with q.indent(2):
821 q.breakable()
822 q.text("port = ");
823 q.text(util.pretty_port(self.port))
824 q.text(","); q.breakable()
825 q.text("max_len = ");
826 q.text("%#x" % self.max_len)
827 q.breakable()
828 q.text('}')
829
Rich Lane7dcdf022013-12-11 14:45:27 -0800830action.subtypes[0] = output
831
832class pop_mpls(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700833 type = 20
Rich Lanec2ee4b82013-04-24 17:12:38 -0700834
835 def __init__(self, ethertype=None):
836 if ethertype != None:
837 self.ethertype = ethertype
838 else:
839 self.ethertype = 0
840 return
841
842 def pack(self):
843 packed = []
844 packed.append(struct.pack("!H", self.type))
845 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
846 packed.append(struct.pack("!H", self.ethertype))
847 packed.append('\x00' * 2)
848 length = sum([len(x) for x in packed])
849 packed[1] = struct.pack("!H", length)
850 return ''.join(packed)
851
852 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800853 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700854 obj = pop_mpls()
Dan Talaycof6202252013-07-02 01:00:29 -0700855 _type = reader.read("!H")[0]
856 assert(_type == 20)
857 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800858 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800859 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700860 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700861 reader.skip(2)
862 return obj
863
864 def __eq__(self, other):
865 if type(self) != type(other): return False
866 if self.ethertype != other.ethertype: return False
867 return True
868
Rich Lanec2ee4b82013-04-24 17:12:38 -0700869 def pretty_print(self, q):
870 q.text("pop_mpls {")
871 with q.group():
872 with q.indent(2):
873 q.breakable()
874 q.text("ethertype = ");
875 q.text("%#x" % self.ethertype)
876 q.breakable()
877 q.text('}')
878
Rich Lane7dcdf022013-12-11 14:45:27 -0800879action.subtypes[20] = pop_mpls
880
881class pop_pbb(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700882 type = 27
Rich Lanec2ee4b82013-04-24 17:12:38 -0700883
884 def __init__(self):
885 return
886
887 def pack(self):
888 packed = []
889 packed.append(struct.pack("!H", self.type))
890 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
891 packed.append('\x00' * 4)
892 length = sum([len(x) for x in packed])
893 packed[1] = struct.pack("!H", length)
894 return ''.join(packed)
895
896 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800897 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700898 obj = pop_pbb()
Dan Talaycof6202252013-07-02 01:00:29 -0700899 _type = reader.read("!H")[0]
900 assert(_type == 27)
901 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800902 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800903 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700904 reader.skip(4)
905 return obj
906
907 def __eq__(self, other):
908 if type(self) != type(other): return False
909 return True
910
Rich Lanec2ee4b82013-04-24 17:12:38 -0700911 def pretty_print(self, q):
912 q.text("pop_pbb {")
913 with q.group():
914 with q.indent(2):
915 q.breakable()
916 q.breakable()
917 q.text('}')
918
Rich Lane7dcdf022013-12-11 14:45:27 -0800919action.subtypes[27] = pop_pbb
920
921class pop_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700922 type = 18
Rich Lanec2ee4b82013-04-24 17:12:38 -0700923
924 def __init__(self):
925 return
926
927 def pack(self):
928 packed = []
929 packed.append(struct.pack("!H", self.type))
930 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
931 packed.append('\x00' * 4)
932 length = sum([len(x) for x in packed])
933 packed[1] = struct.pack("!H", length)
934 return ''.join(packed)
935
936 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800937 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700938 obj = pop_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -0700939 _type = reader.read("!H")[0]
940 assert(_type == 18)
941 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800942 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800943 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700944 reader.skip(4)
945 return obj
946
947 def __eq__(self, other):
948 if type(self) != type(other): return False
949 return True
950
Rich Lanec2ee4b82013-04-24 17:12:38 -0700951 def pretty_print(self, q):
952 q.text("pop_vlan {")
953 with q.group():
954 with q.indent(2):
955 q.breakable()
956 q.breakable()
957 q.text('}')
958
Rich Lane7dcdf022013-12-11 14:45:27 -0800959action.subtypes[18] = pop_vlan
960
961class push_mpls(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700962 type = 19
Rich Lanec2ee4b82013-04-24 17:12:38 -0700963
964 def __init__(self, ethertype=None):
965 if ethertype != None:
966 self.ethertype = ethertype
967 else:
968 self.ethertype = 0
969 return
970
971 def pack(self):
972 packed = []
973 packed.append(struct.pack("!H", self.type))
974 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
975 packed.append(struct.pack("!H", self.ethertype))
976 packed.append('\x00' * 2)
977 length = sum([len(x) for x in packed])
978 packed[1] = struct.pack("!H", length)
979 return ''.join(packed)
980
981 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800982 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700983 obj = push_mpls()
Dan Talaycof6202252013-07-02 01:00:29 -0700984 _type = reader.read("!H")[0]
985 assert(_type == 19)
986 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800987 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800988 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700989 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700990 reader.skip(2)
991 return obj
992
993 def __eq__(self, other):
994 if type(self) != type(other): return False
995 if self.ethertype != other.ethertype: return False
996 return True
997
Rich Lanec2ee4b82013-04-24 17:12:38 -0700998 def pretty_print(self, q):
999 q.text("push_mpls {")
1000 with q.group():
1001 with q.indent(2):
1002 q.breakable()
1003 q.text("ethertype = ");
1004 q.text("%#x" % self.ethertype)
1005 q.breakable()
1006 q.text('}')
1007
Rich Lane7dcdf022013-12-11 14:45:27 -08001008action.subtypes[19] = push_mpls
1009
1010class push_pbb(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001011 type = 26
Rich Lanec2ee4b82013-04-24 17:12:38 -07001012
1013 def __init__(self, ethertype=None):
1014 if ethertype != None:
1015 self.ethertype = ethertype
1016 else:
1017 self.ethertype = 0
1018 return
1019
1020 def pack(self):
1021 packed = []
1022 packed.append(struct.pack("!H", self.type))
1023 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1024 packed.append(struct.pack("!H", self.ethertype))
1025 packed.append('\x00' * 2)
1026 length = sum([len(x) for x in packed])
1027 packed[1] = struct.pack("!H", length)
1028 return ''.join(packed)
1029
1030 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001031 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001032 obj = push_pbb()
Dan Talaycof6202252013-07-02 01:00:29 -07001033 _type = reader.read("!H")[0]
1034 assert(_type == 26)
1035 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001036 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001037 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001038 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001039 reader.skip(2)
1040 return obj
1041
1042 def __eq__(self, other):
1043 if type(self) != type(other): return False
1044 if self.ethertype != other.ethertype: return False
1045 return True
1046
Rich Lanec2ee4b82013-04-24 17:12:38 -07001047 def pretty_print(self, q):
1048 q.text("push_pbb {")
1049 with q.group():
1050 with q.indent(2):
1051 q.breakable()
1052 q.text("ethertype = ");
1053 q.text("%#x" % self.ethertype)
1054 q.breakable()
1055 q.text('}')
1056
Rich Lane7dcdf022013-12-11 14:45:27 -08001057action.subtypes[26] = push_pbb
1058
1059class push_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001060 type = 17
Rich Lanec2ee4b82013-04-24 17:12:38 -07001061
1062 def __init__(self, ethertype=None):
1063 if ethertype != None:
1064 self.ethertype = ethertype
1065 else:
1066 self.ethertype = 0
1067 return
1068
1069 def pack(self):
1070 packed = []
1071 packed.append(struct.pack("!H", self.type))
1072 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1073 packed.append(struct.pack("!H", self.ethertype))
1074 packed.append('\x00' * 2)
1075 length = sum([len(x) for x in packed])
1076 packed[1] = struct.pack("!H", length)
1077 return ''.join(packed)
1078
1079 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001080 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001081 obj = push_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -07001082 _type = reader.read("!H")[0]
1083 assert(_type == 17)
1084 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001085 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001086 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001087 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001088 reader.skip(2)
1089 return obj
1090
1091 def __eq__(self, other):
1092 if type(self) != type(other): return False
1093 if self.ethertype != other.ethertype: return False
1094 return True
1095
Rich Lanec2ee4b82013-04-24 17:12:38 -07001096 def pretty_print(self, q):
1097 q.text("push_vlan {")
1098 with q.group():
1099 with q.indent(2):
1100 q.breakable()
1101 q.text("ethertype = ");
1102 q.text("%#x" % self.ethertype)
1103 q.breakable()
1104 q.text('}')
1105
Rich Lane7dcdf022013-12-11 14:45:27 -08001106action.subtypes[17] = push_vlan
1107
1108class set_field(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001109 type = 25
Rich Lanec2ee4b82013-04-24 17:12:38 -07001110
1111 def __init__(self, field=None):
1112 if field != None:
1113 self.field = field
1114 else:
Rich Laned53156a2013-08-05 17:17:33 -07001115 self.field = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07001116 return
1117
1118 def pack(self):
1119 packed = []
1120 packed.append(struct.pack("!H", self.type))
1121 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Rich Laned53156a2013-08-05 17:17:33 -07001122 packed.append(self.field.pack())
Rich Lanec2ee4b82013-04-24 17:12:38 -07001123 length = sum([len(x) for x in packed])
Rich Laned53156a2013-08-05 17:17:33 -07001124 packed.append(loxi.generic_util.pad_to(8, length))
1125 length += len(packed[-1])
Rich Lanec2ee4b82013-04-24 17:12:38 -07001126 packed[1] = struct.pack("!H", length)
1127 return ''.join(packed)
1128
1129 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001130 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001131 obj = set_field()
Dan Talaycof6202252013-07-02 01:00:29 -07001132 _type = reader.read("!H")[0]
1133 assert(_type == 25)
1134 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001135 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001136 reader = orig_reader.slice(_len, 4)
Rich Lanee2567702015-01-26 15:04:35 -08001137 obj.field = ofp.oxm.oxm.unpack(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001138 return obj
1139
1140 def __eq__(self, other):
1141 if type(self) != type(other): return False
1142 if self.field != other.field: return False
1143 return True
1144
Rich Lanec2ee4b82013-04-24 17:12:38 -07001145 def pretty_print(self, q):
1146 q.text("set_field {")
1147 with q.group():
1148 with q.indent(2):
1149 q.breakable()
1150 q.text("field = ");
1151 q.pp(self.field)
1152 q.breakable()
1153 q.text('}')
1154
Rich Lane7dcdf022013-12-11 14:45:27 -08001155action.subtypes[25] = set_field
1156
1157class set_mpls_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001158 type = 15
Rich Lanec2ee4b82013-04-24 17:12:38 -07001159
1160 def __init__(self, mpls_ttl=None):
1161 if mpls_ttl != None:
1162 self.mpls_ttl = mpls_ttl
1163 else:
1164 self.mpls_ttl = 0
1165 return
1166
1167 def pack(self):
1168 packed = []
1169 packed.append(struct.pack("!H", self.type))
1170 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1171 packed.append(struct.pack("!B", self.mpls_ttl))
1172 packed.append('\x00' * 3)
1173 length = sum([len(x) for x in packed])
1174 packed[1] = struct.pack("!H", length)
1175 return ''.join(packed)
1176
1177 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001178 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001179 obj = set_mpls_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -07001180 _type = reader.read("!H")[0]
1181 assert(_type == 15)
1182 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001183 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001184 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001185 obj.mpls_ttl = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001186 reader.skip(3)
1187 return obj
1188
1189 def __eq__(self, other):
1190 if type(self) != type(other): return False
1191 if self.mpls_ttl != other.mpls_ttl: return False
1192 return True
1193
Rich Lanec2ee4b82013-04-24 17:12:38 -07001194 def pretty_print(self, q):
1195 q.text("set_mpls_ttl {")
1196 with q.group():
1197 with q.indent(2):
1198 q.breakable()
1199 q.text("mpls_ttl = ");
1200 q.text("%#x" % self.mpls_ttl)
1201 q.breakable()
1202 q.text('}')
1203
Rich Lane7dcdf022013-12-11 14:45:27 -08001204action.subtypes[15] = set_mpls_ttl
1205
1206class set_nw_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001207 type = 23
Rich Lanec2ee4b82013-04-24 17:12:38 -07001208
1209 def __init__(self, nw_ttl=None):
1210 if nw_ttl != None:
1211 self.nw_ttl = nw_ttl
1212 else:
1213 self.nw_ttl = 0
1214 return
1215
1216 def pack(self):
1217 packed = []
1218 packed.append(struct.pack("!H", self.type))
1219 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1220 packed.append(struct.pack("!B", self.nw_ttl))
1221 packed.append('\x00' * 3)
1222 length = sum([len(x) for x in packed])
1223 packed[1] = struct.pack("!H", length)
1224 return ''.join(packed)
1225
1226 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001227 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001228 obj = set_nw_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -07001229 _type = reader.read("!H")[0]
1230 assert(_type == 23)
1231 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001232 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001233 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001234 obj.nw_ttl = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001235 reader.skip(3)
1236 return obj
1237
1238 def __eq__(self, other):
1239 if type(self) != type(other): return False
1240 if self.nw_ttl != other.nw_ttl: return False
1241 return True
1242
Rich Lanec2ee4b82013-04-24 17:12:38 -07001243 def pretty_print(self, q):
1244 q.text("set_nw_ttl {")
1245 with q.group():
1246 with q.indent(2):
1247 q.breakable()
1248 q.text("nw_ttl = ");
1249 q.text("%#x" % self.nw_ttl)
1250 q.breakable()
1251 q.text('}')
1252
Rich Lane7dcdf022013-12-11 14:45:27 -08001253action.subtypes[23] = set_nw_ttl
1254
1255class set_queue(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001256 type = 21
Rich Lanec2ee4b82013-04-24 17:12:38 -07001257
1258 def __init__(self, queue_id=None):
1259 if queue_id != None:
1260 self.queue_id = queue_id
1261 else:
1262 self.queue_id = 0
1263 return
1264
1265 def pack(self):
1266 packed = []
1267 packed.append(struct.pack("!H", self.type))
1268 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1269 packed.append(struct.pack("!L", self.queue_id))
1270 length = sum([len(x) for x in packed])
1271 packed[1] = struct.pack("!H", length)
1272 return ''.join(packed)
1273
1274 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001275 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001276 obj = set_queue()
Dan Talaycof6202252013-07-02 01:00:29 -07001277 _type = reader.read("!H")[0]
1278 assert(_type == 21)
1279 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001280 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001281 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001282 obj.queue_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001283 return obj
1284
1285 def __eq__(self, other):
1286 if type(self) != type(other): return False
1287 if self.queue_id != other.queue_id: return False
1288 return True
1289
Rich Lanec2ee4b82013-04-24 17:12:38 -07001290 def pretty_print(self, q):
1291 q.text("set_queue {")
1292 with q.group():
1293 with q.indent(2):
1294 q.breakable()
1295 q.text("queue_id = ");
1296 q.text("%#x" % self.queue_id)
1297 q.breakable()
1298 q.text('}')
1299
Rich Lane7dcdf022013-12-11 14:45:27 -08001300action.subtypes[21] = set_queue
Rich Lanec2ee4b82013-04-24 17:12:38 -07001301
macauley_cheng8e0b3ee2015-08-31 15:18:57 +08001302OFDPA_EXPERIMETER =0x00001018
Rich Lanec2ee4b82013-04-24 17:12:38 -07001303
macauley_cheng8e0b3ee2015-08-31 15:18:57 +08001304class ofdpa(experimenter):
1305 subtypes = {}
1306
1307 type = 65535
1308 experimenter = OFDPA_EXPERIMETER
1309
1310 def __init__(self, subtype=None):
1311 if subtype != None:
1312 self.subtype = subtype
1313 else:
1314 self.subtype = 0
1315 return
1316
1317 def pack(self):
1318 packed = []
1319 packed.append(struct.pack("!H", self.type))
1320 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1321 packed.append(struct.pack("!L", self.experimenter))
1322 packed.append(struct.pack("!H", self.subtype))
1323 packed.append('\x00' * 6)
1324 length = sum([len(x) for x in packed])
1325 packed[1] = struct.pack("!H", length)
1326 return ''.join(packed)
1327
1328 @staticmethod
1329 def unpack(reader):
1330 #8 is offset, ref OFReader
1331 subtype, = reader.peek('!H', 8)
1332 subclass = ofdpa.subtypes.get(subtype)
1333 if subclass:
1334 return subclass.unpack(reader)
1335
1336 obj = ofdpa()
1337 _type = reader.read("!H")[0]
1338 assert(_type == 65535)
1339 _len = reader.read("!H")[0]
1340 orig_reader = reader
1341 reader = orig_reader.slice(_len, 4)
1342 _experimenter = reader.read("!L")[0]
1343 assert(_experimenter == OFDPA_EXPERIMETER)
1344 obj.subtype = reader.read("!H")[0]
1345 reader.skip(6)
1346 return obj
1347
1348 def __eq__(self, other):
1349 if type(self) != type(other): return False
1350 if self.subtype != other.subtype: return False
1351 return True
1352
1353 def pretty_print(self, q):
1354 q.text("ofdpa {")
1355 with q.group():
1356 with q.indent(2):
1357 q.breakable()
1358 q.breakable()
1359 q.text('}')
1360
1361experimenter.subtypes[OFDPA_EXPERIMETER] = ofdpa
1362
1363OFDPA_ACT_PUSH_L2_HEADER=1
1364OFDPA_ACT_POP_L2_HEADER=2
1365OFDPA_ACT_PUSH_CW=3
1366OFDPA_ACT_POP_CW=4
1367OFDPA_ACT_COPY_TC_IN=5
1368OFDPA_ACT_COPY_TC_OUT=6
1369OFDPA_ACT_SET_TC_FROM_TABLE=7
1370OFDPA_ACT_SET_PCP_DFI_FROM_TABLE=9
1371OFDPA_ACT_OAM_LM_RX_COUNT=10
1372OFDPA_ACT_OAM_LM_TX_COUNT=11
1373OFDPA_ACT_OAM_SET_COUNTER_FIELDS=12
1374OFDPA_ACT_DEC_TTL_MTU=13
1375OFDPA_ACT_CHECK_DROP_STATUS=14
1376OFDPA_ACT_SET_QOS_FROM_TABLE=15
1377
1378
1379class ofdpa_push_l2_header(ofdpa):
1380 type = 65535
1381 experimenter = OFDPA_EXPERIMETER
1382 subtype = OFDPA_ACT_PUSH_L2_HEADER
1383
1384 def __init__(self):
1385 return
1386
1387 def pack(self):
1388 packed = []
1389 packed.append(struct.pack("!H", self.type))
1390 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1391 packed.append(struct.pack("!L", self.experimenter))
1392 packed.append(struct.pack("!H", self.subtype))
1393 packed.append('\x00' * 6)
1394 length = sum([len(x) for x in packed])
1395 packed[1] = struct.pack("!H", length)
1396 return ''.join(packed)
1397
1398 @staticmethod
1399 def unpack(reader):
1400 obj = ofdpa_push_l2_header()
1401 _type = reader.read("!H")[0]
1402 assert(_type == 65535)
1403 _len = reader.read("!H")[0]
1404 orig_reader = reader
1405 reader = orig_reader.slice(_len, 4)
1406 _experimenter = reader.read("!L")[0]
1407 assert(_experimenter == OFDPA_EXPERIMETER)
1408 _subtype = reader.read("!H")[0]
1409 assert(_subtype == OFDPA_ACT_PUSH_L2_HEADER)
1410 reader.skip(6)
1411 return obj
1412
1413 def __eq__(self, other):
1414 if type(self) != type(other): return False
1415 return True
1416
1417 def pretty_print(self, q):
1418 q.text("ofdpa_push_l2_header {")
1419 with q.group():
1420 with q.indent(2):
1421 q.breakable()
1422 q.text("ofdpa_push_l2_header");
1423 q.breakable()
1424 q.text('}')
1425
1426ofdpa.subtypes[OFDPA_ACT_PUSH_L2_HEADER] = ofdpa_push_l2_header
1427
1428class ofdpa_pop_l2_header(ofdpa):
1429 type = 65535
1430 experimenter = OFDPA_EXPERIMETER
1431 subtype = OFDPA_ACT_POP_L2_HEADER
1432
1433 def __init__(self):
1434 return
1435
1436 def pack(self):
1437 packed = []
1438 packed.append(struct.pack("!H", self.type))
1439 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1440 packed.append(struct.pack("!L", self.experimenter))
1441 packed.append(struct.pack("!H", self.subtype))
1442 packed.append('\x00' * 6)
1443 length = sum([len(x) for x in packed])
1444 packed[1] = struct.pack("!H", length)
1445 return ''.join(packed)
1446
1447 @staticmethod
1448 def unpack(reader):
1449 obj = ofdpa_pop_l2_header()
1450 _type = reader.read("!H")[0]
1451 assert(_type == 65535)
1452 _len = reader.read("!H")[0]
1453 orig_reader = reader
1454 reader = orig_reader.slice(_len, 4)
1455 _experimenter = reader.read("!L")[0]
1456 assert(_experimenter == OFDPA_EXPERIMETER)
1457 _subtype = reader.read("!H")[0]
1458 assert(_subtype == OFDPA_ACT_POP_L2_HEADER)
1459 return obj
1460
1461 def __eq__(self, other):
1462 if type(self) != type(other): return False
1463 return True
1464
1465 def pretty_print(self, q):
1466 q.text("ofdpa_pop_l2_header {")
1467 with q.group():
1468 with q.indent(2):
1469 q.breakable()
1470 q.text("ofdpa_pop_l2_header");
1471 q.breakable()
1472 q.text('}')
1473
1474ofdpa.subtypes[OFDPA_ACT_POP_L2_HEADER] = ofdpa_pop_l2_header
1475
1476class ofdpa_push_cw(ofdpa):
1477 type = 65535
1478 experimenter = OFDPA_EXPERIMETER
1479 subtype = OFDPA_ACT_PUSH_CW
1480
1481 def __init__(self):
1482 return
1483
1484 def pack(self):
1485 packed = []
1486 packed.append(struct.pack("!H", self.type))
1487 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1488 packed.append(struct.pack("!L", self.experimenter))
1489 packed.append(struct.pack("!H", self.subtype))
1490 packed.append('\x00' * 6)
1491 length = sum([len(x) for x in packed])
1492 packed[1] = struct.pack("!H", length)
1493 return ''.join(packed)
1494
1495 @staticmethod
1496 def unpack(reader):
1497 obj = ofdpa_push_cw()
1498 _type = reader.read("!H")[0]
1499 assert(_type == 65535)
1500 _len = reader.read("!H")[0]
1501 orig_reader = reader
1502 reader = orig_reader.slice(_len, 4)
1503 _experimenter = reader.read("!L")[0]
1504 assert(_experimenter == OFDPA_EXPERIMETER)
1505 _subtype = reader.read("!H")[0]
1506 assert(_subtype == OFDPA_ACT_PUSH_CW)
1507 return obj
1508
1509 def __eq__(self, other):
1510 if type(self) != type(other): return False
1511 return True
1512
1513 def pretty_print(self, q):
1514 q.text("ofdpa_push_cw {")
1515 with q.group():
1516 with q.indent(2):
1517 q.breakable()
1518 q.text("ofdpa_push_cw");
1519 q.breakable()
1520 q.text('}')
1521
1522ofdpa.subtypes[OFDPA_ACT_PUSH_CW] = ofdpa_push_cw
1523
1524class ofdpa_pop_cw(ofdpa):
1525 type = 65535
1526 experimenter = OFDPA_EXPERIMETER
1527 subtype = OFDPA_ACT_POP_CW
1528
1529 def __init__(self):
1530 return
1531
1532 def pack(self):
1533 packed = []
1534 packed.append(struct.pack("!H", self.type))
1535 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1536 packed.append(struct.pack("!L", self.experimenter))
1537 packed.append(struct.pack("!H", self.subtype))
1538 packed.append('\x00' * 6)
1539 length = sum([len(x) for x in packed])
1540 packed[1] = struct.pack("!H", length)
1541 return ''.join(packed)
1542
1543 @staticmethod
1544 def unpack(reader):
1545 obj = ofdpa_pop_cw()
1546 _type = reader.read("!H")[0]
1547 assert(_type == 65535)
1548 _len = reader.read("!H")[0]
1549 orig_reader = reader
1550 reader = orig_reader.slice(_len, 4)
1551 _experimenter = reader.read("!L")[0]
1552 assert(_experimenter == OFDPA_EXPERIMETER)
1553 _subtype = reader.read("!H")[0]
1554 assert(_subtype == OFDPA_ACT_POP_CW)
1555 return obj
1556
1557 def __eq__(self, other):
1558 if type(self) != type(other): return False
1559 return True
1560
1561 def pretty_print(self, q):
1562 q.text("ofdpa_pop_cw {")
1563 with q.group():
1564 with q.indent(2):
1565 q.breakable()
1566 q.text("ofdpa_pop_cw");
1567 q.breakable()
1568 q.text('}')
1569
1570ofdpa.subtypes[OFDPA_ACT_POP_CW] = ofdpa_pop_cw
1571
1572class ofdpa_copy_tc_in(ofdpa):
1573 type = 65535
1574 experimenter = OFDPA_EXPERIMETER
1575 subtype = OFDPA_ACT_COPY_TC_IN
1576
1577 def __init__(self):
1578 return
1579
1580 def pack(self):
1581 packed = []
1582 packed.append(struct.pack("!H", self.type))
1583 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1584 packed.append(struct.pack("!L", self.experimenter))
1585 packed.append(struct.pack("!H", self.subtype))
1586 packed.append('\x00' * 6)
1587 length = sum([len(x) for x in packed])
1588 packed[1] = struct.pack("!H", length)
1589 return ''.join(packed)
1590
1591 @staticmethod
1592 def unpack(reader):
1593 obj = ofdpa_copy_tc_in()
1594 _type = reader.read("!H")[0]
1595 assert(_type == 65535)
1596 _len = reader.read("!H")[0]
1597 orig_reader = reader
1598 reader = orig_reader.slice(_len, 4)
1599 _experimenter = reader.read("!L")[0]
1600 assert(_experimenter == OFDPA_EXPERIMETER)
1601 _subtype = reader.read("!H")[0]
1602 assert(_subtype == OFDPA_ACT_COPY_TC_IN)
1603 return obj
1604
1605 def __eq__(self, other):
1606 if type(self) != type(other): return False
1607 return True
1608
1609 def pretty_print(self, q):
1610 q.text("ofdpa_copy_tc_in {")
1611 with q.group():
1612 with q.indent(2):
1613 q.breakable()
1614 q.text("ofdpa_copy_tc_in");
1615 q.breakable()
1616 q.text('}')
1617
1618ofdpa.subtypes[OFDPA_ACT_COPY_TC_IN] = ofdpa_copy_tc_in
1619
1620class ofdpa_copy_tc_out(ofdpa):
1621 type = 65535
1622 experimenter = OFDPA_EXPERIMETER
1623 subtype = OFDPA_ACT_COPY_TC_OUT
1624
1625 def __init__(self):
1626 return
1627
1628 def pack(self):
1629 packed = []
1630 packed.append(struct.pack("!H", self.type))
1631 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1632 packed.append(struct.pack("!L", self.experimenter))
1633 packed.append(struct.pack("!H", self.subtype))
1634 packed.append('\x00' * 6)
1635 length = sum([len(x) for x in packed])
1636 packed[1] = struct.pack("!H", length)
1637 return ''.join(packed)
1638
1639 @staticmethod
1640 def unpack(reader):
1641 obj = ofdpa_copy_tc_out()
1642 _type = reader.read("!H")[0]
1643 assert(_type == 65535)
1644 _len = reader.read("!H")[0]
1645 orig_reader = reader
1646 reader = orig_reader.slice(_len, 4)
1647 _experimenter = reader.read("!L")[0]
1648 assert(_experimenter == OFDPA_EXPERIMETER)
1649 _subtype = reader.read("!H")[0]
1650 assert(_subtype == OFDPA_ACT_COPY_TC_OUT)
1651 return obj
1652
1653 def __eq__(self, other):
1654 if type(self) != type(other): return False
1655 return True
1656
1657 def pretty_print(self, q):
1658 q.text("ofdpa_copy_tc_out {")
1659 with q.group():
1660 with q.indent(2):
1661 q.breakable()
1662 q.text("ofdpa_copy_tc_out");
1663 q.breakable()
1664 q.text('}')
1665
1666ofdpa.subtypes[OFDPA_ACT_COPY_TC_OUT] = ofdpa_copy_tc_out
1667
1668class ofdpa_dec_ttl_mtu(ofdpa):
1669 type = 65535
1670 experimenter = OFDPA_EXPERIMETER
1671 subtype = OFDPA_ACT_DEC_TTL_MTU
1672
1673 def __init__(self):
1674 return
1675
1676 def pack(self):
1677 packed = []
1678 packed.append(struct.pack("!H", self.type))
1679 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1680 packed.append(struct.pack("!L", self.experimenter))
1681 packed.append(struct.pack("!H", self.subtype))
1682 packed.append('\x00' * 6)
1683 length = sum([len(x) for x in packed])
1684 packed[1] = struct.pack("!H", length)
1685 return ''.join(packed)
1686
1687 @staticmethod
1688 def unpack(reader):
1689 obj = ofdpa_dec_ttl_mtu()
1690 _type = reader.read("!H")[0]
1691 assert(_type == 65535)
1692 _len = reader.read("!H")[0]
1693 orig_reader = reader
1694 reader = orig_reader.slice(_len, 4)
1695 _experimenter = reader.read("!L")[0]
1696 assert(_experimenter == OFDPA_EXPERIMETER)
1697 _subtype = reader.read("!H")[0]
1698 assert(_subtype == OFDPA_ACT_DEC_TTL_MTU)
1699 return obj
1700
1701 def __eq__(self, other):
1702 if type(self) != type(other): return False
1703 return True
1704
1705 def pretty_print(self, q):
1706 q.text("ofdpa_dec_ttl_mtu {")
1707 with q.group():
1708 with q.indent(2):
1709 q.breakable()
1710 q.text("ofdpa_dec_ttl_mtu");
1711 q.breakable()
1712 q.text('}')
1713
1714ofdpa.subtypes[OFDPA_ACT_DEC_TTL_MTU] = ofdpa_dec_ttl_mtu
1715
1716class ofdpa_set_tc_from_table(ofdpa):
1717 type = 65535
1718 experimenter = OFDPA_EXPERIMETER
1719 subtype = OFDPA_ACT_SET_TC_FROM_TABLE
1720
1721 def __init__(self, qos_index=None):
1722 if qos_index != None:
1723 self.qos_index = qos_index
1724 else:
1725 self.qos_index = 0
1726 return
1727
1728 def pack(self):
1729 packed = []
1730 packed.append(struct.pack("!H", self.type))
1731 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1732 packed.append(struct.pack("!L", self.experimenter))
1733 packed.append(struct.pack("!H", self.subtype))
1734 packed.append(struct.pack("!B", self.qos_index))
1735 packed.append('\x00' * 5)
1736 length = sum([len(x) for x in packed])
1737 packed[1] = struct.pack("!H", length)
1738 return ''.join(packed)
1739
1740 @staticmethod
1741 def unpack(reader):
1742 obj = ofdpa_set_tc_from_table()
1743 _type = reader.read("!H")[0]
1744 assert(_type == 65535)
1745 _len = reader.read("!H")[0]
1746 orig_reader = reader
1747 reader = orig_reader.slice(_len, 4)
1748 _experimenter = reader.read("!L")[0]
1749 assert(_experimenter == OFDPA_EXPERIMETER)
1750 _subtype = reader.read("!H")[0]
1751 assert(_subtype == OFDPA_ACT_SET_TC_FROM_TABLE)
1752 obj.qos_index = reader.read("!B")[0]
1753 return obj
1754
1755 def __eq__(self, other):
1756 if type(self) != type(other): return False
1757 if self.qos_index != other.qos_index: return False
1758 return True
1759
1760 def pretty_print(self, q):
1761 q.text("ofdpa_set_tc_from_table {")
1762 with q.group():
1763 with q.indent(2):
1764 q.breakable()
1765 q.text("ofdpa_set_tc_from_table");
1766 q.pp(self.qos_index)
1767 q.breakable()
1768 q.text('}')
1769
1770ofdpa.subtypes[OFDPA_ACT_SET_TC_FROM_TABLE] = ofdpa_set_tc_from_table
1771
1772
1773class ofdpa_set_pcp_dfi_from_table(ofdpa):
1774 type = 65535
1775 experimenter = OFDPA_EXPERIMETER
1776 subtype = OFDPA_ACT_SET_PCP_DFI_FROM_TABLE
1777
1778 def __init__(self, qos_index=None):
1779 if qos_index != None:
1780 self.qos_index = qos_index
1781 else:
1782 self.qos_index = 0
1783 return
1784
1785 def pack(self):
1786 packed = []
1787 packed.append(struct.pack("!H", self.type))
1788 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1789 packed.append(struct.pack("!L", self.experimenter))
1790 packed.append(struct.pack("!H", self.subtype))
1791 packed.append(struct.pack("!B", self.qos_index))
1792 packed.append('\x00' * 5)
1793 length = sum([len(x) for x in packed])
1794 packed[1] = struct.pack("!H", length)
1795 return ''.join(packed)
1796
1797 @staticmethod
1798 def unpack(reader):
1799 obj = ofdpa_set_pcp_dfi_from_table()
1800 _type = reader.read("!H")[0]
1801 assert(_type == 65535)
1802 _len = reader.read("!H")[0]
1803 orig_reader = reader
1804 reader = orig_reader.slice(_len, 4)
1805 _experimenter = reader.read("!L")[0]
1806 assert(_experimenter == OFDPA_EXPERIMETER)
1807 _subtype = reader.read("!H")[0]
1808 assert(_subtype == OFDPA_ACT_SET_PCP_DFI_FROM_TABLE)
1809 obj.qos_index = reader.read("!B")[0]
1810 return obj
1811
1812 def __eq__(self, other):
1813 if type(self) != type(other): return False
1814 if self.qos_index != other.qos_index: return False
1815 return True
1816
1817 def pretty_print(self, q):
1818 q.text("ofdpa_set_pcp_dfi_from_table {")
1819 with q.group():
1820 with q.indent(2):
1821 q.breakable()
1822 q.text("ofdpa_set_pcp_dfi_from_table");
1823 q.pp(self.qos_index)
1824 q.breakable()
1825 q.text('}')
1826
1827ofdpa.subtypes[OFDPA_ACT_SET_PCP_DFI_FROM_TABLE] = ofdpa_set_pcp_dfi_from_table
1828
1829
1830class ofdpa_check_drop_status(ofdpa):
1831 type = 65535
1832 experimenter = OFDPA_EXPERIMETER
1833 subtype = OFDPA_ACT_CHECK_DROP_STATUS
1834
1835 def __init__(self, index, status_type):
1836 self.index = index
1837 self.status_type = status_type
1838 return
1839
1840 def pack(self):
1841 packed = []
1842 packed.append(struct.pack("!H", self.type))
1843 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1844 packed.append(struct.pack("!L", self.experimenter))
1845 packed.append(struct.pack("!H", self.subtype))
1846 packed.append(struct.pack("!L", self.index))
1847 packed.append(struct.pack("!B", self.status_type))
1848 packed.append('\x00' * 1)
1849 length = sum([len(x) for x in packed])
1850 packed[1] = struct.pack("!H", length)
1851 return ''.join(packed)
1852
1853 @staticmethod
1854 def unpack(reader):
1855 obj = ofdpa_check_drop_status()
1856 _type = reader.read("!H")[0]
1857 assert(_type == 65535)
1858 _len = reader.read("!H")[0]
1859 orig_reader = reader
1860 reader = orig_reader.slice(_len, 4)
1861 _experimenter = reader.read("!L")[0]
1862 assert(_experimenter == OFDPA_EXPERIMETER)
1863 _subtype = reader.read("!H")[0]
1864 assert(_subtype == OFDPA_ACT_CHECK_DROP_STATUS)
1865 obj.status_type = reader.read("!L")[0]
1866 obj.index = reader.read("!B")[0]
1867 return obj
1868
1869 def __eq__(self, other):
1870 if type(self) != type(other): return False
1871 if self.index != other.index: return False
1872 if self.status_type != other.status_type: return False
1873 return True
1874
1875 def pretty_print(self, q):
1876 q.text("ofdpa_check_drop_status {")
1877 with q.group():
1878 with q.indent(2):
1879 q.breakable()
1880 q.text("ofdpa_check_drop_status = ");
1881 q.pp(self.index)
1882 q.pp(self.status_type)
1883 q.breakable()
1884 q.text('}')
1885
1886ofdpa.subtypes[OFDPA_ACT_CHECK_DROP_STATUS] = ofdpa_check_drop_status
1887
1888
1889class ofdpa_set_qos_from_table(ofdpa):
1890 type = 65535
1891 experimenter = OFDPA_EXPERIMETER
1892 subtype = OFDPA_ACT_SET_QOS_FROM_TABLE
1893
1894 def __init__(self, qos_index, mpls_tc):
1895 self.qos_index = qos_index
1896 self.mpls_tc = mpls_tc
1897 return
1898
1899 def pack(self):
1900 packed = []
1901 packed.append(struct.pack("!H", self.type))
1902 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1903 packed.append(struct.pack("!L", self.experimenter))
1904 packed.append(struct.pack("!H", self.subtype))
1905 packed.append(struct.pack("!B", self.qos_index))
1906 packed.append(struct.pack("!B", self.mpls_tc))
1907 packed.append('\x00' * 4)
1908 length = sum([len(x) for x in packed])
1909 packed[1] = struct.pack("!H", length)
1910 return ''.join(packed)
1911
1912 @staticmethod
1913 def unpack(reader):
1914 obj = ofdpa_check_drop_status()
1915 _type = reader.read("!H")[0]
1916 assert(_type == 65535)
1917 _len = reader.read("!H")[0]
1918 orig_reader = reader
1919 reader = orig_reader.slice(_len, 4)
1920 _experimenter = reader.read("!L")[0]
1921 assert(_experimenter == OFDPA_EXPERIMETER)
1922 _subtype = reader.read("!H")[0]
1923 assert(_subtype == OFDPA_ACT_SET_QOS_FROM_TABLE)
1924 obj.qos_index = reader.read("!B")[0]
1925 obj.mpls_tc = reader.read("!B")[0]
1926 return obj
1927
1928 def __eq__(self, other):
1929 if type(self) != type(other): return False
1930 if self.qos_index != other.qos_index: return False
1931 if self.mpls_tc != other.mpls_tc: return False
1932 return True
1933
1934 def pretty_print(self, q):
1935 q.text("ofdpa_set_qos_from_table {")
1936 with q.group():
1937 with q.indent(2):
1938 q.breakable()
1939 q.text("ofdpa_set_qos_from_table = ");
1940 q.pp(self.qos_index)
1941 q.pp(self.mpls_tc)
1942 q.breakable()
1943 q.text('}')
1944
1945ofdpa.subtypes[OFDPA_ACT_SET_QOS_FROM_TABLE] = ofdpa_set_qos_from_table
1946
1947
1948class ofdpa_oam_lm_tx_count(ofdpa):
1949 type = 65535
1950 experimenter = OFDPA_EXPERIMETER
1951 subtype = OFDPA_ACT_OAM_LM_TX_COUNT
1952
1953 def __init__(self, lmep_id, traffic_class):
1954 self.lmep_id = lmep_id
1955 self.traffic_class = traffic_class
1956 return
1957
1958 def pack(self):
1959 packed = []
1960 packed.append(struct.pack("!H", self.type))
1961 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1962 packed.append(struct.pack("!L", self.experimenter))
1963 packed.append(struct.pack("!H", self.subtype))
1964 packed.append(struct.pack("!L", self.lmep_id))
1965 packed.append(struct.pack("!B", self.traffic_class))
1966 packed.append('\x00' * 1)
1967 length = sum([len(x) for x in packed])
1968 packed[1] = struct.pack("!H", length)
1969 return ''.join(packed)
1970
1971 @staticmethod
1972 def unpack(reader):
1973 obj = ofdpa_check_drop_status()
1974 _type = reader.read("!H")[0]
1975 assert(_type == 65535)
1976 _len = reader.read("!H")[0]
1977 orig_reader = reader
1978 reader = orig_reader.slice(_len, 4)
1979 _experimenter = reader.read("!L")[0]
1980 assert(_experimenter == OFDPA_EXPERIMETER)
1981 _subtype = reader.read("!H")[0]
1982 assert(_subtype == OFDPA_ACT_OAM_LM_TX_COUNT)
1983 obj.lmep_id = reader.read("!L")[0]
1984 obj.traffic_class = reader.read("!B")[0]
1985 return obj
1986
1987 def __eq__(self, other):
1988 if type(self) != type(other): return False
1989 if self.lmep_id != other.lmep_id: return False
1990 if self.traffic_class != other.traffic_class: return False
1991 return True
1992
1993 def pretty_print(self, q):
1994 q.text("ofdpa_oam_lm_tx_count {")
1995 with q.group():
1996 with q.indent(2):
1997 q.breakable()
1998 q.text("ofdpa_oam_lm_tx_count = ");
1999 q.pp(self.lmep_id)
2000 q.pp(self.traffic_class)
2001 q.breakable()
2002 q.text('}')
2003
2004ofdpa.subtypes[OFDPA_ACT_OAM_LM_TX_COUNT] = ofdpa_oam_lm_tx_count
2005
2006class ofdpa_oam_lm_rx_count(ofdpa):
2007 type = 65535
2008 experimenter = OFDPA_EXPERIMETER
2009 subtype = OFDPA_ACT_OAM_LM_RX_COUNT
2010
2011 def __init__(self, lmep_id, traffic_class):
2012 self.lmep_id = lmep_id
2013 self.traffic_class = traffic_class
2014 return
2015
2016 def pack(self):
2017 packed = []
2018 packed.append(struct.pack("!H", self.type))
2019 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2020 packed.append(struct.pack("!L", self.experimenter))
2021 packed.append(struct.pack("!H", self.subtype))
2022 packed.append(struct.pack("!L", self.lmep_id))
2023 packed.append(struct.pack("!B", self.traffic_class))
2024 packed.append('\x00' * 1)
2025 length = sum([len(x) for x in packed])
2026 packed[1] = struct.pack("!H", length)
2027 return ''.join(packed)
2028
2029 @staticmethod
2030 def unpack(reader):
2031 obj = ofdpa_check_drop_status()
2032 _type = reader.read("!H")[0]
2033 assert(_type == 65535)
2034 _len = reader.read("!H")[0]
2035 orig_reader = reader
2036 reader = orig_reader.slice(_len, 4)
2037 _experimenter = reader.read("!L")[0]
2038 assert(_experimenter == OFDPA_EXPERIMETER)
2039 _subtype = reader.read("!H")[0]
2040 assert(_subtype == OFDPA_ACT_OAM_LM_RX_COUNT)
2041 obj.lmep_id = reader.read("!L")[0]
2042 obj.traffic_class = reader.read("!B")[0]
2043 return obj
2044
2045 def __eq__(self, other):
2046 if type(self) != type(other): return False
2047 if self.lmep_id != other.lmep_id: return False
2048 if self.traffic_class != other.traffic_class: return False
2049 return True
2050
2051 def pretty_print(self, q):
2052 q.text("ofdpa_oam_lm_rx_count {")
2053 with q.group():
2054 with q.indent(2):
2055 q.breakable()
2056 q.text("ofdpa_oam_lm_rx_count = ");
2057 q.pp(self.lmep_id)
2058 q.pp(self.traffic_class)
2059 q.breakable()
2060 q.text('}')
2061
2062ofdpa.subtypes[OFDPA_ACT_OAM_LM_RX_COUNT] = ofdpa_oam_lm_rx_count
2063
2064
2065class ofdpa_oam_set_counter_field(ofdpa):
2066 type = 65535
2067 experimenter = OFDPA_EXPERIMETER
2068 subtype = OFDPA_ACT_OAM_SET_COUNTER_FIELDS
2069
2070 def __init__(self, lmep_id, traffic_class):
2071 self.lmep_id = lmep_id
2072 self.traffic_class = traffic_class
2073 return
2074
2075 def pack(self):
2076 packed = []
2077 packed.append(struct.pack("!H", self.type))
2078 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
2079 packed.append(struct.pack("!L", self.experimenter))
2080 packed.append(struct.pack("!H", self.subtype))
2081 packed.append(struct.pack("!L", self.lmep_id))
2082 packed.append(struct.pack("!B", self.traffic_class))
2083 packed.append('\x00' * 1)
2084 length = sum([len(x) for x in packed])
2085 packed[1] = struct.pack("!H", length)
2086 return ''.join(packed)
2087
2088 @staticmethod
2089 def unpack(reader):
2090 obj = ofdpa_check_drop_status()
2091 _type = reader.read("!H")[0]
2092 assert(_type == 65535)
2093 _len = reader.read("!H")[0]
2094 orig_reader = reader
2095 reader = orig_reader.slice(_len, 4)
2096 _experimenter = reader.read("!L")[0]
2097 assert(_experimenter == OFDPA_EXPERIMETER)
2098 _subtype = reader.read("!H")[0]
2099 assert(_subtype == OFDPA_ACT_OAM_SET_COUNTER_FIELDS)
2100 obj.lmep_id = reader.read("!L")[0]
2101 obj.traffic_class = reader.read("!B")[0]
2102 return obj
2103
2104 def __eq__(self, other):
2105 if type(self) != type(other): return False
2106 if self.lmep_id != other.lmep_id: return False
2107 if self.traffic_class != other.traffic_class: return False
2108 return True
2109
2110 def pretty_print(self, q):
2111 q.text("ofdpa_oam_set_counter_field {")
2112 with q.group():
2113 with q.indent(2):
2114 q.breakable()
2115 q.text("ofdpa_oam_set_counter_field = ");
2116 q.pp(self.lmep_id)
2117 q.pp(self.traffic_class)
2118 q.breakable()
2119 q.text('}')
2120
Andreas Pantelopoulosf83e0212018-03-18 20:44:05 -07002121ofdpa.subtypes[OFDPA_ACT_OAM_SET_COUNTER_FIELDS] = ofdpa_oam_set_counter_field
Jonghwan Hyunff0dfd52018-03-20 15:04:35 -07002122
2123class copy_field(action):
2124 type = 65535
2125 experimenter = 0x4f4e4600 # ONF_EXPERIMENTER_ID
2126 exp_type = 3200 # ONFTFP_ET_WRITE_COPYFIELD
2127
2128 def __init__(self, n_bits=None, src_offset=None, dst_offset=None, oxm_ids=None):
2129 if n_bits != None:
2130 self.n_bits = n_bits
2131 else:
2132 self.n_bits = 0
2133 if src_offset != None:
2134 self.src_offset = src_offset
2135 else:
2136 self.src_offset = 0
2137 if dst_offset != None:
2138 self.dst_offset = dst_offset
2139 else:
2140 self.dst_offset = 0
2141 if oxm_ids != None:
2142 self.oxm_ids = oxm_ids
2143 else:
2144 self.oxm_ids = [ ]
2145 return
2146
2147 def pack( self ):
2148 packed = [ ]
2149 packed.append( struct.pack( "!H", self.type ) )
2150 packed.append( struct.pack( "!H", 0 ) ) # placeholder for len at index 1
2151 packed.append( struct.pack( "!L", self.experimenter ) )
2152 packed.append( struct.pack( "!H", self.exp_type ) )
2153 packed.append( '\x00' * 2 )
2154 packed.append( struct.pack( "!H", self.n_bits ) )
2155 packed.append( struct.pack( "!H", self.src_offset ) )
2156 packed.append( struct.pack( "!H", self.dst_offset ) )
2157 packed.append( '\x00' * 2 )
2158 packed.append( "".join(self.oxm_ids ) )
2159 length = sum( [ len( x ) for x in packed ] )
2160 packed[ 1 ] = struct.pack( "!H", length )
2161 return ''.join( packed )
2162
2163 @staticmethod
2164 def unpack( reader ):
2165 obj = copy_field()
2166 _type = reader.read( "!H" )[ 0 ]
2167 _len = reader.read( "!H" )[ 0 ]
2168 orig_reader = reader
2169 reader = orig_reader.slice( _len, 4 )
2170 obj.n_bits = reader.read( "!H" )[ 0 ]
2171 obj.src_offset = reader.read( "!H" )[ 0 ]
2172 obj.dst_offset = reader.read( "!H" )[ 0 ]
2173 reader.skip( 2 )
2174 obj.oxm_ids = loxi.generic_util.unpack_list( reader, ofp.oxm.oxm.unpack )
2175 return obj
2176
2177 def __eq__( self, other ):
2178 if type( self ) != type( other ): return False
2179 if self.n_bits != other.n_bits: return False
2180 if self.src_offset != other.src_offset: return False
2181 if self.dst_offset != other.dst_offset: return False
2182 if self.oxm_ids != other.oxm_ids: return False
2183 return True
2184
2185 def pretty_print( self, q ):
2186 q.text( "copy_field {" )
2187 with q.group():
2188 with q.indent( 2 ):
2189 q.breakable()
2190 q.text( "n_bits = " )
2191 q.text( "%#x" % self.n_bits )
2192 q.text( "," )
2193 q.breakable()
2194 q.text( "src_offset = " )
2195 q.text( "%#x" % self.src_offset )
2196 q.text( "," )
2197 q.breakable()
2198 q.text( "dst_offset = " )
2199 q.text( "%#x" % self.dst_offset )
2200 q.text( "," )
2201 q.breakable()
2202 q.text( "oxm_ids = " )
2203 q.pp( self.oxm_ids )
2204 q.breakable()
2205 q.text( '}' )