blob: 5c1eda717c376be1f2b525381ee16908c8ba7d5d [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 const
Harshmeet Singh1db46332014-10-14 16:29:13 -070012import bsn_tlv
13import meter_band
Rich Lane7dcdf022013-12-11 14:45:27 -080014import instruction
15import oxm
Harshmeet Singh1db46332014-10-14 16:29:13 -070016import common
Rich Lane7dcdf022013-12-11 14:45:27 -080017import instruction_id
Harshmeet Singh1db46332014-10-14 16:29:13 -070018import action
19import message
20import action_id
Rich Lanec2ee4b82013-04-24 17:12:38 -070021import util
22import loxi.generic_util
Rich Lanec2ee4b82013-04-24 17:12:38 -070023
Rich Lane7dcdf022013-12-11 14:45:27 -080024class action(loxi.OFObject):
25 subtypes = {}
Rich Lanec2ee4b82013-04-24 17:12:38 -070026
Rich Lane95f7fc92014-01-27 17:08:16 -080027
28 def __init__(self, type=None):
29 if type != None:
30 self.type = type
31 else:
32 self.type = 0
33 return
34
35 def pack(self):
36 packed = []
37 packed.append(struct.pack("!H", self.type))
38 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
39 packed.append('\x00' * 4)
40 length = sum([len(x) for x in packed])
41 packed[1] = struct.pack("!H", length)
42 return ''.join(packed)
43
Rich Lane7dcdf022013-12-11 14:45:27 -080044 @staticmethod
45 def unpack(reader):
46 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -080047 subclass = action.subtypes.get(subtype)
48 if subclass:
49 return subclass.unpack(reader)
50
51 obj = action()
52 obj.type = reader.read("!H")[0]
53 _len = reader.read("!H")[0]
54 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -080055 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -080056 reader.skip(4)
57 return obj
58
59 def __eq__(self, other):
60 if type(self) != type(other): return False
61 if self.type != other.type: return False
62 return True
63
64 def pretty_print(self, q):
65 q.text("action {")
66 with q.group():
67 with q.indent(2):
68 q.breakable()
69 q.breakable()
70 q.text('}')
Rich Lanec2ee4b82013-04-24 17:12:38 -070071
Rich Lane7dcdf022013-12-11 14:45:27 -080072
73class experimenter(action):
74 subtypes = {}
75
Rich Lane95f7fc92014-01-27 17:08:16 -080076 type = 65535
77
78 def __init__(self, experimenter=None, data=None):
79 if experimenter != None:
80 self.experimenter = experimenter
81 else:
82 self.experimenter = 0
83 if data != None:
84 self.data = data
85 else:
86 self.data = ''
87 return
88
89 def pack(self):
90 packed = []
91 packed.append(struct.pack("!H", self.type))
92 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
93 packed.append(struct.pack("!L", self.experimenter))
94 packed.append(self.data)
95 length = sum([len(x) for x in packed])
96 packed.append(loxi.generic_util.pad_to(8, length))
97 length += len(packed[-1])
98 packed[1] = struct.pack("!H", length)
99 return ''.join(packed)
100
Rich Lane7dcdf022013-12-11 14:45:27 -0800101 @staticmethod
102 def unpack(reader):
103 subtype, = reader.peek('!L', 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800104 subclass = experimenter.subtypes.get(subtype)
105 if subclass:
106 return subclass.unpack(reader)
107
108 obj = experimenter()
109 _type = reader.read("!H")[0]
110 assert(_type == 65535)
111 _len = reader.read("!H")[0]
112 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800113 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800114 obj.experimenter = reader.read("!L")[0]
115 obj.data = str(reader.read_all())
116 return obj
117
118 def __eq__(self, other):
119 if type(self) != type(other): return False
120 if self.experimenter != other.experimenter: return False
121 if self.data != other.data: return False
122 return True
123
124 def pretty_print(self, q):
125 q.text("experimenter {")
126 with q.group():
127 with q.indent(2):
128 q.breakable()
129 q.text("data = ");
130 q.pp(self.data)
131 q.breakable()
132 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800133
134action.subtypes[65535] = experimenter
135
136class bsn(experimenter):
137 subtypes = {}
138
Rich Lane95f7fc92014-01-27 17:08:16 -0800139 type = 65535
140 experimenter = 6035143
141
142 def __init__(self, subtype=None):
143 if subtype != None:
144 self.subtype = subtype
145 else:
146 self.subtype = 0
147 return
148
149 def pack(self):
150 packed = []
151 packed.append(struct.pack("!H", self.type))
152 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
153 packed.append(struct.pack("!L", self.experimenter))
154 packed.append(struct.pack("!L", self.subtype))
155 packed.append('\x00' * 4)
156 length = sum([len(x) for x in packed])
157 packed[1] = struct.pack("!H", length)
158 return ''.join(packed)
159
Rich Lane7dcdf022013-12-11 14:45:27 -0800160 @staticmethod
161 def unpack(reader):
162 subtype, = reader.peek('!L', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800163 subclass = bsn.subtypes.get(subtype)
164 if subclass:
165 return subclass.unpack(reader)
166
167 obj = bsn()
168 _type = reader.read("!H")[0]
169 assert(_type == 65535)
170 _len = reader.read("!H")[0]
171 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800172 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800173 _experimenter = reader.read("!L")[0]
174 assert(_experimenter == 6035143)
175 obj.subtype = reader.read("!L")[0]
176 reader.skip(4)
177 return obj
178
179 def __eq__(self, other):
180 if type(self) != type(other): return False
181 if self.subtype != other.subtype: return False
182 return True
183
184 def pretty_print(self, q):
185 q.text("bsn {")
186 with q.group():
187 with q.indent(2):
188 q.breakable()
189 q.breakable()
190 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800191
192experimenter.subtypes[6035143] = bsn
193
Rich Lane5587ab12014-06-30 11:19:09 -0700194class bsn_checksum(bsn):
195 type = 65535
196 experimenter = 6035143
197 subtype = 4
198
199 def __init__(self, checksum=None):
200 if checksum != None:
201 self.checksum = checksum
202 else:
203 self.checksum = 0
204 return
205
206 def pack(self):
207 packed = []
208 packed.append(struct.pack("!H", self.type))
209 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
210 packed.append(struct.pack("!L", self.experimenter))
211 packed.append(struct.pack("!L", self.subtype))
212 packed.append(util.pack_checksum_128(self.checksum))
213 length = sum([len(x) for x in packed])
214 packed[1] = struct.pack("!H", length)
215 return ''.join(packed)
216
217 @staticmethod
218 def unpack(reader):
219 obj = bsn_checksum()
220 _type = reader.read("!H")[0]
221 assert(_type == 65535)
222 _len = reader.read("!H")[0]
223 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800224 reader = orig_reader.slice(_len, 4)
Rich Lane5587ab12014-06-30 11:19:09 -0700225 _experimenter = reader.read("!L")[0]
226 assert(_experimenter == 6035143)
227 _subtype = reader.read("!L")[0]
228 assert(_subtype == 4)
229 obj.checksum = util.unpack_checksum_128(reader)
230 return obj
231
232 def __eq__(self, other):
233 if type(self) != type(other): return False
234 if self.checksum != other.checksum: return False
235 return True
236
237 def pretty_print(self, q):
238 q.text("bsn_checksum {")
239 with q.group():
240 with q.indent(2):
241 q.breakable()
242 q.text("checksum = ");
243 q.pp(self.checksum)
244 q.breakable()
245 q.text('}')
246
247bsn.subtypes[4] = bsn_checksum
248
Rich Lane2e079da2014-10-29 15:30:24 -0700249class bsn_gentable(bsn):
250 type = 65535
251 experimenter = 6035143
252 subtype = 5
253
254 def __init__(self, table_id=None, key=None):
255 if table_id != None:
256 self.table_id = table_id
257 else:
258 self.table_id = 0
259 if key != None:
260 self.key = key
261 else:
262 self.key = []
263 return
264
265 def pack(self):
266 packed = []
267 packed.append(struct.pack("!H", self.type))
268 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
269 packed.append(struct.pack("!L", self.experimenter))
270 packed.append(struct.pack("!L", self.subtype))
271 packed.append(struct.pack("!L", self.table_id))
272 packed.append(loxi.generic_util.pack_list(self.key))
273 length = sum([len(x) for x in packed])
274 packed[1] = struct.pack("!H", length)
275 return ''.join(packed)
276
277 @staticmethod
278 def unpack(reader):
279 obj = bsn_gentable()
280 _type = reader.read("!H")[0]
281 assert(_type == 65535)
282 _len = reader.read("!H")[0]
283 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800284 reader = orig_reader.slice(_len, 4)
Rich Lane2e079da2014-10-29 15:30:24 -0700285 _experimenter = reader.read("!L")[0]
286 assert(_experimenter == 6035143)
287 _subtype = reader.read("!L")[0]
288 assert(_subtype == 5)
289 obj.table_id = reader.read("!L")[0]
290 obj.key = loxi.generic_util.unpack_list(reader, bsn_tlv.bsn_tlv.unpack)
291 return obj
292
293 def __eq__(self, other):
294 if type(self) != type(other): return False
295 if self.table_id != other.table_id: return False
296 if self.key != other.key: return False
297 return True
298
299 def pretty_print(self, q):
300 q.text("bsn_gentable {")
301 with q.group():
302 with q.indent(2):
303 q.breakable()
304 q.text("table_id = ");
305 q.text("%#x" % self.table_id)
306 q.text(","); q.breakable()
307 q.text("key = ");
308 q.pp(self.key)
309 q.breakable()
310 q.text('}')
311
312bsn.subtypes[5] = bsn_gentable
313
Rich Lane7dcdf022013-12-11 14:45:27 -0800314class bsn_mirror(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700315 type = 65535
316 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -0700317 subtype = 1
318
319 def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None):
320 if dest_port != None:
321 self.dest_port = dest_port
322 else:
323 self.dest_port = 0
324 if vlan_tag != None:
325 self.vlan_tag = vlan_tag
326 else:
327 self.vlan_tag = 0
328 if copy_stage != None:
329 self.copy_stage = copy_stage
330 else:
331 self.copy_stage = 0
332 return
333
334 def pack(self):
335 packed = []
336 packed.append(struct.pack("!H", self.type))
337 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
338 packed.append(struct.pack("!L", self.experimenter))
339 packed.append(struct.pack("!L", self.subtype))
340 packed.append(struct.pack("!L", self.dest_port))
341 packed.append(struct.pack("!L", self.vlan_tag))
342 packed.append(struct.pack("!B", self.copy_stage))
343 packed.append('\x00' * 3)
344 length = sum([len(x) for x in packed])
345 packed[1] = struct.pack("!H", length)
346 return ''.join(packed)
347
348 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800349 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700350 obj = bsn_mirror()
Dan Talaycof6202252013-07-02 01:00:29 -0700351 _type = reader.read("!H")[0]
352 assert(_type == 65535)
353 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800354 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800355 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700356 _experimenter = reader.read("!L")[0]
357 assert(_experimenter == 6035143)
358 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700359 assert(_subtype == 1)
Dan Talaycof6202252013-07-02 01:00:29 -0700360 obj.dest_port = reader.read("!L")[0]
361 obj.vlan_tag = reader.read("!L")[0]
362 obj.copy_stage = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700363 reader.skip(3)
364 return obj
365
366 def __eq__(self, other):
367 if type(self) != type(other): return False
368 if self.dest_port != other.dest_port: return False
369 if self.vlan_tag != other.vlan_tag: return False
370 if self.copy_stage != other.copy_stage: return False
371 return True
372
Rich Lanec2ee4b82013-04-24 17:12:38 -0700373 def pretty_print(self, q):
374 q.text("bsn_mirror {")
375 with q.group():
376 with q.indent(2):
377 q.breakable()
378 q.text("dest_port = ");
379 q.text("%#x" % self.dest_port)
380 q.text(","); q.breakable()
381 q.text("vlan_tag = ");
382 q.text("%#x" % self.vlan_tag)
383 q.text(","); q.breakable()
384 q.text("copy_stage = ");
385 q.text("%#x" % self.copy_stage)
386 q.breakable()
387 q.text('}')
388
Rich Lane7dcdf022013-12-11 14:45:27 -0800389bsn.subtypes[1] = bsn_mirror
390
391class bsn_set_tunnel_dst(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700392 type = 65535
393 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -0700394 subtype = 2
395
396 def __init__(self, dst=None):
397 if dst != None:
398 self.dst = dst
399 else:
400 self.dst = 0
401 return
402
403 def pack(self):
404 packed = []
405 packed.append(struct.pack("!H", self.type))
406 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
407 packed.append(struct.pack("!L", self.experimenter))
408 packed.append(struct.pack("!L", self.subtype))
409 packed.append(struct.pack("!L", self.dst))
410 length = sum([len(x) for x in packed])
411 packed[1] = struct.pack("!H", length)
412 return ''.join(packed)
413
414 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800415 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700416 obj = bsn_set_tunnel_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700417 _type = reader.read("!H")[0]
418 assert(_type == 65535)
419 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800420 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800421 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700422 _experimenter = reader.read("!L")[0]
423 assert(_experimenter == 6035143)
424 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700425 assert(_subtype == 2)
Dan Talaycof6202252013-07-02 01:00:29 -0700426 obj.dst = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700427 return obj
428
429 def __eq__(self, other):
430 if type(self) != type(other): return False
431 if self.dst != other.dst: return False
432 return True
433
Rich Lanec2ee4b82013-04-24 17:12:38 -0700434 def pretty_print(self, q):
435 q.text("bsn_set_tunnel_dst {")
436 with q.group():
437 with q.indent(2):
438 q.breakable()
439 q.text("dst = ");
440 q.text("%#x" % self.dst)
441 q.breakable()
442 q.text('}')
443
Rich Lane7dcdf022013-12-11 14:45:27 -0800444bsn.subtypes[2] = bsn_set_tunnel_dst
445
446class copy_ttl_in(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700447 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -0700448
449 def __init__(self):
450 return
451
452 def pack(self):
453 packed = []
454 packed.append(struct.pack("!H", self.type))
455 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
456 packed.append('\x00' * 4)
457 length = sum([len(x) for x in packed])
458 packed[1] = struct.pack("!H", length)
459 return ''.join(packed)
460
461 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800462 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700463 obj = copy_ttl_in()
Dan Talaycof6202252013-07-02 01:00:29 -0700464 _type = reader.read("!H")[0]
465 assert(_type == 12)
466 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800467 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800468 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700469 reader.skip(4)
470 return obj
471
472 def __eq__(self, other):
473 if type(self) != type(other): return False
474 return True
475
Rich Lanec2ee4b82013-04-24 17:12:38 -0700476 def pretty_print(self, q):
477 q.text("copy_ttl_in {")
478 with q.group():
479 with q.indent(2):
480 q.breakable()
481 q.breakable()
482 q.text('}')
483
Rich Lane7dcdf022013-12-11 14:45:27 -0800484action.subtypes[12] = copy_ttl_in
485
486class copy_ttl_out(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700487 type = 11
Rich Lanec2ee4b82013-04-24 17:12:38 -0700488
489 def __init__(self):
490 return
491
492 def pack(self):
493 packed = []
494 packed.append(struct.pack("!H", self.type))
495 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
496 packed.append('\x00' * 4)
497 length = sum([len(x) for x in packed])
498 packed[1] = struct.pack("!H", length)
499 return ''.join(packed)
500
501 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800502 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700503 obj = copy_ttl_out()
Dan Talaycof6202252013-07-02 01:00:29 -0700504 _type = reader.read("!H")[0]
505 assert(_type == 11)
506 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800507 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800508 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700509 reader.skip(4)
510 return obj
511
512 def __eq__(self, other):
513 if type(self) != type(other): return False
514 return True
515
Rich Lanec2ee4b82013-04-24 17:12:38 -0700516 def pretty_print(self, q):
517 q.text("copy_ttl_out {")
518 with q.group():
519 with q.indent(2):
520 q.breakable()
521 q.breakable()
522 q.text('}')
523
Rich Lane7dcdf022013-12-11 14:45:27 -0800524action.subtypes[11] = copy_ttl_out
525
526class dec_mpls_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700527 type = 16
Rich Lanec2ee4b82013-04-24 17:12:38 -0700528
529 def __init__(self):
530 return
531
532 def pack(self):
533 packed = []
534 packed.append(struct.pack("!H", self.type))
535 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
536 packed.append('\x00' * 4)
537 length = sum([len(x) for x in packed])
538 packed[1] = struct.pack("!H", length)
539 return ''.join(packed)
540
541 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800542 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700543 obj = dec_mpls_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700544 _type = reader.read("!H")[0]
545 assert(_type == 16)
546 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800547 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800548 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700549 reader.skip(4)
550 return obj
551
552 def __eq__(self, other):
553 if type(self) != type(other): return False
554 return True
555
Rich Lanec2ee4b82013-04-24 17:12:38 -0700556 def pretty_print(self, q):
557 q.text("dec_mpls_ttl {")
558 with q.group():
559 with q.indent(2):
560 q.breakable()
561 q.breakable()
562 q.text('}')
563
Rich Lane7dcdf022013-12-11 14:45:27 -0800564action.subtypes[16] = dec_mpls_ttl
565
566class dec_nw_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700567 type = 24
Rich Lanec2ee4b82013-04-24 17:12:38 -0700568
569 def __init__(self):
570 return
571
572 def pack(self):
573 packed = []
574 packed.append(struct.pack("!H", self.type))
575 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
576 packed.append('\x00' * 4)
577 length = sum([len(x) for x in packed])
578 packed[1] = struct.pack("!H", length)
579 return ''.join(packed)
580
581 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800582 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700583 obj = dec_nw_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700584 _type = reader.read("!H")[0]
585 assert(_type == 24)
586 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800587 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800588 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700589 reader.skip(4)
590 return obj
591
592 def __eq__(self, other):
593 if type(self) != type(other): return False
594 return True
595
Rich Lanec2ee4b82013-04-24 17:12:38 -0700596 def pretty_print(self, q):
597 q.text("dec_nw_ttl {")
598 with q.group():
599 with q.indent(2):
600 q.breakable()
601 q.breakable()
602 q.text('}')
603
Rich Lane7dcdf022013-12-11 14:45:27 -0800604action.subtypes[24] = dec_nw_ttl
605
606class group(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700607 type = 22
Rich Lanec2ee4b82013-04-24 17:12:38 -0700608
609 def __init__(self, group_id=None):
610 if group_id != None:
611 self.group_id = group_id
612 else:
613 self.group_id = 0
614 return
615
616 def pack(self):
617 packed = []
618 packed.append(struct.pack("!H", self.type))
619 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
620 packed.append(struct.pack("!L", self.group_id))
621 length = sum([len(x) for x in packed])
622 packed[1] = struct.pack("!H", length)
623 return ''.join(packed)
624
625 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800626 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700627 obj = group()
Dan Talaycof6202252013-07-02 01:00:29 -0700628 _type = reader.read("!H")[0]
629 assert(_type == 22)
630 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800631 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800632 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700633 obj.group_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700634 return obj
635
636 def __eq__(self, other):
637 if type(self) != type(other): return False
638 if self.group_id != other.group_id: return False
639 return True
640
Rich Lanec2ee4b82013-04-24 17:12:38 -0700641 def pretty_print(self, q):
642 q.text("group {")
643 with q.group():
644 with q.indent(2):
645 q.breakable()
646 q.text("group_id = ");
647 q.text("%#x" % self.group_id)
648 q.breakable()
649 q.text('}')
650
Rich Lane7dcdf022013-12-11 14:45:27 -0800651action.subtypes[22] = group
652
653class nicira(experimenter):
654 subtypes = {}
655
Rich Lane95f7fc92014-01-27 17:08:16 -0800656 type = 65535
657 experimenter = 8992
658
659 def __init__(self, subtype=None):
660 if subtype != None:
661 self.subtype = subtype
662 else:
663 self.subtype = 0
664 return
665
666 def pack(self):
667 packed = []
668 packed.append(struct.pack("!H", self.type))
669 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
670 packed.append(struct.pack("!L", self.experimenter))
671 packed.append(struct.pack("!H", self.subtype))
672 packed.append('\x00' * 2)
673 packed.append('\x00' * 4)
674 length = sum([len(x) for x in packed])
675 packed[1] = struct.pack("!H", length)
676 return ''.join(packed)
677
Rich Lane7dcdf022013-12-11 14:45:27 -0800678 @staticmethod
679 def unpack(reader):
680 subtype, = reader.peek('!H', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800681 subclass = nicira.subtypes.get(subtype)
682 if subclass:
683 return subclass.unpack(reader)
684
685 obj = nicira()
686 _type = reader.read("!H")[0]
687 assert(_type == 65535)
688 _len = reader.read("!H")[0]
689 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800690 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800691 _experimenter = reader.read("!L")[0]
692 assert(_experimenter == 8992)
693 obj.subtype = reader.read("!H")[0]
694 reader.skip(2)
695 reader.skip(4)
696 return obj
697
698 def __eq__(self, other):
699 if type(self) != type(other): return False
700 if self.subtype != other.subtype: return False
701 return True
702
703 def pretty_print(self, q):
704 q.text("nicira {")
705 with q.group():
706 with q.indent(2):
707 q.breakable()
708 q.breakable()
709 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800710
711experimenter.subtypes[8992] = nicira
712
713class nicira_dec_ttl(nicira):
Dan Talaycof6202252013-07-02 01:00:29 -0700714 type = 65535
715 experimenter = 8992
Rich Lanec2ee4b82013-04-24 17:12:38 -0700716 subtype = 18
717
718 def __init__(self):
719 return
720
721 def pack(self):
722 packed = []
723 packed.append(struct.pack("!H", self.type))
724 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
725 packed.append(struct.pack("!L", self.experimenter))
726 packed.append(struct.pack("!H", self.subtype))
727 packed.append('\x00' * 2)
728 packed.append('\x00' * 4)
729 length = sum([len(x) for x in packed])
730 packed[1] = struct.pack("!H", length)
731 return ''.join(packed)
732
733 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800734 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700735 obj = nicira_dec_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700736 _type = reader.read("!H")[0]
737 assert(_type == 65535)
738 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800739 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800740 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700741 _experimenter = reader.read("!L")[0]
742 assert(_experimenter == 8992)
743 _subtype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700744 assert(_subtype == 18)
745 reader.skip(2)
746 reader.skip(4)
747 return obj
748
749 def __eq__(self, other):
750 if type(self) != type(other): return False
751 return True
752
Rich Lanec2ee4b82013-04-24 17:12:38 -0700753 def pretty_print(self, q):
754 q.text("nicira_dec_ttl {")
755 with q.group():
756 with q.indent(2):
757 q.breakable()
758 q.breakable()
759 q.text('}')
760
Rich Lane7dcdf022013-12-11 14:45:27 -0800761nicira.subtypes[18] = nicira_dec_ttl
762
763class output(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700764 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700765
766 def __init__(self, port=None, max_len=None):
767 if port != None:
768 self.port = port
769 else:
770 self.port = 0
771 if max_len != None:
772 self.max_len = max_len
773 else:
774 self.max_len = 0
775 return
776
777 def pack(self):
778 packed = []
779 packed.append(struct.pack("!H", self.type))
780 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700781 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700782 packed.append(struct.pack("!H", self.max_len))
783 packed.append('\x00' * 6)
784 length = sum([len(x) for x in packed])
785 packed[1] = struct.pack("!H", length)
786 return ''.join(packed)
787
788 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800789 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700790 obj = output()
Dan Talaycof6202252013-07-02 01:00:29 -0700791 _type = reader.read("!H")[0]
792 assert(_type == 0)
793 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800794 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800795 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700796 obj.port = util.unpack_port_no(reader)
797 obj.max_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700798 reader.skip(6)
799 return obj
800
801 def __eq__(self, other):
802 if type(self) != type(other): return False
803 if self.port != other.port: return False
804 if self.max_len != other.max_len: return False
805 return True
806
Rich Lanec2ee4b82013-04-24 17:12:38 -0700807 def pretty_print(self, q):
808 q.text("output {")
809 with q.group():
810 with q.indent(2):
811 q.breakable()
812 q.text("port = ");
813 q.text(util.pretty_port(self.port))
814 q.text(","); q.breakable()
815 q.text("max_len = ");
816 q.text("%#x" % self.max_len)
817 q.breakable()
818 q.text('}')
819
Rich Lane7dcdf022013-12-11 14:45:27 -0800820action.subtypes[0] = output
821
822class pop_mpls(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700823 type = 20
Rich Lanec2ee4b82013-04-24 17:12:38 -0700824
825 def __init__(self, ethertype=None):
826 if ethertype != None:
827 self.ethertype = ethertype
828 else:
829 self.ethertype = 0
830 return
831
832 def pack(self):
833 packed = []
834 packed.append(struct.pack("!H", self.type))
835 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
836 packed.append(struct.pack("!H", self.ethertype))
837 packed.append('\x00' * 2)
838 length = sum([len(x) for x in packed])
839 packed[1] = struct.pack("!H", length)
840 return ''.join(packed)
841
842 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800843 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700844 obj = pop_mpls()
Dan Talaycof6202252013-07-02 01:00:29 -0700845 _type = reader.read("!H")[0]
846 assert(_type == 20)
847 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800848 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800849 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700850 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700851 reader.skip(2)
852 return obj
853
854 def __eq__(self, other):
855 if type(self) != type(other): return False
856 if self.ethertype != other.ethertype: return False
857 return True
858
Rich Lanec2ee4b82013-04-24 17:12:38 -0700859 def pretty_print(self, q):
860 q.text("pop_mpls {")
861 with q.group():
862 with q.indent(2):
863 q.breakable()
864 q.text("ethertype = ");
865 q.text("%#x" % self.ethertype)
866 q.breakable()
867 q.text('}')
868
Rich Lane7dcdf022013-12-11 14:45:27 -0800869action.subtypes[20] = pop_mpls
870
871class pop_pbb(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700872 type = 27
Rich Lanec2ee4b82013-04-24 17:12:38 -0700873
874 def __init__(self):
875 return
876
877 def pack(self):
878 packed = []
879 packed.append(struct.pack("!H", self.type))
880 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
881 packed.append('\x00' * 4)
882 length = sum([len(x) for x in packed])
883 packed[1] = struct.pack("!H", length)
884 return ''.join(packed)
885
886 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800887 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700888 obj = pop_pbb()
Dan Talaycof6202252013-07-02 01:00:29 -0700889 _type = reader.read("!H")[0]
890 assert(_type == 27)
891 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800892 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800893 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700894 reader.skip(4)
895 return obj
896
897 def __eq__(self, other):
898 if type(self) != type(other): return False
899 return True
900
Rich Lanec2ee4b82013-04-24 17:12:38 -0700901 def pretty_print(self, q):
902 q.text("pop_pbb {")
903 with q.group():
904 with q.indent(2):
905 q.breakable()
906 q.breakable()
907 q.text('}')
908
Rich Lane7dcdf022013-12-11 14:45:27 -0800909action.subtypes[27] = pop_pbb
910
911class pop_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700912 type = 18
Rich Lanec2ee4b82013-04-24 17:12:38 -0700913
914 def __init__(self):
915 return
916
917 def pack(self):
918 packed = []
919 packed.append(struct.pack("!H", self.type))
920 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
921 packed.append('\x00' * 4)
922 length = sum([len(x) for x in packed])
923 packed[1] = struct.pack("!H", length)
924 return ''.join(packed)
925
926 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800927 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700928 obj = pop_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -0700929 _type = reader.read("!H")[0]
930 assert(_type == 18)
931 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800932 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800933 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700934 reader.skip(4)
935 return obj
936
937 def __eq__(self, other):
938 if type(self) != type(other): return False
939 return True
940
Rich Lanec2ee4b82013-04-24 17:12:38 -0700941 def pretty_print(self, q):
942 q.text("pop_vlan {")
943 with q.group():
944 with q.indent(2):
945 q.breakable()
946 q.breakable()
947 q.text('}')
948
Rich Lane7dcdf022013-12-11 14:45:27 -0800949action.subtypes[18] = pop_vlan
950
951class push_mpls(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700952 type = 19
Rich Lanec2ee4b82013-04-24 17:12:38 -0700953
954 def __init__(self, ethertype=None):
955 if ethertype != None:
956 self.ethertype = ethertype
957 else:
958 self.ethertype = 0
959 return
960
961 def pack(self):
962 packed = []
963 packed.append(struct.pack("!H", self.type))
964 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
965 packed.append(struct.pack("!H", self.ethertype))
966 packed.append('\x00' * 2)
967 length = sum([len(x) for x in packed])
968 packed[1] = struct.pack("!H", length)
969 return ''.join(packed)
970
971 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800972 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700973 obj = push_mpls()
Dan Talaycof6202252013-07-02 01:00:29 -0700974 _type = reader.read("!H")[0]
975 assert(_type == 19)
976 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800977 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800978 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700979 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700980 reader.skip(2)
981 return obj
982
983 def __eq__(self, other):
984 if type(self) != type(other): return False
985 if self.ethertype != other.ethertype: return False
986 return True
987
Rich Lanec2ee4b82013-04-24 17:12:38 -0700988 def pretty_print(self, q):
989 q.text("push_mpls {")
990 with q.group():
991 with q.indent(2):
992 q.breakable()
993 q.text("ethertype = ");
994 q.text("%#x" % self.ethertype)
995 q.breakable()
996 q.text('}')
997
Rich Lane7dcdf022013-12-11 14:45:27 -0800998action.subtypes[19] = push_mpls
999
1000class push_pbb(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001001 type = 26
Rich Lanec2ee4b82013-04-24 17:12:38 -07001002
1003 def __init__(self, ethertype=None):
1004 if ethertype != None:
1005 self.ethertype = ethertype
1006 else:
1007 self.ethertype = 0
1008 return
1009
1010 def pack(self):
1011 packed = []
1012 packed.append(struct.pack("!H", self.type))
1013 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1014 packed.append(struct.pack("!H", self.ethertype))
1015 packed.append('\x00' * 2)
1016 length = sum([len(x) for x in packed])
1017 packed[1] = struct.pack("!H", length)
1018 return ''.join(packed)
1019
1020 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001021 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001022 obj = push_pbb()
Dan Talaycof6202252013-07-02 01:00:29 -07001023 _type = reader.read("!H")[0]
1024 assert(_type == 26)
1025 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001026 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001027 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001028 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001029 reader.skip(2)
1030 return obj
1031
1032 def __eq__(self, other):
1033 if type(self) != type(other): return False
1034 if self.ethertype != other.ethertype: return False
1035 return True
1036
Rich Lanec2ee4b82013-04-24 17:12:38 -07001037 def pretty_print(self, q):
1038 q.text("push_pbb {")
1039 with q.group():
1040 with q.indent(2):
1041 q.breakable()
1042 q.text("ethertype = ");
1043 q.text("%#x" % self.ethertype)
1044 q.breakable()
1045 q.text('}')
1046
Rich Lane7dcdf022013-12-11 14:45:27 -08001047action.subtypes[26] = push_pbb
1048
1049class push_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001050 type = 17
Rich Lanec2ee4b82013-04-24 17:12:38 -07001051
1052 def __init__(self, ethertype=None):
1053 if ethertype != None:
1054 self.ethertype = ethertype
1055 else:
1056 self.ethertype = 0
1057 return
1058
1059 def pack(self):
1060 packed = []
1061 packed.append(struct.pack("!H", self.type))
1062 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1063 packed.append(struct.pack("!H", self.ethertype))
1064 packed.append('\x00' * 2)
1065 length = sum([len(x) for x in packed])
1066 packed[1] = struct.pack("!H", length)
1067 return ''.join(packed)
1068
1069 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001070 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001071 obj = push_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -07001072 _type = reader.read("!H")[0]
1073 assert(_type == 17)
1074 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001075 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001076 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001077 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001078 reader.skip(2)
1079 return obj
1080
1081 def __eq__(self, other):
1082 if type(self) != type(other): return False
1083 if self.ethertype != other.ethertype: return False
1084 return True
1085
Rich Lanec2ee4b82013-04-24 17:12:38 -07001086 def pretty_print(self, q):
1087 q.text("push_vlan {")
1088 with q.group():
1089 with q.indent(2):
1090 q.breakable()
1091 q.text("ethertype = ");
1092 q.text("%#x" % self.ethertype)
1093 q.breakable()
1094 q.text('}')
1095
Rich Lane7dcdf022013-12-11 14:45:27 -08001096action.subtypes[17] = push_vlan
1097
1098class set_field(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001099 type = 25
Rich Lanec2ee4b82013-04-24 17:12:38 -07001100
1101 def __init__(self, field=None):
1102 if field != None:
1103 self.field = field
1104 else:
Rich Laned53156a2013-08-05 17:17:33 -07001105 self.field = None
Rich Lanec2ee4b82013-04-24 17:12:38 -07001106 return
1107
1108 def pack(self):
1109 packed = []
1110 packed.append(struct.pack("!H", self.type))
1111 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Rich Laned53156a2013-08-05 17:17:33 -07001112 packed.append(self.field.pack())
Rich Lanec2ee4b82013-04-24 17:12:38 -07001113 length = sum([len(x) for x in packed])
Rich Laned53156a2013-08-05 17:17:33 -07001114 packed.append(loxi.generic_util.pad_to(8, length))
1115 length += len(packed[-1])
Rich Lanec2ee4b82013-04-24 17:12:38 -07001116 packed[1] = struct.pack("!H", length)
1117 return ''.join(packed)
1118
1119 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001120 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001121 obj = set_field()
Dan Talaycof6202252013-07-02 01:00:29 -07001122 _type = reader.read("!H")[0]
1123 assert(_type == 25)
1124 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001125 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001126 reader = orig_reader.slice(_len, 4)
Rich Lane7dcdf022013-12-11 14:45:27 -08001127 obj.field = oxm.oxm.unpack(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001128 return obj
1129
1130 def __eq__(self, other):
1131 if type(self) != type(other): return False
1132 if self.field != other.field: return False
1133 return True
1134
Rich Lanec2ee4b82013-04-24 17:12:38 -07001135 def pretty_print(self, q):
1136 q.text("set_field {")
1137 with q.group():
1138 with q.indent(2):
1139 q.breakable()
1140 q.text("field = ");
1141 q.pp(self.field)
1142 q.breakable()
1143 q.text('}')
1144
Rich Lane7dcdf022013-12-11 14:45:27 -08001145action.subtypes[25] = set_field
1146
1147class set_mpls_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001148 type = 15
Rich Lanec2ee4b82013-04-24 17:12:38 -07001149
1150 def __init__(self, mpls_ttl=None):
1151 if mpls_ttl != None:
1152 self.mpls_ttl = mpls_ttl
1153 else:
1154 self.mpls_ttl = 0
1155 return
1156
1157 def pack(self):
1158 packed = []
1159 packed.append(struct.pack("!H", self.type))
1160 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1161 packed.append(struct.pack("!B", self.mpls_ttl))
1162 packed.append('\x00' * 3)
1163 length = sum([len(x) for x in packed])
1164 packed[1] = struct.pack("!H", length)
1165 return ''.join(packed)
1166
1167 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001168 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001169 obj = set_mpls_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -07001170 _type = reader.read("!H")[0]
1171 assert(_type == 15)
1172 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001173 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001174 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001175 obj.mpls_ttl = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001176 reader.skip(3)
1177 return obj
1178
1179 def __eq__(self, other):
1180 if type(self) != type(other): return False
1181 if self.mpls_ttl != other.mpls_ttl: return False
1182 return True
1183
Rich Lanec2ee4b82013-04-24 17:12:38 -07001184 def pretty_print(self, q):
1185 q.text("set_mpls_ttl {")
1186 with q.group():
1187 with q.indent(2):
1188 q.breakable()
1189 q.text("mpls_ttl = ");
1190 q.text("%#x" % self.mpls_ttl)
1191 q.breakable()
1192 q.text('}')
1193
Rich Lane7dcdf022013-12-11 14:45:27 -08001194action.subtypes[15] = set_mpls_ttl
1195
1196class set_nw_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001197 type = 23
Rich Lanec2ee4b82013-04-24 17:12:38 -07001198
1199 def __init__(self, nw_ttl=None):
1200 if nw_ttl != None:
1201 self.nw_ttl = nw_ttl
1202 else:
1203 self.nw_ttl = 0
1204 return
1205
1206 def pack(self):
1207 packed = []
1208 packed.append(struct.pack("!H", self.type))
1209 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1210 packed.append(struct.pack("!B", self.nw_ttl))
1211 packed.append('\x00' * 3)
1212 length = sum([len(x) for x in packed])
1213 packed[1] = struct.pack("!H", length)
1214 return ''.join(packed)
1215
1216 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001217 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001218 obj = set_nw_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -07001219 _type = reader.read("!H")[0]
1220 assert(_type == 23)
1221 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001222 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001223 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001224 obj.nw_ttl = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001225 reader.skip(3)
1226 return obj
1227
1228 def __eq__(self, other):
1229 if type(self) != type(other): return False
1230 if self.nw_ttl != other.nw_ttl: return False
1231 return True
1232
Rich Lanec2ee4b82013-04-24 17:12:38 -07001233 def pretty_print(self, q):
1234 q.text("set_nw_ttl {")
1235 with q.group():
1236 with q.indent(2):
1237 q.breakable()
1238 q.text("nw_ttl = ");
1239 q.text("%#x" % self.nw_ttl)
1240 q.breakable()
1241 q.text('}')
1242
Rich Lane7dcdf022013-12-11 14:45:27 -08001243action.subtypes[23] = set_nw_ttl
1244
1245class set_queue(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001246 type = 21
Rich Lanec2ee4b82013-04-24 17:12:38 -07001247
1248 def __init__(self, queue_id=None):
1249 if queue_id != None:
1250 self.queue_id = queue_id
1251 else:
1252 self.queue_id = 0
1253 return
1254
1255 def pack(self):
1256 packed = []
1257 packed.append(struct.pack("!H", self.type))
1258 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1259 packed.append(struct.pack("!L", self.queue_id))
1260 length = sum([len(x) for x in packed])
1261 packed[1] = struct.pack("!H", length)
1262 return ''.join(packed)
1263
1264 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001265 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001266 obj = set_queue()
Dan Talaycof6202252013-07-02 01:00:29 -07001267 _type = reader.read("!H")[0]
1268 assert(_type == 21)
1269 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001270 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001271 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001272 obj.queue_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001273 return obj
1274
1275 def __eq__(self, other):
1276 if type(self) != type(other): return False
1277 if self.queue_id != other.queue_id: return False
1278 return True
1279
Rich Lanec2ee4b82013-04-24 17:12:38 -07001280 def pretty_print(self, q):
1281 q.text("set_queue {")
1282 with q.group():
1283 with q.indent(2):
1284 q.breakable()
1285 q.text("queue_id = ");
1286 q.text("%#x" % self.queue_id)
1287 q.breakable()
1288 q.text('}')
1289
Rich Lane7dcdf022013-12-11 14:45:27 -08001290action.subtypes[21] = set_queue
Rich Lanec2ee4b82013-04-24 17:12:38 -07001291
Rich Lanec2ee4b82013-04-24 17:12:38 -07001292