blob: 7a93a436316536a12feeb2ed9ea7e6e1a532676b [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
15import oxm
Rich Lanec2ee4b82013-04-24 17:12:38 -070016import util
17import loxi.generic_util
Rich Lanec2ee4b82013-04-24 17:12:38 -070018
Rich Lane7dcdf022013-12-11 14:45:27 -080019class action(loxi.OFObject):
20 subtypes = {}
Rich Lanec2ee4b82013-04-24 17:12:38 -070021
Rich Lane7dcdf022013-12-11 14:45:27 -080022 @staticmethod
23 def unpack(reader):
24 subtype, = reader.peek('!H', 0)
25 try:
26 subclass = action.subtypes[subtype]
27 except KeyError:
28 raise loxi.ProtocolError("unknown action subtype %#x" % subtype)
29 return subclass.unpack(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -070030
Rich Lane7dcdf022013-12-11 14:45:27 -080031
32class experimenter(action):
33 subtypes = {}
34
35 @staticmethod
36 def unpack(reader):
37 subtype, = reader.peek('!L', 4)
38 try:
39 subclass = experimenter.subtypes[subtype]
40 except KeyError:
41 raise loxi.ProtocolError("unknown experimenter action subtype %#x" % subtype)
42 return subclass.unpack(reader)
43
44action.subtypes[65535] = experimenter
45
46class bsn(experimenter):
47 subtypes = {}
48
49 @staticmethod
50 def unpack(reader):
51 subtype, = reader.peek('!L', 8)
52 try:
53 subclass = bsn.subtypes[subtype]
54 except KeyError:
55 raise loxi.ProtocolError("unknown bsn experimenter action subtype %#x" % subtype)
56 return subclass.unpack(reader)
57
58experimenter.subtypes[6035143] = bsn
59
60class bsn_mirror(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -070061 type = 65535
62 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -070063 subtype = 1
64
65 def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None):
66 if dest_port != None:
67 self.dest_port = dest_port
68 else:
69 self.dest_port = 0
70 if vlan_tag != None:
71 self.vlan_tag = vlan_tag
72 else:
73 self.vlan_tag = 0
74 if copy_stage != None:
75 self.copy_stage = copy_stage
76 else:
77 self.copy_stage = 0
78 return
79
80 def pack(self):
81 packed = []
82 packed.append(struct.pack("!H", self.type))
83 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
84 packed.append(struct.pack("!L", self.experimenter))
85 packed.append(struct.pack("!L", self.subtype))
86 packed.append(struct.pack("!L", self.dest_port))
87 packed.append(struct.pack("!L", self.vlan_tag))
88 packed.append(struct.pack("!B", self.copy_stage))
89 packed.append('\x00' * 3)
90 length = sum([len(x) for x in packed])
91 packed[1] = struct.pack("!H", length)
92 return ''.join(packed)
93
94 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -080095 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -070096 obj = bsn_mirror()
Dan Talaycof6202252013-07-02 01:00:29 -070097 _type = reader.read("!H")[0]
98 assert(_type == 65535)
99 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800100 orig_reader = reader
101 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700102 _experimenter = reader.read("!L")[0]
103 assert(_experimenter == 6035143)
104 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700105 assert(_subtype == 1)
Dan Talaycof6202252013-07-02 01:00:29 -0700106 obj.dest_port = reader.read("!L")[0]
107 obj.vlan_tag = reader.read("!L")[0]
108 obj.copy_stage = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700109 reader.skip(3)
110 return obj
111
112 def __eq__(self, other):
113 if type(self) != type(other): return False
114 if self.dest_port != other.dest_port: return False
115 if self.vlan_tag != other.vlan_tag: return False
116 if self.copy_stage != other.copy_stage: return False
117 return True
118
Rich Lanec2ee4b82013-04-24 17:12:38 -0700119 def pretty_print(self, q):
120 q.text("bsn_mirror {")
121 with q.group():
122 with q.indent(2):
123 q.breakable()
124 q.text("dest_port = ");
125 q.text("%#x" % self.dest_port)
126 q.text(","); q.breakable()
127 q.text("vlan_tag = ");
128 q.text("%#x" % self.vlan_tag)
129 q.text(","); q.breakable()
130 q.text("copy_stage = ");
131 q.text("%#x" % self.copy_stage)
132 q.breakable()
133 q.text('}')
134
Rich Lane7dcdf022013-12-11 14:45:27 -0800135bsn.subtypes[1] = bsn_mirror
136
137class bsn_set_tunnel_dst(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700138 type = 65535
139 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -0700140 subtype = 2
141
142 def __init__(self, dst=None):
143 if dst != None:
144 self.dst = dst
145 else:
146 self.dst = 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(struct.pack("!L", self.dst))
156 length = sum([len(x) for x in packed])
157 packed[1] = struct.pack("!H", length)
158 return ''.join(packed)
159
160 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800161 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700162 obj = bsn_set_tunnel_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700163 _type = reader.read("!H")[0]
164 assert(_type == 65535)
165 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800166 orig_reader = reader
167 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700168 _experimenter = reader.read("!L")[0]
169 assert(_experimenter == 6035143)
170 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700171 assert(_subtype == 2)
Dan Talaycof6202252013-07-02 01:00:29 -0700172 obj.dst = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700173 return obj
174
175 def __eq__(self, other):
176 if type(self) != type(other): return False
177 if self.dst != other.dst: return False
178 return True
179
Rich Lanec2ee4b82013-04-24 17:12:38 -0700180 def pretty_print(self, q):
181 q.text("bsn_set_tunnel_dst {")
182 with q.group():
183 with q.indent(2):
184 q.breakable()
185 q.text("dst = ");
186 q.text("%#x" % self.dst)
187 q.breakable()
188 q.text('}')
189
Rich Lane7dcdf022013-12-11 14:45:27 -0800190bsn.subtypes[2] = bsn_set_tunnel_dst
191
192class copy_ttl_in(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700193 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -0700194
195 def __init__(self):
196 return
197
198 def pack(self):
199 packed = []
200 packed.append(struct.pack("!H", self.type))
201 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
202 packed.append('\x00' * 4)
203 length = sum([len(x) for x in packed])
204 packed[1] = struct.pack("!H", length)
205 return ''.join(packed)
206
207 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800208 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700209 obj = copy_ttl_in()
Dan Talaycof6202252013-07-02 01:00:29 -0700210 _type = reader.read("!H")[0]
211 assert(_type == 12)
212 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800213 orig_reader = reader
214 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700215 reader.skip(4)
216 return obj
217
218 def __eq__(self, other):
219 if type(self) != type(other): return False
220 return True
221
Rich Lanec2ee4b82013-04-24 17:12:38 -0700222 def pretty_print(self, q):
223 q.text("copy_ttl_in {")
224 with q.group():
225 with q.indent(2):
226 q.breakable()
227 q.breakable()
228 q.text('}')
229
Rich Lane7dcdf022013-12-11 14:45:27 -0800230action.subtypes[12] = copy_ttl_in
231
232class copy_ttl_out(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700233 type = 11
Rich Lanec2ee4b82013-04-24 17:12:38 -0700234
235 def __init__(self):
236 return
237
238 def pack(self):
239 packed = []
240 packed.append(struct.pack("!H", self.type))
241 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
242 packed.append('\x00' * 4)
243 length = sum([len(x) for x in packed])
244 packed[1] = struct.pack("!H", length)
245 return ''.join(packed)
246
247 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800248 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700249 obj = copy_ttl_out()
Dan Talaycof6202252013-07-02 01:00:29 -0700250 _type = reader.read("!H")[0]
251 assert(_type == 11)
252 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800253 orig_reader = reader
254 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700255 reader.skip(4)
256 return obj
257
258 def __eq__(self, other):
259 if type(self) != type(other): return False
260 return True
261
Rich Lanec2ee4b82013-04-24 17:12:38 -0700262 def pretty_print(self, q):
263 q.text("copy_ttl_out {")
264 with q.group():
265 with q.indent(2):
266 q.breakable()
267 q.breakable()
268 q.text('}')
269
Rich Lane7dcdf022013-12-11 14:45:27 -0800270action.subtypes[11] = copy_ttl_out
271
272class dec_mpls_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700273 type = 16
Rich Lanec2ee4b82013-04-24 17:12:38 -0700274
275 def __init__(self):
276 return
277
278 def pack(self):
279 packed = []
280 packed.append(struct.pack("!H", self.type))
281 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
282 packed.append('\x00' * 4)
283 length = sum([len(x) for x in packed])
284 packed[1] = struct.pack("!H", length)
285 return ''.join(packed)
286
287 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800288 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700289 obj = dec_mpls_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700290 _type = reader.read("!H")[0]
291 assert(_type == 16)
292 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800293 orig_reader = reader
294 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700295 reader.skip(4)
296 return obj
297
298 def __eq__(self, other):
299 if type(self) != type(other): return False
300 return True
301
Rich Lanec2ee4b82013-04-24 17:12:38 -0700302 def pretty_print(self, q):
303 q.text("dec_mpls_ttl {")
304 with q.group():
305 with q.indent(2):
306 q.breakable()
307 q.breakable()
308 q.text('}')
309
Rich Lane7dcdf022013-12-11 14:45:27 -0800310action.subtypes[16] = dec_mpls_ttl
311
312class dec_nw_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700313 type = 24
Rich Lanec2ee4b82013-04-24 17:12:38 -0700314
315 def __init__(self):
316 return
317
318 def pack(self):
319 packed = []
320 packed.append(struct.pack("!H", self.type))
321 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
322 packed.append('\x00' * 4)
323 length = sum([len(x) for x in packed])
324 packed[1] = struct.pack("!H", length)
325 return ''.join(packed)
326
327 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800328 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700329 obj = dec_nw_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700330 _type = reader.read("!H")[0]
331 assert(_type == 24)
332 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800333 orig_reader = reader
334 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700335 reader.skip(4)
336 return obj
337
338 def __eq__(self, other):
339 if type(self) != type(other): return False
340 return True
341
Rich Lanec2ee4b82013-04-24 17:12:38 -0700342 def pretty_print(self, q):
343 q.text("dec_nw_ttl {")
344 with q.group():
345 with q.indent(2):
346 q.breakable()
347 q.breakable()
348 q.text('}')
349
Rich Lane7dcdf022013-12-11 14:45:27 -0800350action.subtypes[24] = dec_nw_ttl
351
352class group(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700353 type = 22
Rich Lanec2ee4b82013-04-24 17:12:38 -0700354
355 def __init__(self, group_id=None):
356 if group_id != None:
357 self.group_id = group_id
358 else:
359 self.group_id = 0
360 return
361
362 def pack(self):
363 packed = []
364 packed.append(struct.pack("!H", self.type))
365 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
366 packed.append(struct.pack("!L", self.group_id))
367 length = sum([len(x) for x in packed])
368 packed[1] = struct.pack("!H", length)
369 return ''.join(packed)
370
371 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800372 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700373 obj = group()
Dan Talaycof6202252013-07-02 01:00:29 -0700374 _type = reader.read("!H")[0]
375 assert(_type == 22)
376 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800377 orig_reader = reader
378 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700379 obj.group_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700380 return obj
381
382 def __eq__(self, other):
383 if type(self) != type(other): return False
384 if self.group_id != other.group_id: return False
385 return True
386
Rich Lanec2ee4b82013-04-24 17:12:38 -0700387 def pretty_print(self, q):
388 q.text("group {")
389 with q.group():
390 with q.indent(2):
391 q.breakable()
392 q.text("group_id = ");
393 q.text("%#x" % self.group_id)
394 q.breakable()
395 q.text('}')
396
Rich Lane7dcdf022013-12-11 14:45:27 -0800397action.subtypes[22] = group
398
399class nicira(experimenter):
400 subtypes = {}
401
402 @staticmethod
403 def unpack(reader):
404 subtype, = reader.peek('!H', 8)
405 try:
406 subclass = nicira.subtypes[subtype]
407 except KeyError:
408 raise loxi.ProtocolError("unknown nicira experimenter action subtype %#x" % subtype)
409 return subclass.unpack(reader)
410
411experimenter.subtypes[8992] = nicira
412
413class nicira_dec_ttl(nicira):
Dan Talaycof6202252013-07-02 01:00:29 -0700414 type = 65535
415 experimenter = 8992
Rich Lanec2ee4b82013-04-24 17:12:38 -0700416 subtype = 18
417
418 def __init__(self):
419 return
420
421 def pack(self):
422 packed = []
423 packed.append(struct.pack("!H", self.type))
424 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
425 packed.append(struct.pack("!L", self.experimenter))
426 packed.append(struct.pack("!H", self.subtype))
427 packed.append('\x00' * 2)
428 packed.append('\x00' * 4)
429 length = sum([len(x) for x in packed])
430 packed[1] = struct.pack("!H", length)
431 return ''.join(packed)
432
433 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800434 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700435 obj = nicira_dec_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700436 _type = reader.read("!H")[0]
437 assert(_type == 65535)
438 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800439 orig_reader = reader
440 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700441 _experimenter = reader.read("!L")[0]
442 assert(_experimenter == 8992)
443 _subtype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700444 assert(_subtype == 18)
445 reader.skip(2)
446 reader.skip(4)
447 return obj
448
449 def __eq__(self, other):
450 if type(self) != type(other): return False
451 return True
452
Rich Lanec2ee4b82013-04-24 17:12:38 -0700453 def pretty_print(self, q):
454 q.text("nicira_dec_ttl {")
455 with q.group():
456 with q.indent(2):
457 q.breakable()
458 q.breakable()
459 q.text('}')
460
Rich Lane7dcdf022013-12-11 14:45:27 -0800461nicira.subtypes[18] = nicira_dec_ttl
462
463class output(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700464 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700465
466 def __init__(self, port=None, max_len=None):
467 if port != None:
468 self.port = port
469 else:
470 self.port = 0
471 if max_len != None:
472 self.max_len = max_len
473 else:
474 self.max_len = 0
475 return
476
477 def pack(self):
478 packed = []
479 packed.append(struct.pack("!H", self.type))
480 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700481 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700482 packed.append(struct.pack("!H", self.max_len))
483 packed.append('\x00' * 6)
484 length = sum([len(x) for x in packed])
485 packed[1] = struct.pack("!H", length)
486 return ''.join(packed)
487
488 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800489 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700490 obj = output()
Dan Talaycof6202252013-07-02 01:00:29 -0700491 _type = reader.read("!H")[0]
492 assert(_type == 0)
493 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800494 orig_reader = reader
495 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700496 obj.port = util.unpack_port_no(reader)
497 obj.max_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700498 reader.skip(6)
499 return obj
500
501 def __eq__(self, other):
502 if type(self) != type(other): return False
503 if self.port != other.port: return False
504 if self.max_len != other.max_len: return False
505 return True
506
Rich Lanec2ee4b82013-04-24 17:12:38 -0700507 def pretty_print(self, q):
508 q.text("output {")
509 with q.group():
510 with q.indent(2):
511 q.breakable()
512 q.text("port = ");
513 q.text(util.pretty_port(self.port))
514 q.text(","); q.breakable()
515 q.text("max_len = ");
516 q.text("%#x" % self.max_len)
517 q.breakable()
518 q.text('}')
519
Rich Lane7dcdf022013-12-11 14:45:27 -0800520action.subtypes[0] = output
521
522class pop_mpls(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700523 type = 20
Rich Lanec2ee4b82013-04-24 17:12:38 -0700524
525 def __init__(self, ethertype=None):
526 if ethertype != None:
527 self.ethertype = ethertype
528 else:
529 self.ethertype = 0
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(struct.pack("!H", self.ethertype))
537 packed.append('\x00' * 2)
538 length = sum([len(x) for x in packed])
539 packed[1] = struct.pack("!H", length)
540 return ''.join(packed)
541
542 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800543 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700544 obj = pop_mpls()
Dan Talaycof6202252013-07-02 01:00:29 -0700545 _type = reader.read("!H")[0]
546 assert(_type == 20)
547 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800548 orig_reader = reader
549 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700550 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700551 reader.skip(2)
552 return obj
553
554 def __eq__(self, other):
555 if type(self) != type(other): return False
556 if self.ethertype != other.ethertype: return False
557 return True
558
Rich Lanec2ee4b82013-04-24 17:12:38 -0700559 def pretty_print(self, q):
560 q.text("pop_mpls {")
561 with q.group():
562 with q.indent(2):
563 q.breakable()
564 q.text("ethertype = ");
565 q.text("%#x" % self.ethertype)
566 q.breakable()
567 q.text('}')
568
Rich Lane7dcdf022013-12-11 14:45:27 -0800569action.subtypes[20] = pop_mpls
570
571class pop_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700572 type = 18
Rich Lanec2ee4b82013-04-24 17:12:38 -0700573
574 def __init__(self):
575 return
576
577 def pack(self):
578 packed = []
579 packed.append(struct.pack("!H", self.type))
580 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
581 packed.append('\x00' * 4)
582 length = sum([len(x) for x in packed])
583 packed[1] = struct.pack("!H", length)
584 return ''.join(packed)
585
586 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800587 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700588 obj = pop_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -0700589 _type = reader.read("!H")[0]
590 assert(_type == 18)
591 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800592 orig_reader = reader
593 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700594 reader.skip(4)
595 return obj
596
597 def __eq__(self, other):
598 if type(self) != type(other): return False
599 return True
600
Rich Lanec2ee4b82013-04-24 17:12:38 -0700601 def pretty_print(self, q):
602 q.text("pop_vlan {")
603 with q.group():
604 with q.indent(2):
605 q.breakable()
606 q.breakable()
607 q.text('}')
608
Rich Lane7dcdf022013-12-11 14:45:27 -0800609action.subtypes[18] = pop_vlan
610
611class push_mpls(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700612 type = 19
Rich Lanec2ee4b82013-04-24 17:12:38 -0700613
614 def __init__(self, ethertype=None):
615 if ethertype != None:
616 self.ethertype = ethertype
617 else:
618 self.ethertype = 0
619 return
620
621 def pack(self):
622 packed = []
623 packed.append(struct.pack("!H", self.type))
624 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
625 packed.append(struct.pack("!H", self.ethertype))
626 packed.append('\x00' * 2)
627 length = sum([len(x) for x in packed])
628 packed[1] = struct.pack("!H", length)
629 return ''.join(packed)
630
631 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800632 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700633 obj = push_mpls()
Dan Talaycof6202252013-07-02 01:00:29 -0700634 _type = reader.read("!H")[0]
635 assert(_type == 19)
636 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800637 orig_reader = reader
638 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700639 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700640 reader.skip(2)
641 return obj
642
643 def __eq__(self, other):
644 if type(self) != type(other): return False
645 if self.ethertype != other.ethertype: return False
646 return True
647
Rich Lanec2ee4b82013-04-24 17:12:38 -0700648 def pretty_print(self, q):
649 q.text("push_mpls {")
650 with q.group():
651 with q.indent(2):
652 q.breakable()
653 q.text("ethertype = ");
654 q.text("%#x" % self.ethertype)
655 q.breakable()
656 q.text('}')
657
Rich Lane7dcdf022013-12-11 14:45:27 -0800658action.subtypes[19] = push_mpls
659
660class push_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700661 type = 17
Rich Lanec2ee4b82013-04-24 17:12:38 -0700662
663 def __init__(self, ethertype=None):
664 if ethertype != None:
665 self.ethertype = ethertype
666 else:
667 self.ethertype = 0
668 return
669
670 def pack(self):
671 packed = []
672 packed.append(struct.pack("!H", self.type))
673 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
674 packed.append(struct.pack("!H", self.ethertype))
675 packed.append('\x00' * 2)
676 length = sum([len(x) for x in packed])
677 packed[1] = struct.pack("!H", length)
678 return ''.join(packed)
679
680 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800681 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700682 obj = push_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -0700683 _type = reader.read("!H")[0]
684 assert(_type == 17)
685 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800686 orig_reader = reader
687 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700688 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700689 reader.skip(2)
690 return obj
691
692 def __eq__(self, other):
693 if type(self) != type(other): return False
694 if self.ethertype != other.ethertype: return False
695 return True
696
Rich Lanec2ee4b82013-04-24 17:12:38 -0700697 def pretty_print(self, q):
698 q.text("push_vlan {")
699 with q.group():
700 with q.indent(2):
701 q.breakable()
702 q.text("ethertype = ");
703 q.text("%#x" % self.ethertype)
704 q.breakable()
705 q.text('}')
706
Rich Lane7dcdf022013-12-11 14:45:27 -0800707action.subtypes[17] = push_vlan
708
709class set_field(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700710 type = 25
Rich Lanec2ee4b82013-04-24 17:12:38 -0700711
712 def __init__(self, field=None):
713 if field != None:
714 self.field = field
715 else:
Rich Laned53156a2013-08-05 17:17:33 -0700716 self.field = None
Rich Lanec2ee4b82013-04-24 17:12:38 -0700717 return
718
719 def pack(self):
720 packed = []
721 packed.append(struct.pack("!H", self.type))
722 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Rich Laned53156a2013-08-05 17:17:33 -0700723 packed.append(self.field.pack())
Rich Lanec2ee4b82013-04-24 17:12:38 -0700724 length = sum([len(x) for x in packed])
Rich Laned53156a2013-08-05 17:17:33 -0700725 packed.append(loxi.generic_util.pad_to(8, length))
726 length += len(packed[-1])
Rich Lanec2ee4b82013-04-24 17:12:38 -0700727 packed[1] = struct.pack("!H", length)
728 return ''.join(packed)
729
730 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800731 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700732 obj = set_field()
Dan Talaycof6202252013-07-02 01:00:29 -0700733 _type = reader.read("!H")[0]
734 assert(_type == 25)
735 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800736 orig_reader = reader
737 reader = orig_reader.slice(_len - (2 + 2))
738 obj.field = oxm.oxm.unpack(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700739 return obj
740
741 def __eq__(self, other):
742 if type(self) != type(other): return False
743 if self.field != other.field: return False
744 return True
745
Rich Lanec2ee4b82013-04-24 17:12:38 -0700746 def pretty_print(self, q):
747 q.text("set_field {")
748 with q.group():
749 with q.indent(2):
750 q.breakable()
751 q.text("field = ");
752 q.pp(self.field)
753 q.breakable()
754 q.text('}')
755
Rich Lane7dcdf022013-12-11 14:45:27 -0800756action.subtypes[25] = set_field
757
758class set_mpls_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700759 type = 15
Rich Lanec2ee4b82013-04-24 17:12:38 -0700760
761 def __init__(self, mpls_ttl=None):
762 if mpls_ttl != None:
763 self.mpls_ttl = mpls_ttl
764 else:
765 self.mpls_ttl = 0
766 return
767
768 def pack(self):
769 packed = []
770 packed.append(struct.pack("!H", self.type))
771 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
772 packed.append(struct.pack("!B", self.mpls_ttl))
773 packed.append('\x00' * 3)
774 length = sum([len(x) for x in packed])
775 packed[1] = struct.pack("!H", length)
776 return ''.join(packed)
777
778 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800779 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700780 obj = set_mpls_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700781 _type = reader.read("!H")[0]
782 assert(_type == 15)
783 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800784 orig_reader = reader
785 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700786 obj.mpls_ttl = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700787 reader.skip(3)
788 return obj
789
790 def __eq__(self, other):
791 if type(self) != type(other): return False
792 if self.mpls_ttl != other.mpls_ttl: return False
793 return True
794
Rich Lanec2ee4b82013-04-24 17:12:38 -0700795 def pretty_print(self, q):
796 q.text("set_mpls_ttl {")
797 with q.group():
798 with q.indent(2):
799 q.breakable()
800 q.text("mpls_ttl = ");
801 q.text("%#x" % self.mpls_ttl)
802 q.breakable()
803 q.text('}')
804
Rich Lane7dcdf022013-12-11 14:45:27 -0800805action.subtypes[15] = set_mpls_ttl
806
807class set_nw_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700808 type = 23
Rich Lanec2ee4b82013-04-24 17:12:38 -0700809
810 def __init__(self, nw_ttl=None):
811 if nw_ttl != None:
812 self.nw_ttl = nw_ttl
813 else:
814 self.nw_ttl = 0
815 return
816
817 def pack(self):
818 packed = []
819 packed.append(struct.pack("!H", self.type))
820 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
821 packed.append(struct.pack("!B", self.nw_ttl))
822 packed.append('\x00' * 3)
823 length = sum([len(x) for x in packed])
824 packed[1] = struct.pack("!H", length)
825 return ''.join(packed)
826
827 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800828 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700829 obj = set_nw_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700830 _type = reader.read("!H")[0]
831 assert(_type == 23)
832 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800833 orig_reader = reader
834 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700835 obj.nw_ttl = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700836 reader.skip(3)
837 return obj
838
839 def __eq__(self, other):
840 if type(self) != type(other): return False
841 if self.nw_ttl != other.nw_ttl: return False
842 return True
843
Rich Lanec2ee4b82013-04-24 17:12:38 -0700844 def pretty_print(self, q):
845 q.text("set_nw_ttl {")
846 with q.group():
847 with q.indent(2):
848 q.breakable()
849 q.text("nw_ttl = ");
850 q.text("%#x" % self.nw_ttl)
851 q.breakable()
852 q.text('}')
853
Rich Lane7dcdf022013-12-11 14:45:27 -0800854action.subtypes[23] = set_nw_ttl
855
856class set_queue(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700857 type = 21
Rich Lanec2ee4b82013-04-24 17:12:38 -0700858
859 def __init__(self, queue_id=None):
860 if queue_id != None:
861 self.queue_id = queue_id
862 else:
863 self.queue_id = 0
864 return
865
866 def pack(self):
867 packed = []
868 packed.append(struct.pack("!H", self.type))
869 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
870 packed.append(struct.pack("!L", self.queue_id))
871 length = sum([len(x) for x in packed])
872 packed[1] = struct.pack("!H", length)
873 return ''.join(packed)
874
875 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800876 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700877 obj = set_queue()
Dan Talaycof6202252013-07-02 01:00:29 -0700878 _type = reader.read("!H")[0]
879 assert(_type == 21)
880 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800881 orig_reader = reader
882 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700883 obj.queue_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700884 return obj
885
886 def __eq__(self, other):
887 if type(self) != type(other): return False
888 if self.queue_id != other.queue_id: return False
889 return True
890
Rich Lanec2ee4b82013-04-24 17:12:38 -0700891 def pretty_print(self, q):
892 q.text("set_queue {")
893 with q.group():
894 with q.indent(2):
895 q.breakable()
896 q.text("queue_id = ");
897 q.text("%#x" % self.queue_id)
898 q.breakable()
899 q.text('}')
900
Rich Lane7dcdf022013-12-11 14:45:27 -0800901action.subtypes[21] = set_queue
Rich Lanec2ee4b82013-04-24 17:12:38 -0700902
Rich Lanec2ee4b82013-04-24 17:12:38 -0700903