blob: 94bd36475e29ad88ca99c0dc5adc524885b86eb7 [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
16import action_id
17import instruction_id
18import meter_band
Rich Lane1a820412014-01-06 14:15:07 -080019import bsn_tlv
Rich Lanec2ee4b82013-04-24 17:12:38 -070020import util
21import loxi.generic_util
Rich Lanec2ee4b82013-04-24 17:12:38 -070022
Rich Lane7dcdf022013-12-11 14:45:27 -080023class action(loxi.OFObject):
24 subtypes = {}
Rich Lanec2ee4b82013-04-24 17:12:38 -070025
Rich Lane7dcdf022013-12-11 14:45:27 -080026 @staticmethod
27 def unpack(reader):
28 subtype, = reader.peek('!H', 0)
29 try:
30 subclass = action.subtypes[subtype]
31 except KeyError:
32 raise loxi.ProtocolError("unknown action subtype %#x" % subtype)
33 return subclass.unpack(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -070034
Rich Lane7dcdf022013-12-11 14:45:27 -080035
36class experimenter(action):
37 subtypes = {}
38
39 @staticmethod
40 def unpack(reader):
41 subtype, = reader.peek('!L', 4)
42 try:
43 subclass = experimenter.subtypes[subtype]
44 except KeyError:
45 raise loxi.ProtocolError("unknown experimenter action subtype %#x" % subtype)
46 return subclass.unpack(reader)
47
48action.subtypes[65535] = experimenter
49
50class bsn(experimenter):
51 subtypes = {}
52
53 @staticmethod
54 def unpack(reader):
55 subtype, = reader.peek('!L', 8)
56 try:
57 subclass = bsn.subtypes[subtype]
58 except KeyError:
59 raise loxi.ProtocolError("unknown bsn experimenter action subtype %#x" % subtype)
60 return subclass.unpack(reader)
61
62experimenter.subtypes[6035143] = bsn
63
64class bsn_mirror(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -070065 type = 65535
66 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -070067 subtype = 1
68
69 def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None):
70 if dest_port != None:
71 self.dest_port = dest_port
72 else:
73 self.dest_port = 0
74 if vlan_tag != None:
75 self.vlan_tag = vlan_tag
76 else:
77 self.vlan_tag = 0
78 if copy_stage != None:
79 self.copy_stage = copy_stage
80 else:
81 self.copy_stage = 0
82 return
83
84 def pack(self):
85 packed = []
86 packed.append(struct.pack("!H", self.type))
87 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
88 packed.append(struct.pack("!L", self.experimenter))
89 packed.append(struct.pack("!L", self.subtype))
90 packed.append(struct.pack("!L", self.dest_port))
91 packed.append(struct.pack("!L", self.vlan_tag))
92 packed.append(struct.pack("!B", self.copy_stage))
93 packed.append('\x00' * 3)
94 length = sum([len(x) for x in packed])
95 packed[1] = struct.pack("!H", length)
96 return ''.join(packed)
97
98 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -080099 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700100 obj = bsn_mirror()
Dan Talaycof6202252013-07-02 01:00:29 -0700101 _type = reader.read("!H")[0]
102 assert(_type == 65535)
103 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800104 orig_reader = reader
105 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700106 _experimenter = reader.read("!L")[0]
107 assert(_experimenter == 6035143)
108 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700109 assert(_subtype == 1)
Dan Talaycof6202252013-07-02 01:00:29 -0700110 obj.dest_port = reader.read("!L")[0]
111 obj.vlan_tag = reader.read("!L")[0]
112 obj.copy_stage = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700113 reader.skip(3)
114 return obj
115
116 def __eq__(self, other):
117 if type(self) != type(other): return False
118 if self.dest_port != other.dest_port: return False
119 if self.vlan_tag != other.vlan_tag: return False
120 if self.copy_stage != other.copy_stage: return False
121 return True
122
Rich Lanec2ee4b82013-04-24 17:12:38 -0700123 def pretty_print(self, q):
124 q.text("bsn_mirror {")
125 with q.group():
126 with q.indent(2):
127 q.breakable()
128 q.text("dest_port = ");
129 q.text("%#x" % self.dest_port)
130 q.text(","); q.breakable()
131 q.text("vlan_tag = ");
132 q.text("%#x" % self.vlan_tag)
133 q.text(","); q.breakable()
134 q.text("copy_stage = ");
135 q.text("%#x" % self.copy_stage)
136 q.breakable()
137 q.text('}')
138
Rich Lane7dcdf022013-12-11 14:45:27 -0800139bsn.subtypes[1] = bsn_mirror
140
141class bsn_set_tunnel_dst(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700142 type = 65535
143 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -0700144 subtype = 2
145
146 def __init__(self, dst=None):
147 if dst != None:
148 self.dst = dst
149 else:
150 self.dst = 0
151 return
152
153 def pack(self):
154 packed = []
155 packed.append(struct.pack("!H", self.type))
156 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
157 packed.append(struct.pack("!L", self.experimenter))
158 packed.append(struct.pack("!L", self.subtype))
159 packed.append(struct.pack("!L", self.dst))
160 length = sum([len(x) for x in packed])
161 packed[1] = struct.pack("!H", length)
162 return ''.join(packed)
163
164 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800165 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700166 obj = bsn_set_tunnel_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700167 _type = reader.read("!H")[0]
168 assert(_type == 65535)
169 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800170 orig_reader = reader
171 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700172 _experimenter = reader.read("!L")[0]
173 assert(_experimenter == 6035143)
174 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700175 assert(_subtype == 2)
Dan Talaycof6202252013-07-02 01:00:29 -0700176 obj.dst = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700177 return obj
178
179 def __eq__(self, other):
180 if type(self) != type(other): return False
181 if self.dst != other.dst: return False
182 return True
183
Rich Lanec2ee4b82013-04-24 17:12:38 -0700184 def pretty_print(self, q):
185 q.text("bsn_set_tunnel_dst {")
186 with q.group():
187 with q.indent(2):
188 q.breakable()
189 q.text("dst = ");
190 q.text("%#x" % self.dst)
191 q.breakable()
192 q.text('}')
193
Rich Lane7dcdf022013-12-11 14:45:27 -0800194bsn.subtypes[2] = bsn_set_tunnel_dst
195
196class copy_ttl_in(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700197 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -0700198
199 def __init__(self):
200 return
201
202 def pack(self):
203 packed = []
204 packed.append(struct.pack("!H", self.type))
205 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
206 packed.append('\x00' * 4)
207 length = sum([len(x) for x in packed])
208 packed[1] = struct.pack("!H", length)
209 return ''.join(packed)
210
211 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800212 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700213 obj = copy_ttl_in()
Dan Talaycof6202252013-07-02 01:00:29 -0700214 _type = reader.read("!H")[0]
215 assert(_type == 12)
216 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800217 orig_reader = reader
218 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700219 reader.skip(4)
220 return obj
221
222 def __eq__(self, other):
223 if type(self) != type(other): return False
224 return True
225
Rich Lanec2ee4b82013-04-24 17:12:38 -0700226 def pretty_print(self, q):
227 q.text("copy_ttl_in {")
228 with q.group():
229 with q.indent(2):
230 q.breakable()
231 q.breakable()
232 q.text('}')
233
Rich Lane7dcdf022013-12-11 14:45:27 -0800234action.subtypes[12] = copy_ttl_in
235
236class copy_ttl_out(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700237 type = 11
Rich Lanec2ee4b82013-04-24 17:12:38 -0700238
239 def __init__(self):
240 return
241
242 def pack(self):
243 packed = []
244 packed.append(struct.pack("!H", self.type))
245 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
246 packed.append('\x00' * 4)
247 length = sum([len(x) for x in packed])
248 packed[1] = struct.pack("!H", length)
249 return ''.join(packed)
250
251 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800252 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700253 obj = copy_ttl_out()
Dan Talaycof6202252013-07-02 01:00:29 -0700254 _type = reader.read("!H")[0]
255 assert(_type == 11)
256 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800257 orig_reader = reader
258 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700259 reader.skip(4)
260 return obj
261
262 def __eq__(self, other):
263 if type(self) != type(other): return False
264 return True
265
Rich Lanec2ee4b82013-04-24 17:12:38 -0700266 def pretty_print(self, q):
267 q.text("copy_ttl_out {")
268 with q.group():
269 with q.indent(2):
270 q.breakable()
271 q.breakable()
272 q.text('}')
273
Rich Lane7dcdf022013-12-11 14:45:27 -0800274action.subtypes[11] = copy_ttl_out
275
276class dec_mpls_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700277 type = 16
Rich Lanec2ee4b82013-04-24 17:12:38 -0700278
279 def __init__(self):
280 return
281
282 def pack(self):
283 packed = []
284 packed.append(struct.pack("!H", self.type))
285 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
286 packed.append('\x00' * 4)
287 length = sum([len(x) for x in packed])
288 packed[1] = struct.pack("!H", length)
289 return ''.join(packed)
290
291 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800292 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700293 obj = dec_mpls_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700294 _type = reader.read("!H")[0]
295 assert(_type == 16)
296 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800297 orig_reader = reader
298 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700299 reader.skip(4)
300 return obj
301
302 def __eq__(self, other):
303 if type(self) != type(other): return False
304 return True
305
Rich Lanec2ee4b82013-04-24 17:12:38 -0700306 def pretty_print(self, q):
307 q.text("dec_mpls_ttl {")
308 with q.group():
309 with q.indent(2):
310 q.breakable()
311 q.breakable()
312 q.text('}')
313
Rich Lane7dcdf022013-12-11 14:45:27 -0800314action.subtypes[16] = dec_mpls_ttl
315
316class dec_nw_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700317 type = 24
Rich Lanec2ee4b82013-04-24 17:12:38 -0700318
319 def __init__(self):
320 return
321
322 def pack(self):
323 packed = []
324 packed.append(struct.pack("!H", self.type))
325 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
326 packed.append('\x00' * 4)
327 length = sum([len(x) for x in packed])
328 packed[1] = struct.pack("!H", length)
329 return ''.join(packed)
330
331 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800332 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700333 obj = dec_nw_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700334 _type = reader.read("!H")[0]
335 assert(_type == 24)
336 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800337 orig_reader = reader
338 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700339 reader.skip(4)
340 return obj
341
342 def __eq__(self, other):
343 if type(self) != type(other): return False
344 return True
345
Rich Lanec2ee4b82013-04-24 17:12:38 -0700346 def pretty_print(self, q):
347 q.text("dec_nw_ttl {")
348 with q.group():
349 with q.indent(2):
350 q.breakable()
351 q.breakable()
352 q.text('}')
353
Rich Lane7dcdf022013-12-11 14:45:27 -0800354action.subtypes[24] = dec_nw_ttl
355
356class group(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700357 type = 22
Rich Lanec2ee4b82013-04-24 17:12:38 -0700358
359 def __init__(self, group_id=None):
360 if group_id != None:
361 self.group_id = group_id
362 else:
363 self.group_id = 0
364 return
365
366 def pack(self):
367 packed = []
368 packed.append(struct.pack("!H", self.type))
369 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
370 packed.append(struct.pack("!L", self.group_id))
371 length = sum([len(x) for x in packed])
372 packed[1] = struct.pack("!H", length)
373 return ''.join(packed)
374
375 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800376 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700377 obj = group()
Dan Talaycof6202252013-07-02 01:00:29 -0700378 _type = reader.read("!H")[0]
379 assert(_type == 22)
380 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800381 orig_reader = reader
382 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700383 obj.group_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700384 return obj
385
386 def __eq__(self, other):
387 if type(self) != type(other): return False
388 if self.group_id != other.group_id: return False
389 return True
390
Rich Lanec2ee4b82013-04-24 17:12:38 -0700391 def pretty_print(self, q):
392 q.text("group {")
393 with q.group():
394 with q.indent(2):
395 q.breakable()
396 q.text("group_id = ");
397 q.text("%#x" % self.group_id)
398 q.breakable()
399 q.text('}')
400
Rich Lane7dcdf022013-12-11 14:45:27 -0800401action.subtypes[22] = group
402
403class nicira(experimenter):
404 subtypes = {}
405
406 @staticmethod
407 def unpack(reader):
408 subtype, = reader.peek('!H', 8)
409 try:
410 subclass = nicira.subtypes[subtype]
411 except KeyError:
412 raise loxi.ProtocolError("unknown nicira experimenter action subtype %#x" % subtype)
413 return subclass.unpack(reader)
414
415experimenter.subtypes[8992] = nicira
416
417class nicira_dec_ttl(nicira):
Dan Talaycof6202252013-07-02 01:00:29 -0700418 type = 65535
419 experimenter = 8992
Rich Lanec2ee4b82013-04-24 17:12:38 -0700420 subtype = 18
421
422 def __init__(self):
423 return
424
425 def pack(self):
426 packed = []
427 packed.append(struct.pack("!H", self.type))
428 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
429 packed.append(struct.pack("!L", self.experimenter))
430 packed.append(struct.pack("!H", self.subtype))
431 packed.append('\x00' * 2)
432 packed.append('\x00' * 4)
433 length = sum([len(x) for x in packed])
434 packed[1] = struct.pack("!H", length)
435 return ''.join(packed)
436
437 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800438 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700439 obj = nicira_dec_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700440 _type = reader.read("!H")[0]
441 assert(_type == 65535)
442 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800443 orig_reader = reader
444 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700445 _experimenter = reader.read("!L")[0]
446 assert(_experimenter == 8992)
447 _subtype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700448 assert(_subtype == 18)
449 reader.skip(2)
450 reader.skip(4)
451 return obj
452
453 def __eq__(self, other):
454 if type(self) != type(other): return False
455 return True
456
Rich Lanec2ee4b82013-04-24 17:12:38 -0700457 def pretty_print(self, q):
458 q.text("nicira_dec_ttl {")
459 with q.group():
460 with q.indent(2):
461 q.breakable()
462 q.breakable()
463 q.text('}')
464
Rich Lane7dcdf022013-12-11 14:45:27 -0800465nicira.subtypes[18] = nicira_dec_ttl
466
467class output(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700468 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700469
470 def __init__(self, port=None, max_len=None):
471 if port != None:
472 self.port = port
473 else:
474 self.port = 0
475 if max_len != None:
476 self.max_len = max_len
477 else:
478 self.max_len = 0
479 return
480
481 def pack(self):
482 packed = []
483 packed.append(struct.pack("!H", self.type))
484 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700485 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700486 packed.append(struct.pack("!H", self.max_len))
487 packed.append('\x00' * 6)
488 length = sum([len(x) for x in packed])
489 packed[1] = struct.pack("!H", length)
490 return ''.join(packed)
491
492 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800493 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700494 obj = output()
Dan Talaycof6202252013-07-02 01:00:29 -0700495 _type = reader.read("!H")[0]
496 assert(_type == 0)
497 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800498 orig_reader = reader
499 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700500 obj.port = util.unpack_port_no(reader)
501 obj.max_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700502 reader.skip(6)
503 return obj
504
505 def __eq__(self, other):
506 if type(self) != type(other): return False
507 if self.port != other.port: return False
508 if self.max_len != other.max_len: return False
509 return True
510
Rich Lanec2ee4b82013-04-24 17:12:38 -0700511 def pretty_print(self, q):
512 q.text("output {")
513 with q.group():
514 with q.indent(2):
515 q.breakable()
516 q.text("port = ");
517 q.text(util.pretty_port(self.port))
518 q.text(","); q.breakable()
519 q.text("max_len = ");
520 q.text("%#x" % self.max_len)
521 q.breakable()
522 q.text('}')
523
Rich Lane7dcdf022013-12-11 14:45:27 -0800524action.subtypes[0] = output
525
526class pop_mpls(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700527 type = 20
Rich Lanec2ee4b82013-04-24 17:12:38 -0700528
529 def __init__(self, ethertype=None):
530 if ethertype != None:
531 self.ethertype = ethertype
532 else:
533 self.ethertype = 0
534 return
535
536 def pack(self):
537 packed = []
538 packed.append(struct.pack("!H", self.type))
539 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
540 packed.append(struct.pack("!H", self.ethertype))
541 packed.append('\x00' * 2)
542 length = sum([len(x) for x in packed])
543 packed[1] = struct.pack("!H", length)
544 return ''.join(packed)
545
546 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800547 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700548 obj = pop_mpls()
Dan Talaycof6202252013-07-02 01:00:29 -0700549 _type = reader.read("!H")[0]
550 assert(_type == 20)
551 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800552 orig_reader = reader
553 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700554 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700555 reader.skip(2)
556 return obj
557
558 def __eq__(self, other):
559 if type(self) != type(other): return False
560 if self.ethertype != other.ethertype: return False
561 return True
562
Rich Lanec2ee4b82013-04-24 17:12:38 -0700563 def pretty_print(self, q):
564 q.text("pop_mpls {")
565 with q.group():
566 with q.indent(2):
567 q.breakable()
568 q.text("ethertype = ");
569 q.text("%#x" % self.ethertype)
570 q.breakable()
571 q.text('}')
572
Rich Lane7dcdf022013-12-11 14:45:27 -0800573action.subtypes[20] = pop_mpls
574
575class pop_pbb(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700576 type = 27
Rich Lanec2ee4b82013-04-24 17:12:38 -0700577
578 def __init__(self):
579 return
580
581 def pack(self):
582 packed = []
583 packed.append(struct.pack("!H", self.type))
584 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
585 packed.append('\x00' * 4)
586 length = sum([len(x) for x in packed])
587 packed[1] = struct.pack("!H", length)
588 return ''.join(packed)
589
590 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800591 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700592 obj = pop_pbb()
Dan Talaycof6202252013-07-02 01:00:29 -0700593 _type = reader.read("!H")[0]
594 assert(_type == 27)
595 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800596 orig_reader = reader
597 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700598 reader.skip(4)
599 return obj
600
601 def __eq__(self, other):
602 if type(self) != type(other): return False
603 return True
604
Rich Lanec2ee4b82013-04-24 17:12:38 -0700605 def pretty_print(self, q):
606 q.text("pop_pbb {")
607 with q.group():
608 with q.indent(2):
609 q.breakable()
610 q.breakable()
611 q.text('}')
612
Rich Lane7dcdf022013-12-11 14:45:27 -0800613action.subtypes[27] = pop_pbb
614
615class pop_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700616 type = 18
Rich Lanec2ee4b82013-04-24 17:12:38 -0700617
618 def __init__(self):
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('\x00' * 4)
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 = pop_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -0700633 _type = reader.read("!H")[0]
634 assert(_type == 18)
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))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700638 reader.skip(4)
639 return obj
640
641 def __eq__(self, other):
642 if type(self) != type(other): return False
643 return True
644
Rich Lanec2ee4b82013-04-24 17:12:38 -0700645 def pretty_print(self, q):
646 q.text("pop_vlan {")
647 with q.group():
648 with q.indent(2):
649 q.breakable()
650 q.breakable()
651 q.text('}')
652
Rich Lane7dcdf022013-12-11 14:45:27 -0800653action.subtypes[18] = pop_vlan
654
655class push_mpls(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700656 type = 19
Rich Lanec2ee4b82013-04-24 17:12:38 -0700657
658 def __init__(self, ethertype=None):
659 if ethertype != None:
660 self.ethertype = ethertype
661 else:
662 self.ethertype = 0
663 return
664
665 def pack(self):
666 packed = []
667 packed.append(struct.pack("!H", self.type))
668 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
669 packed.append(struct.pack("!H", self.ethertype))
670 packed.append('\x00' * 2)
671 length = sum([len(x) for x in packed])
672 packed[1] = struct.pack("!H", length)
673 return ''.join(packed)
674
675 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800676 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700677 obj = push_mpls()
Dan Talaycof6202252013-07-02 01:00:29 -0700678 _type = reader.read("!H")[0]
679 assert(_type == 19)
680 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800681 orig_reader = reader
682 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700683 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700684 reader.skip(2)
685 return obj
686
687 def __eq__(self, other):
688 if type(self) != type(other): return False
689 if self.ethertype != other.ethertype: return False
690 return True
691
Rich Lanec2ee4b82013-04-24 17:12:38 -0700692 def pretty_print(self, q):
693 q.text("push_mpls {")
694 with q.group():
695 with q.indent(2):
696 q.breakable()
697 q.text("ethertype = ");
698 q.text("%#x" % self.ethertype)
699 q.breakable()
700 q.text('}')
701
Rich Lane7dcdf022013-12-11 14:45:27 -0800702action.subtypes[19] = push_mpls
703
704class push_pbb(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700705 type = 26
Rich Lanec2ee4b82013-04-24 17:12:38 -0700706
707 def __init__(self, ethertype=None):
708 if ethertype != None:
709 self.ethertype = ethertype
710 else:
711 self.ethertype = 0
712 return
713
714 def pack(self):
715 packed = []
716 packed.append(struct.pack("!H", self.type))
717 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
718 packed.append(struct.pack("!H", self.ethertype))
719 packed.append('\x00' * 2)
720 length = sum([len(x) for x in packed])
721 packed[1] = struct.pack("!H", length)
722 return ''.join(packed)
723
724 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800725 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700726 obj = push_pbb()
Dan Talaycof6202252013-07-02 01:00:29 -0700727 _type = reader.read("!H")[0]
728 assert(_type == 26)
729 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800730 orig_reader = reader
731 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700732 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700733 reader.skip(2)
734 return obj
735
736 def __eq__(self, other):
737 if type(self) != type(other): return False
738 if self.ethertype != other.ethertype: return False
739 return True
740
Rich Lanec2ee4b82013-04-24 17:12:38 -0700741 def pretty_print(self, q):
742 q.text("push_pbb {")
743 with q.group():
744 with q.indent(2):
745 q.breakable()
746 q.text("ethertype = ");
747 q.text("%#x" % self.ethertype)
748 q.breakable()
749 q.text('}')
750
Rich Lane7dcdf022013-12-11 14:45:27 -0800751action.subtypes[26] = push_pbb
752
753class push_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700754 type = 17
Rich Lanec2ee4b82013-04-24 17:12:38 -0700755
756 def __init__(self, ethertype=None):
757 if ethertype != None:
758 self.ethertype = ethertype
759 else:
760 self.ethertype = 0
761 return
762
763 def pack(self):
764 packed = []
765 packed.append(struct.pack("!H", self.type))
766 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
767 packed.append(struct.pack("!H", self.ethertype))
768 packed.append('\x00' * 2)
769 length = sum([len(x) for x in packed])
770 packed[1] = struct.pack("!H", length)
771 return ''.join(packed)
772
773 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800774 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700775 obj = push_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -0700776 _type = reader.read("!H")[0]
777 assert(_type == 17)
778 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800779 orig_reader = reader
780 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700781 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700782 reader.skip(2)
783 return obj
784
785 def __eq__(self, other):
786 if type(self) != type(other): return False
787 if self.ethertype != other.ethertype: return False
788 return True
789
Rich Lanec2ee4b82013-04-24 17:12:38 -0700790 def pretty_print(self, q):
791 q.text("push_vlan {")
792 with q.group():
793 with q.indent(2):
794 q.breakable()
795 q.text("ethertype = ");
796 q.text("%#x" % self.ethertype)
797 q.breakable()
798 q.text('}')
799
Rich Lane7dcdf022013-12-11 14:45:27 -0800800action.subtypes[17] = push_vlan
801
802class set_field(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700803 type = 25
Rich Lanec2ee4b82013-04-24 17:12:38 -0700804
805 def __init__(self, field=None):
806 if field != None:
807 self.field = field
808 else:
Rich Laned53156a2013-08-05 17:17:33 -0700809 self.field = None
Rich Lanec2ee4b82013-04-24 17:12:38 -0700810 return
811
812 def pack(self):
813 packed = []
814 packed.append(struct.pack("!H", self.type))
815 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Rich Laned53156a2013-08-05 17:17:33 -0700816 packed.append(self.field.pack())
Rich Lanec2ee4b82013-04-24 17:12:38 -0700817 length = sum([len(x) for x in packed])
Rich Laned53156a2013-08-05 17:17:33 -0700818 packed.append(loxi.generic_util.pad_to(8, length))
819 length += len(packed[-1])
Rich Lanec2ee4b82013-04-24 17:12:38 -0700820 packed[1] = struct.pack("!H", length)
821 return ''.join(packed)
822
823 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800824 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700825 obj = set_field()
Dan Talaycof6202252013-07-02 01:00:29 -0700826 _type = reader.read("!H")[0]
827 assert(_type == 25)
828 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800829 orig_reader = reader
830 reader = orig_reader.slice(_len - (2 + 2))
831 obj.field = oxm.oxm.unpack(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700832 return obj
833
834 def __eq__(self, other):
835 if type(self) != type(other): return False
836 if self.field != other.field: return False
837 return True
838
Rich Lanec2ee4b82013-04-24 17:12:38 -0700839 def pretty_print(self, q):
840 q.text("set_field {")
841 with q.group():
842 with q.indent(2):
843 q.breakable()
844 q.text("field = ");
845 q.pp(self.field)
846 q.breakable()
847 q.text('}')
848
Rich Lane7dcdf022013-12-11 14:45:27 -0800849action.subtypes[25] = set_field
850
851class set_mpls_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700852 type = 15
Rich Lanec2ee4b82013-04-24 17:12:38 -0700853
854 def __init__(self, mpls_ttl=None):
855 if mpls_ttl != None:
856 self.mpls_ttl = mpls_ttl
857 else:
858 self.mpls_ttl = 0
859 return
860
861 def pack(self):
862 packed = []
863 packed.append(struct.pack("!H", self.type))
864 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
865 packed.append(struct.pack("!B", self.mpls_ttl))
866 packed.append('\x00' * 3)
867 length = sum([len(x) for x in packed])
868 packed[1] = struct.pack("!H", length)
869 return ''.join(packed)
870
871 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800872 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700873 obj = set_mpls_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700874 _type = reader.read("!H")[0]
875 assert(_type == 15)
876 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800877 orig_reader = reader
878 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700879 obj.mpls_ttl = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700880 reader.skip(3)
881 return obj
882
883 def __eq__(self, other):
884 if type(self) != type(other): return False
885 if self.mpls_ttl != other.mpls_ttl: return False
886 return True
887
Rich Lanec2ee4b82013-04-24 17:12:38 -0700888 def pretty_print(self, q):
889 q.text("set_mpls_ttl {")
890 with q.group():
891 with q.indent(2):
892 q.breakable()
893 q.text("mpls_ttl = ");
894 q.text("%#x" % self.mpls_ttl)
895 q.breakable()
896 q.text('}')
897
Rich Lane7dcdf022013-12-11 14:45:27 -0800898action.subtypes[15] = set_mpls_ttl
899
900class set_nw_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700901 type = 23
Rich Lanec2ee4b82013-04-24 17:12:38 -0700902
903 def __init__(self, nw_ttl=None):
904 if nw_ttl != None:
905 self.nw_ttl = nw_ttl
906 else:
907 self.nw_ttl = 0
908 return
909
910 def pack(self):
911 packed = []
912 packed.append(struct.pack("!H", self.type))
913 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
914 packed.append(struct.pack("!B", self.nw_ttl))
915 packed.append('\x00' * 3)
916 length = sum([len(x) for x in packed])
917 packed[1] = struct.pack("!H", length)
918 return ''.join(packed)
919
920 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800921 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700922 obj = set_nw_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700923 _type = reader.read("!H")[0]
924 assert(_type == 23)
925 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800926 orig_reader = reader
927 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700928 obj.nw_ttl = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700929 reader.skip(3)
930 return obj
931
932 def __eq__(self, other):
933 if type(self) != type(other): return False
934 if self.nw_ttl != other.nw_ttl: return False
935 return True
936
Rich Lanec2ee4b82013-04-24 17:12:38 -0700937 def pretty_print(self, q):
938 q.text("set_nw_ttl {")
939 with q.group():
940 with q.indent(2):
941 q.breakable()
942 q.text("nw_ttl = ");
943 q.text("%#x" % self.nw_ttl)
944 q.breakable()
945 q.text('}')
946
Rich Lane7dcdf022013-12-11 14:45:27 -0800947action.subtypes[23] = set_nw_ttl
948
949class set_queue(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700950 type = 21
Rich Lanec2ee4b82013-04-24 17:12:38 -0700951
952 def __init__(self, queue_id=None):
953 if queue_id != None:
954 self.queue_id = queue_id
955 else:
956 self.queue_id = 0
957 return
958
959 def pack(self):
960 packed = []
961 packed.append(struct.pack("!H", self.type))
962 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
963 packed.append(struct.pack("!L", self.queue_id))
964 length = sum([len(x) for x in packed])
965 packed[1] = struct.pack("!H", length)
966 return ''.join(packed)
967
968 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800969 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700970 obj = set_queue()
Dan Talaycof6202252013-07-02 01:00:29 -0700971 _type = reader.read("!H")[0]
972 assert(_type == 21)
973 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800974 orig_reader = reader
975 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700976 obj.queue_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700977 return obj
978
979 def __eq__(self, other):
980 if type(self) != type(other): return False
981 if self.queue_id != other.queue_id: return False
982 return True
983
Rich Lanec2ee4b82013-04-24 17:12:38 -0700984 def pretty_print(self, q):
985 q.text("set_queue {")
986 with q.group():
987 with q.indent(2):
988 q.breakable()
989 q.text("queue_id = ");
990 q.text("%#x" % self.queue_id)
991 q.breakable()
992 q.text('}')
993
Rich Lane7dcdf022013-12-11 14:45:27 -0800994action.subtypes[21] = set_queue
Rich Lanec2ee4b82013-04-24 17:12:38 -0700995
Rich Lanec2ee4b82013-04-24 17:12:38 -0700996