blob: 50650413b5fe71ab13e2b4e2a7c2f67e6abcffe9 [file] [log] [blame]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001# Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2# Copyright (c) 2011, 2012 Open Networking Foundation
3# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
Dan Talaycof6202252013-07-02 01:00:29 -07004# See the file LICENSE.pyloxi which should have been included in the source distribution
Rich Lanec2ee4b82013-04-24 17:12:38 -07005
Rich Lane7dcdf022013-12-11 14:45:27 -08006# Automatically generated by LOXI from template module.py
Rich Lanec2ee4b82013-04-24 17:12:38 -07007# Do not modify
8
9import struct
Rich Lane7dcdf022013-12-11 14:45:27 -080010import loxi
Rich Lanec2ee4b82013-04-24 17:12:38 -070011import util
12import loxi.generic_util
Rich Lanec2ee4b82013-04-24 17:12:38 -070013
Rich Lanee2567702015-01-26 15:04:35 -080014import sys
15ofp = sys.modules['loxi.of13']
16
Rich Lane7dcdf022013-12-11 14:45:27 -080017class action(loxi.OFObject):
18 subtypes = {}
Rich Lanec2ee4b82013-04-24 17:12:38 -070019
Rich Lane95f7fc92014-01-27 17:08:16 -080020
21 def __init__(self, type=None):
22 if type != None:
23 self.type = type
24 else:
25 self.type = 0
26 return
27
28 def pack(self):
29 packed = []
30 packed.append(struct.pack("!H", self.type))
31 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
32 packed.append('\x00' * 4)
33 length = sum([len(x) for x in packed])
34 packed[1] = struct.pack("!H", length)
35 return ''.join(packed)
36
Rich Lane7dcdf022013-12-11 14:45:27 -080037 @staticmethod
38 def unpack(reader):
39 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -080040 subclass = action.subtypes.get(subtype)
41 if subclass:
42 return subclass.unpack(reader)
43
44 obj = action()
45 obj.type = reader.read("!H")[0]
46 _len = reader.read("!H")[0]
47 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -080048 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -080049 reader.skip(4)
50 return obj
51
52 def __eq__(self, other):
53 if type(self) != type(other): return False
54 if self.type != other.type: return False
55 return True
56
57 def pretty_print(self, q):
58 q.text("action {")
59 with q.group():
60 with q.indent(2):
61 q.breakable()
62 q.breakable()
63 q.text('}')
Rich Lanec2ee4b82013-04-24 17:12:38 -070064
Rich Lane7dcdf022013-12-11 14:45:27 -080065
66class experimenter(action):
67 subtypes = {}
68
Rich Lane95f7fc92014-01-27 17:08:16 -080069 type = 65535
70
71 def __init__(self, experimenter=None, data=None):
72 if experimenter != None:
73 self.experimenter = experimenter
74 else:
75 self.experimenter = 0
76 if data != None:
77 self.data = data
78 else:
79 self.data = ''
80 return
81
82 def pack(self):
83 packed = []
84 packed.append(struct.pack("!H", self.type))
85 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
86 packed.append(struct.pack("!L", self.experimenter))
87 packed.append(self.data)
88 length = sum([len(x) for x in packed])
89 packed.append(loxi.generic_util.pad_to(8, length))
90 length += len(packed[-1])
91 packed[1] = struct.pack("!H", length)
92 return ''.join(packed)
93
Rich Lane7dcdf022013-12-11 14:45:27 -080094 @staticmethod
95 def unpack(reader):
96 subtype, = reader.peek('!L', 4)
Rich Lane95f7fc92014-01-27 17:08:16 -080097 subclass = experimenter.subtypes.get(subtype)
98 if subclass:
99 return subclass.unpack(reader)
100
101 obj = experimenter()
102 _type = reader.read("!H")[0]
103 assert(_type == 65535)
104 _len = reader.read("!H")[0]
105 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800106 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800107 obj.experimenter = reader.read("!L")[0]
108 obj.data = str(reader.read_all())
109 return obj
110
111 def __eq__(self, other):
112 if type(self) != type(other): return False
113 if self.experimenter != other.experimenter: return False
114 if self.data != other.data: return False
115 return True
116
117 def pretty_print(self, q):
118 q.text("experimenter {")
119 with q.group():
120 with q.indent(2):
121 q.breakable()
122 q.text("data = ");
123 q.pp(self.data)
124 q.breakable()
125 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800126
127action.subtypes[65535] = experimenter
128
129class bsn(experimenter):
130 subtypes = {}
131
Rich Lane95f7fc92014-01-27 17:08:16 -0800132 type = 65535
133 experimenter = 6035143
134
135 def __init__(self, subtype=None):
136 if subtype != None:
137 self.subtype = subtype
138 else:
139 self.subtype = 0
140 return
141
142 def pack(self):
143 packed = []
144 packed.append(struct.pack("!H", self.type))
145 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
146 packed.append(struct.pack("!L", self.experimenter))
147 packed.append(struct.pack("!L", self.subtype))
148 packed.append('\x00' * 4)
149 length = sum([len(x) for x in packed])
150 packed[1] = struct.pack("!H", length)
151 return ''.join(packed)
152
Rich Lane7dcdf022013-12-11 14:45:27 -0800153 @staticmethod
154 def unpack(reader):
155 subtype, = reader.peek('!L', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800156 subclass = bsn.subtypes.get(subtype)
157 if subclass:
158 return subclass.unpack(reader)
159
160 obj = bsn()
161 _type = reader.read("!H")[0]
162 assert(_type == 65535)
163 _len = reader.read("!H")[0]
164 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800165 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800166 _experimenter = reader.read("!L")[0]
167 assert(_experimenter == 6035143)
168 obj.subtype = reader.read("!L")[0]
169 reader.skip(4)
170 return obj
171
172 def __eq__(self, other):
173 if type(self) != type(other): return False
174 if self.subtype != other.subtype: return False
175 return True
176
177 def pretty_print(self, q):
178 q.text("bsn {")
179 with q.group():
180 with q.indent(2):
181 q.breakable()
182 q.breakable()
183 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800184
185experimenter.subtypes[6035143] = bsn
186
Rich Lane5587ab12014-06-30 11:19:09 -0700187class bsn_checksum(bsn):
188 type = 65535
189 experimenter = 6035143
190 subtype = 4
191
192 def __init__(self, checksum=None):
193 if checksum != None:
194 self.checksum = checksum
195 else:
196 self.checksum = 0
197 return
198
199 def pack(self):
200 packed = []
201 packed.append(struct.pack("!H", self.type))
202 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
203 packed.append(struct.pack("!L", self.experimenter))
204 packed.append(struct.pack("!L", self.subtype))
205 packed.append(util.pack_checksum_128(self.checksum))
206 length = sum([len(x) for x in packed])
207 packed[1] = struct.pack("!H", length)
208 return ''.join(packed)
209
210 @staticmethod
211 def unpack(reader):
212 obj = bsn_checksum()
213 _type = reader.read("!H")[0]
214 assert(_type == 65535)
215 _len = reader.read("!H")[0]
216 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800217 reader = orig_reader.slice(_len, 4)
Rich Lane5587ab12014-06-30 11:19:09 -0700218 _experimenter = reader.read("!L")[0]
219 assert(_experimenter == 6035143)
220 _subtype = reader.read("!L")[0]
221 assert(_subtype == 4)
222 obj.checksum = util.unpack_checksum_128(reader)
223 return obj
224
225 def __eq__(self, other):
226 if type(self) != type(other): return False
227 if self.checksum != other.checksum: return False
228 return True
229
230 def pretty_print(self, q):
231 q.text("bsn_checksum {")
232 with q.group():
233 with q.indent(2):
234 q.breakable()
235 q.text("checksum = ");
236 q.pp(self.checksum)
237 q.breakable()
238 q.text('}')
239
240bsn.subtypes[4] = bsn_checksum
241
Rich Lane2e079da2014-10-29 15:30:24 -0700242class bsn_gentable(bsn):
243 type = 65535
244 experimenter = 6035143
245 subtype = 5
246
247 def __init__(self, table_id=None, key=None):
248 if table_id != None:
249 self.table_id = table_id
250 else:
251 self.table_id = 0
252 if key != None:
253 self.key = key
254 else:
255 self.key = []
256 return
257
258 def pack(self):
259 packed = []
260 packed.append(struct.pack("!H", self.type))
261 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
262 packed.append(struct.pack("!L", self.experimenter))
263 packed.append(struct.pack("!L", self.subtype))
264 packed.append(struct.pack("!L", self.table_id))
265 packed.append(loxi.generic_util.pack_list(self.key))
266 length = sum([len(x) for x in packed])
267 packed[1] = struct.pack("!H", length)
268 return ''.join(packed)
269
270 @staticmethod
271 def unpack(reader):
272 obj = bsn_gentable()
273 _type = reader.read("!H")[0]
274 assert(_type == 65535)
275 _len = reader.read("!H")[0]
276 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800277 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -0700278 _experimenter = reader.read("!L")[0]
279 assert(_experimenter == 6035143)
280 _subtype = reader.read("!L")[0]
281 assert(_subtype == 5)
282 obj.table_id = reader.read("!L")[0]
Rich Lanee2567702015-01-26 15:04:35 -0800283 obj.key = loxi.generic_util.unpack_list(reader, ofp.bsn_tlv.bsn_tlv.unpack)
Rich Lane2e079da2014-10-29 15:30:24 -0700284 return obj
285
286 def __eq__(self, other):
287 if type(self) != type(other): return False
288 if self.table_id != other.table_id: return False
289 if self.key != other.key: return False
290 return True
291
292 def pretty_print(self, q):
293 q.text("bsn_gentable {")
294 with q.group():
295 with q.indent(2):
296 q.breakable()
297 q.text("table_id = ");
298 q.text("%#x" % self.table_id)
299 q.text(","); q.breakable()
300 q.text("key = ");
301 q.pp(self.key)
302 q.breakable()
303 q.text('}')
304
305bsn.subtypes[5] = bsn_gentable
306
Rich Lane7dcdf022013-12-11 14:45:27 -0800307class bsn_mirror(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700308 type = 65535
309 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -0700310 subtype = 1
311
312 def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None):
313 if dest_port != None:
314 self.dest_port = dest_port
315 else:
316 self.dest_port = 0
317 if vlan_tag != None:
318 self.vlan_tag = vlan_tag
319 else:
320 self.vlan_tag = 0
321 if copy_stage != None:
322 self.copy_stage = copy_stage
323 else:
324 self.copy_stage = 0
325 return
326
327 def pack(self):
328 packed = []
329 packed.append(struct.pack("!H", self.type))
330 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
331 packed.append(struct.pack("!L", self.experimenter))
332 packed.append(struct.pack("!L", self.subtype))
333 packed.append(struct.pack("!L", self.dest_port))
334 packed.append(struct.pack("!L", self.vlan_tag))
335 packed.append(struct.pack("!B", self.copy_stage))
336 packed.append('\x00' * 3)
337 length = sum([len(x) for x in packed])
338 packed[1] = struct.pack("!H", length)
339 return ''.join(packed)
340
341 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800342 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700343 obj = bsn_mirror()
Dan Talaycof6202252013-07-02 01:00:29 -0700344 _type = reader.read("!H")[0]
345 assert(_type == 65535)
346 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800347 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800348 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700349 _experimenter = reader.read("!L")[0]
350 assert(_experimenter == 6035143)
351 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700352 assert(_subtype == 1)
Dan Talaycof6202252013-07-02 01:00:29 -0700353 obj.dest_port = reader.read("!L")[0]
354 obj.vlan_tag = reader.read("!L")[0]
355 obj.copy_stage = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700356 reader.skip(3)
357 return obj
358
359 def __eq__(self, other):
360 if type(self) != type(other): return False
361 if self.dest_port != other.dest_port: return False
362 if self.vlan_tag != other.vlan_tag: return False
363 if self.copy_stage != other.copy_stage: return False
364 return True
365
Rich Lanec2ee4b82013-04-24 17:12:38 -0700366 def pretty_print(self, q):
367 q.text("bsn_mirror {")
368 with q.group():
369 with q.indent(2):
370 q.breakable()
371 q.text("dest_port = ");
372 q.text("%#x" % self.dest_port)
373 q.text(","); q.breakable()
374 q.text("vlan_tag = ");
375 q.text("%#x" % self.vlan_tag)
376 q.text(","); q.breakable()
377 q.text("copy_stage = ");
378 q.text("%#x" % self.copy_stage)
379 q.breakable()
380 q.text('}')
381
Rich Lane7dcdf022013-12-11 14:45:27 -0800382bsn.subtypes[1] = bsn_mirror
383
384class bsn_set_tunnel_dst(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700385 type = 65535
386 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -0700387 subtype = 2
388
389 def __init__(self, dst=None):
390 if dst != None:
391 self.dst = dst
392 else:
393 self.dst = 0
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(struct.pack("!L", self.experimenter))
401 packed.append(struct.pack("!L", self.subtype))
402 packed.append(struct.pack("!L", self.dst))
403 length = sum([len(x) for x in packed])
404 packed[1] = struct.pack("!H", length)
405 return ''.join(packed)
406
407 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800408 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700409 obj = bsn_set_tunnel_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700410 _type = reader.read("!H")[0]
411 assert(_type == 65535)
412 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800413 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800414 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700415 _experimenter = reader.read("!L")[0]
416 assert(_experimenter == 6035143)
417 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700418 assert(_subtype == 2)
Dan Talaycof6202252013-07-02 01:00:29 -0700419 obj.dst = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700420 return obj
421
422 def __eq__(self, other):
423 if type(self) != type(other): return False
424 if self.dst != other.dst: return False
425 return True
426
Rich Lanec2ee4b82013-04-24 17:12:38 -0700427 def pretty_print(self, q):
428 q.text("bsn_set_tunnel_dst {")
429 with q.group():
430 with q.indent(2):
431 q.breakable()
432 q.text("dst = ");
433 q.text("%#x" % self.dst)
434 q.breakable()
435 q.text('}')
436
Rich Lane7dcdf022013-12-11 14:45:27 -0800437bsn.subtypes[2] = bsn_set_tunnel_dst
438
439class copy_ttl_in(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700440 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -0700441
442 def __init__(self):
443 return
444
445 def pack(self):
446 packed = []
447 packed.append(struct.pack("!H", self.type))
448 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
449 packed.append('\x00' * 4)
450 length = sum([len(x) for x in packed])
451 packed[1] = struct.pack("!H", length)
452 return ''.join(packed)
453
454 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800455 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700456 obj = copy_ttl_in()
Dan Talaycof6202252013-07-02 01:00:29 -0700457 _type = reader.read("!H")[0]
458 assert(_type == 12)
459 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800460 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800461 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700462 reader.skip(4)
463 return obj
464
465 def __eq__(self, other):
466 if type(self) != type(other): return False
467 return True
468
Rich Lanec2ee4b82013-04-24 17:12:38 -0700469 def pretty_print(self, q):
470 q.text("copy_ttl_in {")
471 with q.group():
472 with q.indent(2):
473 q.breakable()
474 q.breakable()
475 q.text('}')
476
Rich Lane7dcdf022013-12-11 14:45:27 -0800477action.subtypes[12] = copy_ttl_in
478
479class copy_ttl_out(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700480 type = 11
Rich Lanec2ee4b82013-04-24 17:12:38 -0700481
482 def __init__(self):
483 return
484
485 def pack(self):
486 packed = []
487 packed.append(struct.pack("!H", self.type))
488 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
489 packed.append('\x00' * 4)
490 length = sum([len(x) for x in packed])
491 packed[1] = struct.pack("!H", length)
492 return ''.join(packed)
493
494 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800495 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700496 obj = copy_ttl_out()
Dan Talaycof6202252013-07-02 01:00:29 -0700497 _type = reader.read("!H")[0]
498 assert(_type == 11)
499 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800500 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800501 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700502 reader.skip(4)
503 return obj
504
505 def __eq__(self, other):
506 if type(self) != type(other): return False
507 return True
508
Rich Lanec2ee4b82013-04-24 17:12:38 -0700509 def pretty_print(self, q):
510 q.text("copy_ttl_out {")
511 with q.group():
512 with q.indent(2):
513 q.breakable()
514 q.breakable()
515 q.text('}')
516
Rich Lane7dcdf022013-12-11 14:45:27 -0800517action.subtypes[11] = copy_ttl_out
518
519class dec_mpls_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700520 type = 16
Rich Lanec2ee4b82013-04-24 17:12:38 -0700521
522 def __init__(self):
523 return
524
525 def pack(self):
526 packed = []
527 packed.append(struct.pack("!H", self.type))
528 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
529 packed.append('\x00' * 4)
530 length = sum([len(x) for x in packed])
531 packed[1] = struct.pack("!H", length)
532 return ''.join(packed)
533
534 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800535 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700536 obj = dec_mpls_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700537 _type = reader.read("!H")[0]
538 assert(_type == 16)
539 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800540 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800541 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700542 reader.skip(4)
543 return obj
544
545 def __eq__(self, other):
546 if type(self) != type(other): return False
547 return True
548
Rich Lanec2ee4b82013-04-24 17:12:38 -0700549 def pretty_print(self, q):
550 q.text("dec_mpls_ttl {")
551 with q.group():
552 with q.indent(2):
553 q.breakable()
554 q.breakable()
555 q.text('}')
556
Rich Lane7dcdf022013-12-11 14:45:27 -0800557action.subtypes[16] = dec_mpls_ttl
558
559class dec_nw_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700560 type = 24
Rich Lanec2ee4b82013-04-24 17:12:38 -0700561
562 def __init__(self):
563 return
564
565 def pack(self):
566 packed = []
567 packed.append(struct.pack("!H", self.type))
568 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
569 packed.append('\x00' * 4)
570 length = sum([len(x) for x in packed])
571 packed[1] = struct.pack("!H", length)
572 return ''.join(packed)
573
574 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800575 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700576 obj = dec_nw_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700577 _type = reader.read("!H")[0]
578 assert(_type == 24)
579 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800580 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800581 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700582 reader.skip(4)
583 return obj
584
585 def __eq__(self, other):
586 if type(self) != type(other): return False
587 return True
588
Rich Lanec2ee4b82013-04-24 17:12:38 -0700589 def pretty_print(self, q):
590 q.text("dec_nw_ttl {")
591 with q.group():
592 with q.indent(2):
593 q.breakable()
594 q.breakable()
595 q.text('}')
596
Rich Lane7dcdf022013-12-11 14:45:27 -0800597action.subtypes[24] = dec_nw_ttl
598
599class group(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700600 type = 22
Rich Lanec2ee4b82013-04-24 17:12:38 -0700601
602 def __init__(self, group_id=None):
603 if group_id != None:
604 self.group_id = group_id
605 else:
606 self.group_id = 0
607 return
608
609 def pack(self):
610 packed = []
611 packed.append(struct.pack("!H", self.type))
612 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
613 packed.append(struct.pack("!L", self.group_id))
614 length = sum([len(x) for x in packed])
615 packed[1] = struct.pack("!H", length)
616 return ''.join(packed)
617
618 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800619 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700620 obj = group()
Dan Talaycof6202252013-07-02 01:00:29 -0700621 _type = reader.read("!H")[0]
622 assert(_type == 22)
623 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800624 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800625 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700626 obj.group_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700627 return obj
628
629 def __eq__(self, other):
630 if type(self) != type(other): return False
631 if self.group_id != other.group_id: return False
632 return True
633
Rich Lanec2ee4b82013-04-24 17:12:38 -0700634 def pretty_print(self, q):
635 q.text("group {")
636 with q.group():
637 with q.indent(2):
638 q.breakable()
639 q.text("group_id = ");
640 q.text("%#x" % self.group_id)
641 q.breakable()
642 q.text('}')
643
Rich Lane7dcdf022013-12-11 14:45:27 -0800644action.subtypes[22] = group
645
646class nicira(experimenter):
647 subtypes = {}
648
Rich Lane95f7fc92014-01-27 17:08:16 -0800649 type = 65535
650 experimenter = 8992
651
652 def __init__(self, subtype=None):
653 if subtype != None:
654 self.subtype = subtype
655 else:
656 self.subtype = 0
657 return
658
659 def pack(self):
660 packed = []
661 packed.append(struct.pack("!H", self.type))
662 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
663 packed.append(struct.pack("!L", self.experimenter))
664 packed.append(struct.pack("!H", self.subtype))
665 packed.append('\x00' * 2)
666 packed.append('\x00' * 4)
667 length = sum([len(x) for x in packed])
668 packed[1] = struct.pack("!H", length)
669 return ''.join(packed)
670
Rich Lane7dcdf022013-12-11 14:45:27 -0800671 @staticmethod
672 def unpack(reader):
673 subtype, = reader.peek('!H', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800674 subclass = nicira.subtypes.get(subtype)
675 if subclass:
676 return subclass.unpack(reader)
677
678 obj = nicira()
679 _type = reader.read("!H")[0]
680 assert(_type == 65535)
681 _len = reader.read("!H")[0]
682 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800683 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800684 _experimenter = reader.read("!L")[0]
685 assert(_experimenter == 8992)
686 obj.subtype = reader.read("!H")[0]
687 reader.skip(2)
688 reader.skip(4)
689 return obj
690
691 def __eq__(self, other):
692 if type(self) != type(other): return False
693 if self.subtype != other.subtype: return False
694 return True
695
696 def pretty_print(self, q):
697 q.text("nicira {")
698 with q.group():
699 with q.indent(2):
700 q.breakable()
701 q.breakable()
702 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800703
704experimenter.subtypes[8992] = nicira
705
706class nicira_dec_ttl(nicira):
Dan Talaycof6202252013-07-02 01:00:29 -0700707 type = 65535
708 experimenter = 8992
Rich Lanec2ee4b82013-04-24 17:12:38 -0700709 subtype = 18
710
711 def __init__(self):
712 return
713
714 def pack(self):
715 packed = []
716 packed.append(struct.pack("!H", self.type))
717 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
718 packed.append(struct.pack("!L", self.experimenter))
719 packed.append(struct.pack("!H", self.subtype))
720 packed.append('\x00' * 2)
721 packed.append('\x00' * 4)
722 length = sum([len(x) for x in packed])
723 packed[1] = struct.pack("!H", length)
724 return ''.join(packed)
725
726 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800727 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700728 obj = nicira_dec_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700729 _type = reader.read("!H")[0]
730 assert(_type == 65535)
731 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800732 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800733 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700734 _experimenter = reader.read("!L")[0]
735 assert(_experimenter == 8992)
736 _subtype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700737 assert(_subtype == 18)
738 reader.skip(2)
739 reader.skip(4)
740 return obj
741
742 def __eq__(self, other):
743 if type(self) != type(other): return False
744 return True
745
Rich Lanec2ee4b82013-04-24 17:12:38 -0700746 def pretty_print(self, q):
747 q.text("nicira_dec_ttl {")
748 with q.group():
749 with q.indent(2):
750 q.breakable()
751 q.breakable()
752 q.text('}')
753
Rich Lane7dcdf022013-12-11 14:45:27 -0800754nicira.subtypes[18] = nicira_dec_ttl
755
756class output(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700757 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700758
759 def __init__(self, port=None, max_len=None):
760 if port != None:
761 self.port = port
762 else:
763 self.port = 0
764 if max_len != None:
765 self.max_len = max_len
766 else:
767 self.max_len = 0
768 return
769
770 def pack(self):
771 packed = []
772 packed.append(struct.pack("!H", self.type))
773 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700774 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700775 packed.append(struct.pack("!H", self.max_len))
776 packed.append('\x00' * 6)
777 length = sum([len(x) for x in packed])
778 packed[1] = struct.pack("!H", length)
779 return ''.join(packed)
780
781 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800782 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700783 obj = output()
Dan Talaycof6202252013-07-02 01:00:29 -0700784 _type = reader.read("!H")[0]
785 assert(_type == 0)
786 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800787 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800788 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700789 obj.port = util.unpack_port_no(reader)
790 obj.max_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700791 reader.skip(6)
792 return obj
793
794 def __eq__(self, other):
795 if type(self) != type(other): return False
796 if self.port != other.port: return False
797 if self.max_len != other.max_len: return False
798 return True
799
Rich Lanec2ee4b82013-04-24 17:12:38 -0700800 def pretty_print(self, q):
801 q.text("output {")
802 with q.group():
803 with q.indent(2):
804 q.breakable()
805 q.text("port = ");
806 q.text(util.pretty_port(self.port))
807 q.text(","); q.breakable()
808 q.text("max_len = ");
809 q.text("%#x" % self.max_len)
810 q.breakable()
811 q.text('}')
812
Rich Lane7dcdf022013-12-11 14:45:27 -0800813action.subtypes[0] = output
814
815class pop_mpls(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700816 type = 20
Rich Lanec2ee4b82013-04-24 17:12:38 -0700817
818 def __init__(self, ethertype=None):
819 if ethertype != None:
820 self.ethertype = ethertype
821 else:
822 self.ethertype = 0
823 return
824
825 def pack(self):
826 packed = []
827 packed.append(struct.pack("!H", self.type))
828 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
829 packed.append(struct.pack("!H", self.ethertype))
830 packed.append('\x00' * 2)
831 length = sum([len(x) for x in packed])
832 packed[1] = struct.pack("!H", length)
833 return ''.join(packed)
834
835 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800836 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700837 obj = pop_mpls()
Dan Talaycof6202252013-07-02 01:00:29 -0700838 _type = reader.read("!H")[0]
839 assert(_type == 20)
840 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800841 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800842 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700843 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700844 reader.skip(2)
845 return obj
846
847 def __eq__(self, other):
848 if type(self) != type(other): return False
849 if self.ethertype != other.ethertype: return False
850 return True
851
Rich Lanec2ee4b82013-04-24 17:12:38 -0700852 def pretty_print(self, q):
853 q.text("pop_mpls {")
854 with q.group():
855 with q.indent(2):
856 q.breakable()
857 q.text("ethertype = ");
858 q.text("%#x" % self.ethertype)
859 q.breakable()
860 q.text('}')
861
Rich Lane7dcdf022013-12-11 14:45:27 -0800862action.subtypes[20] = pop_mpls
863
864class pop_pbb(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700865 type = 27
Rich Lanec2ee4b82013-04-24 17:12:38 -0700866
867 def __init__(self):
868 return
869
870 def pack(self):
871 packed = []
872 packed.append(struct.pack("!H", self.type))
873 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
874 packed.append('\x00' * 4)
875 length = sum([len(x) for x in packed])
876 packed[1] = struct.pack("!H", length)
877 return ''.join(packed)
878
879 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800880 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700881 obj = pop_pbb()
Dan Talaycof6202252013-07-02 01:00:29 -0700882 _type = reader.read("!H")[0]
883 assert(_type == 27)
884 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800885 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800886 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700887 reader.skip(4)
888 return obj
889
890 def __eq__(self, other):
891 if type(self) != type(other): return False
892 return True
893
Rich Lanec2ee4b82013-04-24 17:12:38 -0700894 def pretty_print(self, q):
895 q.text("pop_pbb {")
896 with q.group():
897 with q.indent(2):
898 q.breakable()
899 q.breakable()
900 q.text('}')
901
Rich Lane7dcdf022013-12-11 14:45:27 -0800902action.subtypes[27] = pop_pbb
903
904class pop_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700905 type = 18
Rich Lanec2ee4b82013-04-24 17:12:38 -0700906
907 def __init__(self):
908 return
909
910 def pack(self):
911 packed = []
912 packed.append(struct.pack("!H", self.type))
913 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
914 packed.append('\x00' * 4)
915 length = sum([len(x) for x in packed])
916 packed[1] = struct.pack("!H", length)
917 return ''.join(packed)
918
919 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800920 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700921 obj = pop_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -0700922 _type = reader.read("!H")[0]
923 assert(_type == 18)
924 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800925 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800926 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700927 reader.skip(4)
928 return obj
929
930 def __eq__(self, other):
931 if type(self) != type(other): return False
932 return True
933
Rich Lanec2ee4b82013-04-24 17:12:38 -0700934 def pretty_print(self, q):
935 q.text("pop_vlan {")
936 with q.group():
937 with q.indent(2):
938 q.breakable()
939 q.breakable()
940 q.text('}')
941
Rich Lane7dcdf022013-12-11 14:45:27 -0800942action.subtypes[18] = pop_vlan
943
944class push_mpls(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700945 type = 19
Rich Lanec2ee4b82013-04-24 17:12:38 -0700946
947 def __init__(self, ethertype=None):
948 if ethertype != None:
949 self.ethertype = ethertype
950 else:
951 self.ethertype = 0
952 return
953
954 def pack(self):
955 packed = []
956 packed.append(struct.pack("!H", self.type))
957 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
958 packed.append(struct.pack("!H", self.ethertype))
959 packed.append('\x00' * 2)
960 length = sum([len(x) for x in packed])
961 packed[1] = struct.pack("!H", length)
962 return ''.join(packed)
963
964 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800965 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700966 obj = push_mpls()
Dan Talaycof6202252013-07-02 01:00:29 -0700967 _type = reader.read("!H")[0]
968 assert(_type == 19)
969 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800970 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800971 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700972 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700973 reader.skip(2)
974 return obj
975
976 def __eq__(self, other):
977 if type(self) != type(other): return False
978 if self.ethertype != other.ethertype: return False
979 return True
980
Rich Lanec2ee4b82013-04-24 17:12:38 -0700981 def pretty_print(self, q):
982 q.text("push_mpls {")
983 with q.group():
984 with q.indent(2):
985 q.breakable()
986 q.text("ethertype = ");
987 q.text("%#x" % self.ethertype)
988 q.breakable()
989 q.text('}')
990
Rich Lane7dcdf022013-12-11 14:45:27 -0800991action.subtypes[19] = push_mpls
992
993class push_pbb(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700994 type = 26
Rich Lanec2ee4b82013-04-24 17:12:38 -0700995
996 def __init__(self, ethertype=None):
997 if ethertype != None:
998 self.ethertype = ethertype
999 else:
1000 self.ethertype = 0
1001 return
1002
1003 def pack(self):
1004 packed = []
1005 packed.append(struct.pack("!H", self.type))
1006 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1007 packed.append(struct.pack("!H", self.ethertype))
1008 packed.append('\x00' * 2)
1009 length = sum([len(x) for x in packed])
1010 packed[1] = struct.pack("!H", length)
1011 return ''.join(packed)
1012
1013 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001014 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001015 obj = push_pbb()
Dan Talaycof6202252013-07-02 01:00:29 -07001016 _type = reader.read("!H")[0]
1017 assert(_type == 26)
1018 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001019 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001020 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001021 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001022 reader.skip(2)
1023 return obj
1024
1025 def __eq__(self, other):
1026 if type(self) != type(other): return False
1027 if self.ethertype != other.ethertype: return False
1028 return True
1029
Rich Lanec2ee4b82013-04-24 17:12:38 -07001030 def pretty_print(self, q):
1031 q.text("push_pbb {")
1032 with q.group():
1033 with q.indent(2):
1034 q.breakable()
1035 q.text("ethertype = ");
1036 q.text("%#x" % self.ethertype)
1037 q.breakable()
1038 q.text('}')
1039
Rich Lane7dcdf022013-12-11 14:45:27 -08001040action.subtypes[26] = push_pbb
1041
1042class push_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001043 type = 17
Rich Lanec2ee4b82013-04-24 17:12:38 -07001044
1045 def __init__(self, ethertype=None):
1046 if ethertype != None:
1047 self.ethertype = ethertype
1048 else:
1049 self.ethertype = 0
1050 return
1051
1052 def pack(self):
1053 packed = []
1054 packed.append(struct.pack("!H", self.type))
1055 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1056 packed.append(struct.pack("!H", self.ethertype))
1057 packed.append('\x00' * 2)
1058 length = sum([len(x) for x in packed])
1059 packed[1] = struct.pack("!H", length)
1060 return ''.join(packed)
1061
1062 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001063 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001064 obj = push_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -07001065 _type = reader.read("!H")[0]
1066 assert(_type == 17)
1067 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001068 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001069 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001070 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001071 reader.skip(2)
1072 return obj
1073
1074 def __eq__(self, other):
1075 if type(self) != type(other): return False
1076 if self.ethertype != other.ethertype: return False
1077 return True
1078
Rich Lanec2ee4b82013-04-24 17:12:38 -07001079 def pretty_print(self, q):
1080 q.text("push_vlan {")
1081 with q.group():
1082 with q.indent(2):
1083 q.breakable()
1084 q.text("ethertype = ");
1085 q.text("%#x" % self.ethertype)
1086 q.breakable()
1087 q.text('}')
1088
Rich Lane7dcdf022013-12-11 14:45:27 -08001089action.subtypes[17] = push_vlan
1090
1091class set_field(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001092 type = 25
Rich Lanec2ee4b82013-04-24 17:12:38 -07001093
1094 def __init__(self, field=None):
1095 if field != None:
1096 self.field = field
1097 else:
Rich Laned53156a2013-08-05 17:17:33 -07001098 self.field = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07001099 return
1100
1101 def pack(self):
1102 packed = []
1103 packed.append(struct.pack("!H", self.type))
1104 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Rich Laned53156a2013-08-05 17:17:33 -07001105 packed.append(self.field.pack())
Rich Lanec2ee4b82013-04-24 17:12:38 -07001106 length = sum([len(x) for x in packed])
Rich Laned53156a2013-08-05 17:17:33 -07001107 packed.append(loxi.generic_util.pad_to(8, length))
1108 length += len(packed[-1])
Rich Lanec2ee4b82013-04-24 17:12:38 -07001109 packed[1] = struct.pack("!H", length)
1110 return ''.join(packed)
1111
1112 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001113 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001114 obj = set_field()
Dan Talaycof6202252013-07-02 01:00:29 -07001115 _type = reader.read("!H")[0]
1116 assert(_type == 25)
1117 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001118 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001119 reader = orig_reader.slice(_len, 4)
Rich Lanee2567702015-01-26 15:04:35 -08001120 obj.field = ofp.oxm.oxm.unpack(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001121 return obj
1122
1123 def __eq__(self, other):
1124 if type(self) != type(other): return False
1125 if self.field != other.field: return False
1126 return True
1127
Rich Lanec2ee4b82013-04-24 17:12:38 -07001128 def pretty_print(self, q):
1129 q.text("set_field {")
1130 with q.group():
1131 with q.indent(2):
1132 q.breakable()
1133 q.text("field = ");
1134 q.pp(self.field)
1135 q.breakable()
1136 q.text('}')
1137
Rich Lane7dcdf022013-12-11 14:45:27 -08001138action.subtypes[25] = set_field
1139
1140class set_mpls_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001141 type = 15
Rich Lanec2ee4b82013-04-24 17:12:38 -07001142
1143 def __init__(self, mpls_ttl=None):
1144 if mpls_ttl != None:
1145 self.mpls_ttl = mpls_ttl
1146 else:
1147 self.mpls_ttl = 0
1148 return
1149
1150 def pack(self):
1151 packed = []
1152 packed.append(struct.pack("!H", self.type))
1153 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1154 packed.append(struct.pack("!B", self.mpls_ttl))
1155 packed.append('\x00' * 3)
1156 length = sum([len(x) for x in packed])
1157 packed[1] = struct.pack("!H", length)
1158 return ''.join(packed)
1159
1160 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001161 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001162 obj = set_mpls_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -07001163 _type = reader.read("!H")[0]
1164 assert(_type == 15)
1165 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001166 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001167 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001168 obj.mpls_ttl = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001169 reader.skip(3)
1170 return obj
1171
1172 def __eq__(self, other):
1173 if type(self) != type(other): return False
1174 if self.mpls_ttl != other.mpls_ttl: return False
1175 return True
1176
Rich Lanec2ee4b82013-04-24 17:12:38 -07001177 def pretty_print(self, q):
1178 q.text("set_mpls_ttl {")
1179 with q.group():
1180 with q.indent(2):
1181 q.breakable()
1182 q.text("mpls_ttl = ");
1183 q.text("%#x" % self.mpls_ttl)
1184 q.breakable()
1185 q.text('}')
1186
Rich Lane7dcdf022013-12-11 14:45:27 -08001187action.subtypes[15] = set_mpls_ttl
1188
1189class set_nw_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001190 type = 23
Rich Lanec2ee4b82013-04-24 17:12:38 -07001191
1192 def __init__(self, nw_ttl=None):
1193 if nw_ttl != None:
1194 self.nw_ttl = nw_ttl
1195 else:
1196 self.nw_ttl = 0
1197 return
1198
1199 def pack(self):
1200 packed = []
1201 packed.append(struct.pack("!H", self.type))
1202 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1203 packed.append(struct.pack("!B", self.nw_ttl))
1204 packed.append('\x00' * 3)
1205 length = sum([len(x) for x in packed])
1206 packed[1] = struct.pack("!H", length)
1207 return ''.join(packed)
1208
1209 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001210 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001211 obj = set_nw_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -07001212 _type = reader.read("!H")[0]
1213 assert(_type == 23)
1214 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001215 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001216 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001217 obj.nw_ttl = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001218 reader.skip(3)
1219 return obj
1220
1221 def __eq__(self, other):
1222 if type(self) != type(other): return False
1223 if self.nw_ttl != other.nw_ttl: return False
1224 return True
1225
Rich Lanec2ee4b82013-04-24 17:12:38 -07001226 def pretty_print(self, q):
1227 q.text("set_nw_ttl {")
1228 with q.group():
1229 with q.indent(2):
1230 q.breakable()
1231 q.text("nw_ttl = ");
1232 q.text("%#x" % self.nw_ttl)
1233 q.breakable()
1234 q.text('}')
1235
Rich Lane7dcdf022013-12-11 14:45:27 -08001236action.subtypes[23] = set_nw_ttl
1237
1238class set_queue(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001239 type = 21
Rich Lanec2ee4b82013-04-24 17:12:38 -07001240
1241 def __init__(self, queue_id=None):
1242 if queue_id != None:
1243 self.queue_id = queue_id
1244 else:
1245 self.queue_id = 0
1246 return
1247
1248 def pack(self):
1249 packed = []
1250 packed.append(struct.pack("!H", self.type))
1251 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1252 packed.append(struct.pack("!L", self.queue_id))
1253 length = sum([len(x) for x in packed])
1254 packed[1] = struct.pack("!H", length)
1255 return ''.join(packed)
1256
1257 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001258 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001259 obj = set_queue()
Dan Talaycof6202252013-07-02 01:00:29 -07001260 _type = reader.read("!H")[0]
1261 assert(_type == 21)
1262 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001263 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001264 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001265 obj.queue_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001266 return obj
1267
1268 def __eq__(self, other):
1269 if type(self) != type(other): return False
1270 if self.queue_id != other.queue_id: return False
1271 return True
1272
Rich Lanec2ee4b82013-04-24 17:12:38 -07001273 def pretty_print(self, q):
1274 q.text("set_queue {")
1275 with q.group():
1276 with q.indent(2):
1277 q.breakable()
1278 q.text("queue_id = ");
1279 q.text("%#x" % self.queue_id)
1280 q.breakable()
1281 q.text('}')
1282
Rich Lane7dcdf022013-12-11 14:45:27 -08001283action.subtypes[21] = set_queue
Rich Lanec2ee4b82013-04-24 17:12:38 -07001284
Rich Lanec2ee4b82013-04-24 17:12:38 -07001285