blob: 06f669507a3c00ebd5e2fdaa3d5f1f7004f29a70 [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
Rich Lane7dcdf022013-12-11 14:45:27 -080012import common
13import action
14import instruction
Rich Lanec2ee4b82013-04-24 17:12:38 -070015import util
16import loxi.generic_util
Rich Lanec2ee4b82013-04-24 17:12:38 -070017
Rich Lane7dcdf022013-12-11 14:45:27 -080018class action(loxi.OFObject):
19 subtypes = {}
Rich Lanec2ee4b82013-04-24 17:12:38 -070020
Rich Lane7dcdf022013-12-11 14:45:27 -080021 @staticmethod
22 def unpack(reader):
23 subtype, = reader.peek('!H', 0)
24 try:
25 subclass = action.subtypes[subtype]
26 except KeyError:
27 raise loxi.ProtocolError("unknown action subtype %#x" % subtype)
28 return subclass.unpack(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -070029
Rich Lane7dcdf022013-12-11 14:45:27 -080030
31class experimenter(action):
32 subtypes = {}
33
34 @staticmethod
35 def unpack(reader):
36 subtype, = reader.peek('!L', 4)
37 try:
38 subclass = experimenter.subtypes[subtype]
39 except KeyError:
40 raise loxi.ProtocolError("unknown experimenter action subtype %#x" % subtype)
41 return subclass.unpack(reader)
42
43action.subtypes[65535] = experimenter
44
45class bsn(experimenter):
46 subtypes = {}
47
48 @staticmethod
49 def unpack(reader):
50 subtype, = reader.peek('!L', 8)
51 try:
52 subclass = bsn.subtypes[subtype]
53 except KeyError:
54 raise loxi.ProtocolError("unknown bsn experimenter action subtype %#x" % subtype)
55 return subclass.unpack(reader)
56
57experimenter.subtypes[6035143] = bsn
58
59class bsn_mirror(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -070060 type = 65535
61 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -070062 subtype = 1
63
64 def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None):
65 if dest_port != None:
66 self.dest_port = dest_port
67 else:
68 self.dest_port = 0
69 if vlan_tag != None:
70 self.vlan_tag = vlan_tag
71 else:
72 self.vlan_tag = 0
73 if copy_stage != None:
74 self.copy_stage = copy_stage
75 else:
76 self.copy_stage = 0
77 return
78
79 def pack(self):
80 packed = []
81 packed.append(struct.pack("!H", self.type))
82 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
83 packed.append(struct.pack("!L", self.experimenter))
84 packed.append(struct.pack("!L", self.subtype))
85 packed.append(struct.pack("!L", self.dest_port))
86 packed.append(struct.pack("!L", self.vlan_tag))
87 packed.append(struct.pack("!B", self.copy_stage))
88 packed.append('\x00' * 3)
89 length = sum([len(x) for x in packed])
90 packed[1] = struct.pack("!H", length)
91 return ''.join(packed)
92
93 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -080094 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -070095 obj = bsn_mirror()
Dan Talaycof6202252013-07-02 01:00:29 -070096 _type = reader.read("!H")[0]
97 assert(_type == 65535)
98 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -080099 orig_reader = reader
100 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700101 _experimenter = reader.read("!L")[0]
102 assert(_experimenter == 6035143)
103 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700104 assert(_subtype == 1)
Dan Talaycof6202252013-07-02 01:00:29 -0700105 obj.dest_port = reader.read("!L")[0]
106 obj.vlan_tag = reader.read("!L")[0]
107 obj.copy_stage = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700108 reader.skip(3)
109 return obj
110
111 def __eq__(self, other):
112 if type(self) != type(other): return False
113 if self.dest_port != other.dest_port: return False
114 if self.vlan_tag != other.vlan_tag: return False
115 if self.copy_stage != other.copy_stage: return False
116 return True
117
Rich Lanec2ee4b82013-04-24 17:12:38 -0700118 def pretty_print(self, q):
119 q.text("bsn_mirror {")
120 with q.group():
121 with q.indent(2):
122 q.breakable()
123 q.text("dest_port = ");
124 q.text("%#x" % self.dest_port)
125 q.text(","); q.breakable()
126 q.text("vlan_tag = ");
127 q.text("%#x" % self.vlan_tag)
128 q.text(","); q.breakable()
129 q.text("copy_stage = ");
130 q.text("%#x" % self.copy_stage)
131 q.breakable()
132 q.text('}')
133
Rich Lane7dcdf022013-12-11 14:45:27 -0800134bsn.subtypes[1] = bsn_mirror
135
136class bsn_set_tunnel_dst(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700137 type = 65535
138 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -0700139 subtype = 2
140
141 def __init__(self, dst=None):
142 if dst != None:
143 self.dst = dst
144 else:
145 self.dst = 0
146 return
147
148 def pack(self):
149 packed = []
150 packed.append(struct.pack("!H", self.type))
151 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
152 packed.append(struct.pack("!L", self.experimenter))
153 packed.append(struct.pack("!L", self.subtype))
154 packed.append(struct.pack("!L", self.dst))
155 length = sum([len(x) for x in packed])
156 packed[1] = struct.pack("!H", length)
157 return ''.join(packed)
158
159 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800160 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700161 obj = bsn_set_tunnel_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700162 _type = reader.read("!H")[0]
163 assert(_type == 65535)
164 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800165 orig_reader = reader
166 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700167 _experimenter = reader.read("!L")[0]
168 assert(_experimenter == 6035143)
169 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700170 assert(_subtype == 2)
Dan Talaycof6202252013-07-02 01:00:29 -0700171 obj.dst = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700172 return obj
173
174 def __eq__(self, other):
175 if type(self) != type(other): return False
176 if self.dst != other.dst: return False
177 return True
178
Rich Lanec2ee4b82013-04-24 17:12:38 -0700179 def pretty_print(self, q):
180 q.text("bsn_set_tunnel_dst {")
181 with q.group():
182 with q.indent(2):
183 q.breakable()
184 q.text("dst = ");
185 q.text("%#x" % self.dst)
186 q.breakable()
187 q.text('}')
188
Rich Lane7dcdf022013-12-11 14:45:27 -0800189bsn.subtypes[2] = bsn_set_tunnel_dst
190
191class copy_ttl_in(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700192 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -0700193
194 def __init__(self):
195 return
196
197 def pack(self):
198 packed = []
199 packed.append(struct.pack("!H", self.type))
200 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
201 packed.append('\x00' * 4)
202 length = sum([len(x) for x in packed])
203 packed[1] = struct.pack("!H", length)
204 return ''.join(packed)
205
206 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800207 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700208 obj = copy_ttl_in()
Dan Talaycof6202252013-07-02 01:00:29 -0700209 _type = reader.read("!H")[0]
210 assert(_type == 12)
211 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800212 orig_reader = reader
213 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700214 reader.skip(4)
215 return obj
216
217 def __eq__(self, other):
218 if type(self) != type(other): return False
219 return True
220
Rich Lanec2ee4b82013-04-24 17:12:38 -0700221 def pretty_print(self, q):
222 q.text("copy_ttl_in {")
223 with q.group():
224 with q.indent(2):
225 q.breakable()
226 q.breakable()
227 q.text('}')
228
Rich Lane7dcdf022013-12-11 14:45:27 -0800229action.subtypes[12] = copy_ttl_in
230
231class copy_ttl_out(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700232 type = 11
Rich Lanec2ee4b82013-04-24 17:12:38 -0700233
234 def __init__(self):
235 return
236
237 def pack(self):
238 packed = []
239 packed.append(struct.pack("!H", self.type))
240 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
241 packed.append('\x00' * 4)
242 length = sum([len(x) for x in packed])
243 packed[1] = struct.pack("!H", length)
244 return ''.join(packed)
245
246 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800247 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700248 obj = copy_ttl_out()
Dan Talaycof6202252013-07-02 01:00:29 -0700249 _type = reader.read("!H")[0]
250 assert(_type == 11)
251 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800252 orig_reader = reader
253 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700254 reader.skip(4)
255 return obj
256
257 def __eq__(self, other):
258 if type(self) != type(other): return False
259 return True
260
Rich Lanec2ee4b82013-04-24 17:12:38 -0700261 def pretty_print(self, q):
262 q.text("copy_ttl_out {")
263 with q.group():
264 with q.indent(2):
265 q.breakable()
266 q.breakable()
267 q.text('}')
268
Rich Lane7dcdf022013-12-11 14:45:27 -0800269action.subtypes[11] = copy_ttl_out
270
271class dec_mpls_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700272 type = 16
Rich Lanec2ee4b82013-04-24 17:12:38 -0700273
274 def __init__(self):
275 return
276
277 def pack(self):
278 packed = []
279 packed.append(struct.pack("!H", self.type))
280 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
281 packed.append('\x00' * 4)
282 length = sum([len(x) for x in packed])
283 packed[1] = struct.pack("!H", length)
284 return ''.join(packed)
285
286 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800287 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700288 obj = dec_mpls_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700289 _type = reader.read("!H")[0]
290 assert(_type == 16)
291 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800292 orig_reader = reader
293 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700294 reader.skip(4)
295 return obj
296
297 def __eq__(self, other):
298 if type(self) != type(other): return False
299 return True
300
Rich Lanec2ee4b82013-04-24 17:12:38 -0700301 def pretty_print(self, q):
302 q.text("dec_mpls_ttl {")
303 with q.group():
304 with q.indent(2):
305 q.breakable()
306 q.breakable()
307 q.text('}')
308
Rich Lane7dcdf022013-12-11 14:45:27 -0800309action.subtypes[16] = dec_mpls_ttl
310
311class dec_nw_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700312 type = 24
Rich Lanec2ee4b82013-04-24 17:12:38 -0700313
314 def __init__(self):
315 return
316
317 def pack(self):
318 packed = []
319 packed.append(struct.pack("!H", self.type))
320 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
321 packed.append('\x00' * 4)
322 length = sum([len(x) for x in packed])
323 packed[1] = struct.pack("!H", length)
324 return ''.join(packed)
325
326 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800327 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700328 obj = dec_nw_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700329 _type = reader.read("!H")[0]
330 assert(_type == 24)
331 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800332 orig_reader = reader
333 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700334 reader.skip(4)
335 return obj
336
337 def __eq__(self, other):
338 if type(self) != type(other): return False
339 return True
340
Rich Lanec2ee4b82013-04-24 17:12:38 -0700341 def pretty_print(self, q):
342 q.text("dec_nw_ttl {")
343 with q.group():
344 with q.indent(2):
345 q.breakable()
346 q.breakable()
347 q.text('}')
348
Rich Lane7dcdf022013-12-11 14:45:27 -0800349action.subtypes[24] = dec_nw_ttl
350
351class group(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700352 type = 22
Rich Lanec2ee4b82013-04-24 17:12:38 -0700353
354 def __init__(self, group_id=None):
355 if group_id != None:
356 self.group_id = group_id
357 else:
358 self.group_id = 0
359 return
360
361 def pack(self):
362 packed = []
363 packed.append(struct.pack("!H", self.type))
364 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
365 packed.append(struct.pack("!L", self.group_id))
366 length = sum([len(x) for x in packed])
367 packed[1] = struct.pack("!H", length)
368 return ''.join(packed)
369
370 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800371 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700372 obj = group()
Dan Talaycof6202252013-07-02 01:00:29 -0700373 _type = reader.read("!H")[0]
374 assert(_type == 22)
375 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800376 orig_reader = reader
377 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700378 obj.group_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700379 return obj
380
381 def __eq__(self, other):
382 if type(self) != type(other): return False
383 if self.group_id != other.group_id: return False
384 return True
385
Rich Lanec2ee4b82013-04-24 17:12:38 -0700386 def pretty_print(self, q):
387 q.text("group {")
388 with q.group():
389 with q.indent(2):
390 q.breakable()
391 q.text("group_id = ");
392 q.text("%#x" % self.group_id)
393 q.breakable()
394 q.text('}')
395
Rich Lane7dcdf022013-12-11 14:45:27 -0800396action.subtypes[22] = group
397
398class nicira(experimenter):
399 subtypes = {}
400
401 @staticmethod
402 def unpack(reader):
403 subtype, = reader.peek('!H', 8)
404 try:
405 subclass = nicira.subtypes[subtype]
406 except KeyError:
407 raise loxi.ProtocolError("unknown nicira experimenter action subtype %#x" % subtype)
408 return subclass.unpack(reader)
409
410experimenter.subtypes[8992] = nicira
411
412class nicira_dec_ttl(nicira):
Dan Talaycof6202252013-07-02 01:00:29 -0700413 type = 65535
414 experimenter = 8992
Rich Lanec2ee4b82013-04-24 17:12:38 -0700415 subtype = 18
416
417 def __init__(self):
418 return
419
420 def pack(self):
421 packed = []
422 packed.append(struct.pack("!H", self.type))
423 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
424 packed.append(struct.pack("!L", self.experimenter))
425 packed.append(struct.pack("!H", self.subtype))
426 packed.append('\x00' * 2)
427 packed.append('\x00' * 4)
428 length = sum([len(x) for x in packed])
429 packed[1] = struct.pack("!H", length)
430 return ''.join(packed)
431
432 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800433 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700434 obj = nicira_dec_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700435 _type = reader.read("!H")[0]
436 assert(_type == 65535)
437 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800438 orig_reader = reader
439 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700440 _experimenter = reader.read("!L")[0]
441 assert(_experimenter == 8992)
442 _subtype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700443 assert(_subtype == 18)
444 reader.skip(2)
445 reader.skip(4)
446 return obj
447
448 def __eq__(self, other):
449 if type(self) != type(other): return False
450 return True
451
Rich Lanec2ee4b82013-04-24 17:12:38 -0700452 def pretty_print(self, q):
453 q.text("nicira_dec_ttl {")
454 with q.group():
455 with q.indent(2):
456 q.breakable()
457 q.breakable()
458 q.text('}')
459
Rich Lane7dcdf022013-12-11 14:45:27 -0800460nicira.subtypes[18] = nicira_dec_ttl
461
462class output(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700463 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700464
465 def __init__(self, port=None, max_len=None):
466 if port != None:
467 self.port = port
468 else:
469 self.port = 0
470 if max_len != None:
471 self.max_len = max_len
472 else:
473 self.max_len = 0
474 return
475
476 def pack(self):
477 packed = []
478 packed.append(struct.pack("!H", self.type))
479 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700480 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700481 packed.append(struct.pack("!H", self.max_len))
482 packed.append('\x00' * 6)
483 length = sum([len(x) for x in packed])
484 packed[1] = struct.pack("!H", length)
485 return ''.join(packed)
486
487 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800488 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700489 obj = output()
Dan Talaycof6202252013-07-02 01:00:29 -0700490 _type = reader.read("!H")[0]
491 assert(_type == 0)
492 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800493 orig_reader = reader
494 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700495 obj.port = util.unpack_port_no(reader)
496 obj.max_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700497 reader.skip(6)
498 return obj
499
500 def __eq__(self, other):
501 if type(self) != type(other): return False
502 if self.port != other.port: return False
503 if self.max_len != other.max_len: return False
504 return True
505
Rich Lanec2ee4b82013-04-24 17:12:38 -0700506 def pretty_print(self, q):
507 q.text("output {")
508 with q.group():
509 with q.indent(2):
510 q.breakable()
511 q.text("port = ");
512 q.text(util.pretty_port(self.port))
513 q.text(","); q.breakable()
514 q.text("max_len = ");
515 q.text("%#x" % self.max_len)
516 q.breakable()
517 q.text('}')
518
Rich Lane7dcdf022013-12-11 14:45:27 -0800519action.subtypes[0] = output
520
521class pop_mpls(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700522 type = 20
Rich Lanec2ee4b82013-04-24 17:12:38 -0700523
524 def __init__(self, ethertype=None):
525 if ethertype != None:
526 self.ethertype = ethertype
527 else:
528 self.ethertype = 0
529 return
530
531 def pack(self):
532 packed = []
533 packed.append(struct.pack("!H", self.type))
534 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
535 packed.append(struct.pack("!H", self.ethertype))
536 packed.append('\x00' * 2)
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 = pop_mpls()
Dan Talaycof6202252013-07-02 01:00:29 -0700544 _type = reader.read("!H")[0]
545 assert(_type == 20)
546 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800547 orig_reader = reader
548 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700549 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700550 reader.skip(2)
551 return obj
552
553 def __eq__(self, other):
554 if type(self) != type(other): return False
555 if self.ethertype != other.ethertype: return False
556 return True
557
Rich Lanec2ee4b82013-04-24 17:12:38 -0700558 def pretty_print(self, q):
559 q.text("pop_mpls {")
560 with q.group():
561 with q.indent(2):
562 q.breakable()
563 q.text("ethertype = ");
564 q.text("%#x" % self.ethertype)
565 q.breakable()
566 q.text('}')
567
Rich Lane7dcdf022013-12-11 14:45:27 -0800568action.subtypes[20] = pop_mpls
569
570class pop_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700571 type = 18
Rich Lanec2ee4b82013-04-24 17:12:38 -0700572
573 def __init__(self):
574 return
575
576 def pack(self):
577 packed = []
578 packed.append(struct.pack("!H", self.type))
579 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
580 packed.append('\x00' * 4)
581 length = sum([len(x) for x in packed])
582 packed[1] = struct.pack("!H", length)
583 return ''.join(packed)
584
585 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800586 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700587 obj = pop_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -0700588 _type = reader.read("!H")[0]
589 assert(_type == 18)
590 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800591 orig_reader = reader
592 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700593 reader.skip(4)
594 return obj
595
596 def __eq__(self, other):
597 if type(self) != type(other): return False
598 return True
599
Rich Lanec2ee4b82013-04-24 17:12:38 -0700600 def pretty_print(self, q):
601 q.text("pop_vlan {")
602 with q.group():
603 with q.indent(2):
604 q.breakable()
605 q.breakable()
606 q.text('}')
607
Rich Lane7dcdf022013-12-11 14:45:27 -0800608action.subtypes[18] = pop_vlan
609
610class push_mpls(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700611 type = 19
Rich Lanec2ee4b82013-04-24 17:12:38 -0700612
613 def __init__(self, ethertype=None):
614 if ethertype != None:
615 self.ethertype = ethertype
616 else:
617 self.ethertype = 0
618 return
619
620 def pack(self):
621 packed = []
622 packed.append(struct.pack("!H", self.type))
623 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
624 packed.append(struct.pack("!H", self.ethertype))
625 packed.append('\x00' * 2)
626 length = sum([len(x) for x in packed])
627 packed[1] = struct.pack("!H", length)
628 return ''.join(packed)
629
630 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800631 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700632 obj = push_mpls()
Dan Talaycof6202252013-07-02 01:00:29 -0700633 _type = reader.read("!H")[0]
634 assert(_type == 19)
635 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800636 orig_reader = reader
637 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700638 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700639 reader.skip(2)
640 return obj
641
642 def __eq__(self, other):
643 if type(self) != type(other): return False
644 if self.ethertype != other.ethertype: return False
645 return True
646
Rich Lanec2ee4b82013-04-24 17:12:38 -0700647 def pretty_print(self, q):
648 q.text("push_mpls {")
649 with q.group():
650 with q.indent(2):
651 q.breakable()
652 q.text("ethertype = ");
653 q.text("%#x" % self.ethertype)
654 q.breakable()
655 q.text('}')
656
Rich Lane7dcdf022013-12-11 14:45:27 -0800657action.subtypes[19] = push_mpls
658
659class push_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700660 type = 17
Rich Lanec2ee4b82013-04-24 17:12:38 -0700661
662 def __init__(self, ethertype=None):
663 if ethertype != None:
664 self.ethertype = ethertype
665 else:
666 self.ethertype = 0
667 return
668
669 def pack(self):
670 packed = []
671 packed.append(struct.pack("!H", self.type))
672 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
673 packed.append(struct.pack("!H", self.ethertype))
674 packed.append('\x00' * 2)
675 length = sum([len(x) for x in packed])
676 packed[1] = struct.pack("!H", length)
677 return ''.join(packed)
678
679 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800680 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700681 obj = push_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -0700682 _type = reader.read("!H")[0]
683 assert(_type == 17)
684 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800685 orig_reader = reader
686 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700687 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700688 reader.skip(2)
689 return obj
690
691 def __eq__(self, other):
692 if type(self) != type(other): return False
693 if self.ethertype != other.ethertype: return False
694 return True
695
Rich Lanec2ee4b82013-04-24 17:12:38 -0700696 def pretty_print(self, q):
697 q.text("push_vlan {")
698 with q.group():
699 with q.indent(2):
700 q.breakable()
701 q.text("ethertype = ");
702 q.text("%#x" % self.ethertype)
703 q.breakable()
704 q.text('}')
705
Rich Lane7dcdf022013-12-11 14:45:27 -0800706action.subtypes[17] = push_vlan
707
708class set_dl_dst(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700709 type = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -0700710
711 def __init__(self, dl_addr=None):
712 if dl_addr != None:
713 self.dl_addr = dl_addr
714 else:
715 self.dl_addr = [0,0,0,0,0,0]
716 return
717
718 def pack(self):
719 packed = []
720 packed.append(struct.pack("!H", self.type))
721 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
722 packed.append(struct.pack("!6B", *self.dl_addr))
723 packed.append('\x00' * 6)
724 length = sum([len(x) for x in packed])
725 packed[1] = struct.pack("!H", length)
726 return ''.join(packed)
727
728 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800729 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700730 obj = set_dl_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700731 _type = reader.read("!H")[0]
732 assert(_type == 4)
733 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800734 orig_reader = reader
735 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700736 obj.dl_addr = list(reader.read('!6B'))
737 reader.skip(6)
738 return obj
739
740 def __eq__(self, other):
741 if type(self) != type(other): return False
742 if self.dl_addr != other.dl_addr: return False
743 return True
744
Rich Lanec2ee4b82013-04-24 17:12:38 -0700745 def pretty_print(self, q):
746 q.text("set_dl_dst {")
747 with q.group():
748 with q.indent(2):
749 q.breakable()
750 q.text("dl_addr = ");
751 q.text(util.pretty_mac(self.dl_addr))
752 q.breakable()
753 q.text('}')
754
Rich Lane7dcdf022013-12-11 14:45:27 -0800755action.subtypes[4] = set_dl_dst
756
757class set_dl_src(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700758 type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -0700759
760 def __init__(self, dl_addr=None):
761 if dl_addr != None:
762 self.dl_addr = dl_addr
763 else:
764 self.dl_addr = [0,0,0,0,0,0]
765 return
766
767 def pack(self):
768 packed = []
769 packed.append(struct.pack("!H", self.type))
770 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
771 packed.append(struct.pack("!6B", *self.dl_addr))
772 packed.append('\x00' * 6)
773 length = sum([len(x) for x in packed])
774 packed[1] = struct.pack("!H", length)
775 return ''.join(packed)
776
777 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800778 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700779 obj = set_dl_src()
Dan Talaycof6202252013-07-02 01:00:29 -0700780 _type = reader.read("!H")[0]
781 assert(_type == 3)
782 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800783 orig_reader = reader
784 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700785 obj.dl_addr = list(reader.read('!6B'))
786 reader.skip(6)
787 return obj
788
789 def __eq__(self, other):
790 if type(self) != type(other): return False
791 if self.dl_addr != other.dl_addr: return False
792 return True
793
Rich Lanec2ee4b82013-04-24 17:12:38 -0700794 def pretty_print(self, q):
795 q.text("set_dl_src {")
796 with q.group():
797 with q.indent(2):
798 q.breakable()
799 q.text("dl_addr = ");
800 q.text(util.pretty_mac(self.dl_addr))
801 q.breakable()
802 q.text('}')
803
Rich Lane7dcdf022013-12-11 14:45:27 -0800804action.subtypes[3] = set_dl_src
805
806class set_mpls_label(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700807 type = 13
Rich Lanec2ee4b82013-04-24 17:12:38 -0700808
809 def __init__(self, mpls_label=None):
810 if mpls_label != None:
811 self.mpls_label = mpls_label
812 else:
813 self.mpls_label = 0
814 return
815
816 def pack(self):
817 packed = []
818 packed.append(struct.pack("!H", self.type))
819 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
820 packed.append(struct.pack("!L", self.mpls_label))
821 length = sum([len(x) for x in packed])
822 packed[1] = struct.pack("!H", length)
823 return ''.join(packed)
824
825 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800826 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700827 obj = set_mpls_label()
Dan Talaycof6202252013-07-02 01:00:29 -0700828 _type = reader.read("!H")[0]
829 assert(_type == 13)
830 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800831 orig_reader = reader
832 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700833 obj.mpls_label = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700834 return obj
835
836 def __eq__(self, other):
837 if type(self) != type(other): return False
838 if self.mpls_label != other.mpls_label: return False
839 return True
840
Rich Lanec2ee4b82013-04-24 17:12:38 -0700841 def pretty_print(self, q):
842 q.text("set_mpls_label {")
843 with q.group():
844 with q.indent(2):
845 q.breakable()
846 q.text("mpls_label = ");
847 q.text("%#x" % self.mpls_label)
848 q.breakable()
849 q.text('}')
850
Rich Lane7dcdf022013-12-11 14:45:27 -0800851action.subtypes[13] = set_mpls_label
852
853class set_mpls_tc(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700854 type = 14
Rich Lanec2ee4b82013-04-24 17:12:38 -0700855
856 def __init__(self, mpls_tc=None):
857 if mpls_tc != None:
858 self.mpls_tc = mpls_tc
859 else:
860 self.mpls_tc = 0
861 return
862
863 def pack(self):
864 packed = []
865 packed.append(struct.pack("!H", self.type))
866 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
867 packed.append(struct.pack("!B", self.mpls_tc))
868 packed.append('\x00' * 3)
869 length = sum([len(x) for x in packed])
870 packed[1] = struct.pack("!H", length)
871 return ''.join(packed)
872
873 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800874 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700875 obj = set_mpls_tc()
Dan Talaycof6202252013-07-02 01:00:29 -0700876 _type = reader.read("!H")[0]
877 assert(_type == 14)
878 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800879 orig_reader = reader
880 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700881 obj.mpls_tc = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700882 reader.skip(3)
883 return obj
884
885 def __eq__(self, other):
886 if type(self) != type(other): return False
887 if self.mpls_tc != other.mpls_tc: return False
888 return True
889
Rich Lanec2ee4b82013-04-24 17:12:38 -0700890 def pretty_print(self, q):
891 q.text("set_mpls_tc {")
892 with q.group():
893 with q.indent(2):
894 q.breakable()
895 q.text("mpls_tc = ");
896 q.text("%#x" % self.mpls_tc)
897 q.breakable()
898 q.text('}')
899
Rich Lane7dcdf022013-12-11 14:45:27 -0800900action.subtypes[14] = set_mpls_tc
901
902class set_mpls_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700903 type = 15
Rich Lanec2ee4b82013-04-24 17:12:38 -0700904
905 def __init__(self, mpls_ttl=None):
906 if mpls_ttl != None:
907 self.mpls_ttl = mpls_ttl
908 else:
909 self.mpls_ttl = 0
910 return
911
912 def pack(self):
913 packed = []
914 packed.append(struct.pack("!H", self.type))
915 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
916 packed.append(struct.pack("!B", self.mpls_ttl))
917 packed.append('\x00' * 3)
918 length = sum([len(x) for x in packed])
919 packed[1] = struct.pack("!H", length)
920 return ''.join(packed)
921
922 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800923 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700924 obj = set_mpls_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700925 _type = reader.read("!H")[0]
926 assert(_type == 15)
927 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800928 orig_reader = reader
929 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700930 obj.mpls_ttl = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700931 reader.skip(3)
932 return obj
933
934 def __eq__(self, other):
935 if type(self) != type(other): return False
936 if self.mpls_ttl != other.mpls_ttl: return False
937 return True
938
Rich Lanec2ee4b82013-04-24 17:12:38 -0700939 def pretty_print(self, q):
940 q.text("set_mpls_ttl {")
941 with q.group():
942 with q.indent(2):
943 q.breakable()
944 q.text("mpls_ttl = ");
945 q.text("%#x" % self.mpls_ttl)
946 q.breakable()
947 q.text('}')
948
Rich Lane7dcdf022013-12-11 14:45:27 -0800949action.subtypes[15] = set_mpls_ttl
950
951class set_nw_dst(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700952 type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -0700953
954 def __init__(self, nw_addr=None):
955 if nw_addr != None:
956 self.nw_addr = nw_addr
957 else:
958 self.nw_addr = 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("!L", self.nw_addr))
966 length = sum([len(x) for x in packed])
967 packed[1] = struct.pack("!H", length)
968 return ''.join(packed)
969
970 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800971 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700972 obj = set_nw_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700973 _type = reader.read("!H")[0]
974 assert(_type == 6)
975 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800976 orig_reader = reader
977 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700978 obj.nw_addr = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700979 return obj
980
981 def __eq__(self, other):
982 if type(self) != type(other): return False
983 if self.nw_addr != other.nw_addr: return False
984 return True
985
Rich Lanec2ee4b82013-04-24 17:12:38 -0700986 def pretty_print(self, q):
987 q.text("set_nw_dst {")
988 with q.group():
989 with q.indent(2):
990 q.breakable()
991 q.text("nw_addr = ");
992 q.text("%#x" % self.nw_addr)
993 q.breakable()
994 q.text('}')
995
Rich Lane7dcdf022013-12-11 14:45:27 -0800996action.subtypes[6] = set_nw_dst
997
998class set_nw_ecn(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700999 type = 8
Rich Lanec2ee4b82013-04-24 17:12:38 -07001000
1001 def __init__(self, nw_ecn=None):
1002 if nw_ecn != None:
1003 self.nw_ecn = nw_ecn
1004 else:
1005 self.nw_ecn = 0
1006 return
1007
1008 def pack(self):
1009 packed = []
1010 packed.append(struct.pack("!H", self.type))
1011 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1012 packed.append(struct.pack("!B", self.nw_ecn))
1013 packed.append('\x00' * 3)
1014 length = sum([len(x) for x in packed])
1015 packed[1] = struct.pack("!H", length)
1016 return ''.join(packed)
1017
1018 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001019 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001020 obj = set_nw_ecn()
Dan Talaycof6202252013-07-02 01:00:29 -07001021 _type = reader.read("!H")[0]
1022 assert(_type == 8)
1023 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001024 orig_reader = reader
1025 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001026 obj.nw_ecn = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001027 reader.skip(3)
1028 return obj
1029
1030 def __eq__(self, other):
1031 if type(self) != type(other): return False
1032 if self.nw_ecn != other.nw_ecn: return False
1033 return True
1034
Rich Lanec2ee4b82013-04-24 17:12:38 -07001035 def pretty_print(self, q):
1036 q.text("set_nw_ecn {")
1037 with q.group():
1038 with q.indent(2):
1039 q.breakable()
1040 q.text("nw_ecn = ");
1041 q.text("%#x" % self.nw_ecn)
1042 q.breakable()
1043 q.text('}')
1044
Rich Lane7dcdf022013-12-11 14:45:27 -08001045action.subtypes[8] = set_nw_ecn
1046
1047class set_nw_src(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001048 type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07001049
1050 def __init__(self, nw_addr=None):
1051 if nw_addr != None:
1052 self.nw_addr = nw_addr
1053 else:
1054 self.nw_addr = 0
1055 return
1056
1057 def pack(self):
1058 packed = []
1059 packed.append(struct.pack("!H", self.type))
1060 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1061 packed.append(struct.pack("!L", self.nw_addr))
1062 length = sum([len(x) for x in packed])
1063 packed[1] = struct.pack("!H", length)
1064 return ''.join(packed)
1065
1066 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001067 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001068 obj = set_nw_src()
Dan Talaycof6202252013-07-02 01:00:29 -07001069 _type = reader.read("!H")[0]
1070 assert(_type == 5)
1071 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001072 orig_reader = reader
1073 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001074 obj.nw_addr = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001075 return obj
1076
1077 def __eq__(self, other):
1078 if type(self) != type(other): return False
1079 if self.nw_addr != other.nw_addr: return False
1080 return True
1081
Rich Lanec2ee4b82013-04-24 17:12:38 -07001082 def pretty_print(self, q):
1083 q.text("set_nw_src {")
1084 with q.group():
1085 with q.indent(2):
1086 q.breakable()
1087 q.text("nw_addr = ");
1088 q.text("%#x" % self.nw_addr)
1089 q.breakable()
1090 q.text('}')
1091
Rich Lane7dcdf022013-12-11 14:45:27 -08001092action.subtypes[5] = set_nw_src
1093
1094class set_nw_tos(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001095 type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07001096
1097 def __init__(self, nw_tos=None):
1098 if nw_tos != None:
1099 self.nw_tos = nw_tos
1100 else:
1101 self.nw_tos = 0
1102 return
1103
1104 def pack(self):
1105 packed = []
1106 packed.append(struct.pack("!H", self.type))
1107 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1108 packed.append(struct.pack("!B", self.nw_tos))
1109 packed.append('\x00' * 3)
1110 length = sum([len(x) for x in packed])
1111 packed[1] = struct.pack("!H", length)
1112 return ''.join(packed)
1113
1114 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001115 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001116 obj = set_nw_tos()
Dan Talaycof6202252013-07-02 01:00:29 -07001117 _type = reader.read("!H")[0]
1118 assert(_type == 7)
1119 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001120 orig_reader = reader
1121 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001122 obj.nw_tos = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001123 reader.skip(3)
1124 return obj
1125
1126 def __eq__(self, other):
1127 if type(self) != type(other): return False
1128 if self.nw_tos != other.nw_tos: return False
1129 return True
1130
Rich Lanec2ee4b82013-04-24 17:12:38 -07001131 def pretty_print(self, q):
1132 q.text("set_nw_tos {")
1133 with q.group():
1134 with q.indent(2):
1135 q.breakable()
1136 q.text("nw_tos = ");
1137 q.text("%#x" % self.nw_tos)
1138 q.breakable()
1139 q.text('}')
1140
Rich Lane7dcdf022013-12-11 14:45:27 -08001141action.subtypes[7] = set_nw_tos
1142
1143class set_nw_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001144 type = 23
Rich Lanec2ee4b82013-04-24 17:12:38 -07001145
1146 def __init__(self, nw_ttl=None):
1147 if nw_ttl != None:
1148 self.nw_ttl = nw_ttl
1149 else:
1150 self.nw_ttl = 0
1151 return
1152
1153 def pack(self):
1154 packed = []
1155 packed.append(struct.pack("!H", self.type))
1156 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1157 packed.append(struct.pack("!B", self.nw_ttl))
1158 packed.append('\x00' * 3)
1159 length = sum([len(x) for x in packed])
1160 packed[1] = struct.pack("!H", length)
1161 return ''.join(packed)
1162
1163 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001164 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001165 obj = set_nw_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -07001166 _type = reader.read("!H")[0]
1167 assert(_type == 23)
1168 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001169 orig_reader = reader
1170 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001171 obj.nw_ttl = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001172 reader.skip(3)
1173 return obj
1174
1175 def __eq__(self, other):
1176 if type(self) != type(other): return False
1177 if self.nw_ttl != other.nw_ttl: return False
1178 return True
1179
Rich Lanec2ee4b82013-04-24 17:12:38 -07001180 def pretty_print(self, q):
1181 q.text("set_nw_ttl {")
1182 with q.group():
1183 with q.indent(2):
1184 q.breakable()
1185 q.text("nw_ttl = ");
1186 q.text("%#x" % self.nw_ttl)
1187 q.breakable()
1188 q.text('}')
1189
Rich Lane7dcdf022013-12-11 14:45:27 -08001190action.subtypes[23] = set_nw_ttl
1191
1192class set_queue(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001193 type = 21
Rich Lanec2ee4b82013-04-24 17:12:38 -07001194
1195 def __init__(self, queue_id=None):
1196 if queue_id != None:
1197 self.queue_id = queue_id
1198 else:
1199 self.queue_id = 0
1200 return
1201
1202 def pack(self):
1203 packed = []
1204 packed.append(struct.pack("!H", self.type))
1205 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1206 packed.append(struct.pack("!L", self.queue_id))
1207 length = sum([len(x) for x in packed])
1208 packed[1] = struct.pack("!H", length)
1209 return ''.join(packed)
1210
1211 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001212 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001213 obj = set_queue()
Dan Talaycof6202252013-07-02 01:00:29 -07001214 _type = reader.read("!H")[0]
1215 assert(_type == 21)
1216 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001217 orig_reader = reader
1218 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001219 obj.queue_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001220 return obj
1221
1222 def __eq__(self, other):
1223 if type(self) != type(other): return False
1224 if self.queue_id != other.queue_id: return False
1225 return True
1226
Rich Lanec2ee4b82013-04-24 17:12:38 -07001227 def pretty_print(self, q):
1228 q.text("set_queue {")
1229 with q.group():
1230 with q.indent(2):
1231 q.breakable()
1232 q.text("queue_id = ");
1233 q.text("%#x" % self.queue_id)
1234 q.breakable()
1235 q.text('}')
1236
Rich Lane7dcdf022013-12-11 14:45:27 -08001237action.subtypes[21] = set_queue
1238
1239class set_tp_dst(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001240 type = 10
Rich Lanec2ee4b82013-04-24 17:12:38 -07001241
1242 def __init__(self, tp_port=None):
1243 if tp_port != None:
1244 self.tp_port = tp_port
1245 else:
1246 self.tp_port = 0
1247 return
1248
1249 def pack(self):
1250 packed = []
1251 packed.append(struct.pack("!H", self.type))
1252 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1253 packed.append(struct.pack("!H", self.tp_port))
1254 packed.append('\x00' * 2)
1255 length = sum([len(x) for x in packed])
1256 packed[1] = struct.pack("!H", length)
1257 return ''.join(packed)
1258
1259 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001260 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001261 obj = set_tp_dst()
Dan Talaycof6202252013-07-02 01:00:29 -07001262 _type = reader.read("!H")[0]
1263 assert(_type == 10)
1264 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001265 orig_reader = reader
1266 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001267 obj.tp_port = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001268 reader.skip(2)
1269 return obj
1270
1271 def __eq__(self, other):
1272 if type(self) != type(other): return False
1273 if self.tp_port != other.tp_port: return False
1274 return True
1275
Rich Lanec2ee4b82013-04-24 17:12:38 -07001276 def pretty_print(self, q):
1277 q.text("set_tp_dst {")
1278 with q.group():
1279 with q.indent(2):
1280 q.breakable()
1281 q.text("tp_port = ");
1282 q.text("%#x" % self.tp_port)
1283 q.breakable()
1284 q.text('}')
1285
Rich Lane7dcdf022013-12-11 14:45:27 -08001286action.subtypes[10] = set_tp_dst
1287
1288class set_tp_src(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001289 type = 9
Rich Lanec2ee4b82013-04-24 17:12:38 -07001290
1291 def __init__(self, tp_port=None):
1292 if tp_port != None:
1293 self.tp_port = tp_port
1294 else:
1295 self.tp_port = 0
1296 return
1297
1298 def pack(self):
1299 packed = []
1300 packed.append(struct.pack("!H", self.type))
1301 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1302 packed.append(struct.pack("!H", self.tp_port))
1303 packed.append('\x00' * 2)
1304 length = sum([len(x) for x in packed])
1305 packed[1] = struct.pack("!H", length)
1306 return ''.join(packed)
1307
1308 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001309 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001310 obj = set_tp_src()
Dan Talaycof6202252013-07-02 01:00:29 -07001311 _type = reader.read("!H")[0]
1312 assert(_type == 9)
1313 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001314 orig_reader = reader
1315 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001316 obj.tp_port = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001317 reader.skip(2)
1318 return obj
1319
1320 def __eq__(self, other):
1321 if type(self) != type(other): return False
1322 if self.tp_port != other.tp_port: return False
1323 return True
1324
Rich Lanec2ee4b82013-04-24 17:12:38 -07001325 def pretty_print(self, q):
1326 q.text("set_tp_src {")
1327 with q.group():
1328 with q.indent(2):
1329 q.breakable()
1330 q.text("tp_port = ");
1331 q.text("%#x" % self.tp_port)
1332 q.breakable()
1333 q.text('}')
1334
Rich Lane7dcdf022013-12-11 14:45:27 -08001335action.subtypes[9] = set_tp_src
1336
1337class set_vlan_pcp(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001338 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07001339
1340 def __init__(self, vlan_pcp=None):
1341 if vlan_pcp != None:
1342 self.vlan_pcp = vlan_pcp
1343 else:
1344 self.vlan_pcp = 0
1345 return
1346
1347 def pack(self):
1348 packed = []
1349 packed.append(struct.pack("!H", self.type))
1350 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1351 packed.append(struct.pack("!B", self.vlan_pcp))
1352 packed.append('\x00' * 3)
1353 length = sum([len(x) for x in packed])
1354 packed[1] = struct.pack("!H", length)
1355 return ''.join(packed)
1356
1357 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001358 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001359 obj = set_vlan_pcp()
Dan Talaycof6202252013-07-02 01:00:29 -07001360 _type = reader.read("!H")[0]
1361 assert(_type == 2)
1362 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001363 orig_reader = reader
1364 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001365 obj.vlan_pcp = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001366 reader.skip(3)
1367 return obj
1368
1369 def __eq__(self, other):
1370 if type(self) != type(other): return False
1371 if self.vlan_pcp != other.vlan_pcp: return False
1372 return True
1373
Rich Lanec2ee4b82013-04-24 17:12:38 -07001374 def pretty_print(self, q):
1375 q.text("set_vlan_pcp {")
1376 with q.group():
1377 with q.indent(2):
1378 q.breakable()
1379 q.text("vlan_pcp = ");
1380 q.text("%#x" % self.vlan_pcp)
1381 q.breakable()
1382 q.text('}')
1383
Rich Lane7dcdf022013-12-11 14:45:27 -08001384action.subtypes[2] = set_vlan_pcp
1385
1386class set_vlan_vid(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001387 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07001388
1389 def __init__(self, vlan_vid=None):
1390 if vlan_vid != None:
1391 self.vlan_vid = vlan_vid
1392 else:
1393 self.vlan_vid = 0
1394 return
1395
1396 def pack(self):
1397 packed = []
1398 packed.append(struct.pack("!H", self.type))
1399 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1400 packed.append(struct.pack("!H", self.vlan_vid))
1401 packed.append('\x00' * 2)
1402 length = sum([len(x) for x in packed])
1403 packed[1] = struct.pack("!H", length)
1404 return ''.join(packed)
1405
1406 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001407 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001408 obj = set_vlan_vid()
Dan Talaycof6202252013-07-02 01:00:29 -07001409 _type = reader.read("!H")[0]
1410 assert(_type == 1)
1411 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001412 orig_reader = reader
1413 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001414 obj.vlan_vid = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001415 reader.skip(2)
1416 return obj
1417
1418 def __eq__(self, other):
1419 if type(self) != type(other): return False
1420 if self.vlan_vid != other.vlan_vid: return False
1421 return True
1422
Rich Lanec2ee4b82013-04-24 17:12:38 -07001423 def pretty_print(self, q):
1424 q.text("set_vlan_vid {")
1425 with q.group():
1426 with q.indent(2):
1427 q.breakable()
1428 q.text("vlan_vid = ");
1429 q.text("%#x" % self.vlan_vid)
1430 q.breakable()
1431 q.text('}')
1432
Rich Lane7dcdf022013-12-11 14:45:27 -08001433action.subtypes[1] = set_vlan_vid
Rich Lanec2ee4b82013-04-24 17:12:38 -07001434
Rich Lanec2ee4b82013-04-24 17:12:38 -07001435