blob: 1c1714cc39148ffea75771d7b09143d789dbbde3 [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 Lanec2ee4b82013-04-24 17:12:38 -070019import util
20import loxi.generic_util
Rich Lanec2ee4b82013-04-24 17:12:38 -070021
Rich Lane7dcdf022013-12-11 14:45:27 -080022class action(loxi.OFObject):
23 subtypes = {}
Rich Lanec2ee4b82013-04-24 17:12:38 -070024
Rich Lane7dcdf022013-12-11 14:45:27 -080025 @staticmethod
26 def unpack(reader):
27 subtype, = reader.peek('!H', 0)
28 try:
29 subclass = action.subtypes[subtype]
30 except KeyError:
31 raise loxi.ProtocolError("unknown action subtype %#x" % subtype)
32 return subclass.unpack(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -070033
Rich Lane7dcdf022013-12-11 14:45:27 -080034
35class experimenter(action):
36 subtypes = {}
37
38 @staticmethod
39 def unpack(reader):
40 subtype, = reader.peek('!L', 4)
41 try:
42 subclass = experimenter.subtypes[subtype]
43 except KeyError:
44 raise loxi.ProtocolError("unknown experimenter action subtype %#x" % subtype)
45 return subclass.unpack(reader)
46
47action.subtypes[65535] = experimenter
48
49class bsn(experimenter):
50 subtypes = {}
51
52 @staticmethod
53 def unpack(reader):
54 subtype, = reader.peek('!L', 8)
55 try:
56 subclass = bsn.subtypes[subtype]
57 except KeyError:
58 raise loxi.ProtocolError("unknown bsn experimenter action subtype %#x" % subtype)
59 return subclass.unpack(reader)
60
61experimenter.subtypes[6035143] = bsn
62
63class bsn_mirror(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -070064 type = 65535
65 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -070066 subtype = 1
67
68 def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None):
69 if dest_port != None:
70 self.dest_port = dest_port
71 else:
72 self.dest_port = 0
73 if vlan_tag != None:
74 self.vlan_tag = vlan_tag
75 else:
76 self.vlan_tag = 0
77 if copy_stage != None:
78 self.copy_stage = copy_stage
79 else:
80 self.copy_stage = 0
81 return
82
83 def pack(self):
84 packed = []
85 packed.append(struct.pack("!H", self.type))
86 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
87 packed.append(struct.pack("!L", self.experimenter))
88 packed.append(struct.pack("!L", self.subtype))
89 packed.append(struct.pack("!L", self.dest_port))
90 packed.append(struct.pack("!L", self.vlan_tag))
91 packed.append(struct.pack("!B", self.copy_stage))
92 packed.append('\x00' * 3)
93 length = sum([len(x) for x in packed])
94 packed[1] = struct.pack("!H", length)
95 return ''.join(packed)
96
97 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -080098 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -070099 obj = bsn_mirror()
Dan Talaycof6202252013-07-02 01:00:29 -0700100 _type = reader.read("!H")[0]
101 assert(_type == 65535)
102 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800103 orig_reader = reader
104 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700105 _experimenter = reader.read("!L")[0]
106 assert(_experimenter == 6035143)
107 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700108 assert(_subtype == 1)
Dan Talaycof6202252013-07-02 01:00:29 -0700109 obj.dest_port = reader.read("!L")[0]
110 obj.vlan_tag = reader.read("!L")[0]
111 obj.copy_stage = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700112 reader.skip(3)
113 return obj
114
115 def __eq__(self, other):
116 if type(self) != type(other): return False
117 if self.dest_port != other.dest_port: return False
118 if self.vlan_tag != other.vlan_tag: return False
119 if self.copy_stage != other.copy_stage: return False
120 return True
121
Rich Lanec2ee4b82013-04-24 17:12:38 -0700122 def pretty_print(self, q):
123 q.text("bsn_mirror {")
124 with q.group():
125 with q.indent(2):
126 q.breakable()
127 q.text("dest_port = ");
128 q.text("%#x" % self.dest_port)
129 q.text(","); q.breakable()
130 q.text("vlan_tag = ");
131 q.text("%#x" % self.vlan_tag)
132 q.text(","); q.breakable()
133 q.text("copy_stage = ");
134 q.text("%#x" % self.copy_stage)
135 q.breakable()
136 q.text('}')
137
Rich Lane7dcdf022013-12-11 14:45:27 -0800138bsn.subtypes[1] = bsn_mirror
139
140class bsn_set_tunnel_dst(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700141 type = 65535
142 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -0700143 subtype = 2
144
145 def __init__(self, dst=None):
146 if dst != None:
147 self.dst = dst
148 else:
149 self.dst = 0
150 return
151
152 def pack(self):
153 packed = []
154 packed.append(struct.pack("!H", self.type))
155 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
156 packed.append(struct.pack("!L", self.experimenter))
157 packed.append(struct.pack("!L", self.subtype))
158 packed.append(struct.pack("!L", self.dst))
159 length = sum([len(x) for x in packed])
160 packed[1] = struct.pack("!H", length)
161 return ''.join(packed)
162
163 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800164 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700165 obj = bsn_set_tunnel_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700166 _type = reader.read("!H")[0]
167 assert(_type == 65535)
168 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800169 orig_reader = reader
170 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700171 _experimenter = reader.read("!L")[0]
172 assert(_experimenter == 6035143)
173 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700174 assert(_subtype == 2)
Dan Talaycof6202252013-07-02 01:00:29 -0700175 obj.dst = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700176 return obj
177
178 def __eq__(self, other):
179 if type(self) != type(other): return False
180 if self.dst != other.dst: return False
181 return True
182
Rich Lanec2ee4b82013-04-24 17:12:38 -0700183 def pretty_print(self, q):
184 q.text("bsn_set_tunnel_dst {")
185 with q.group():
186 with q.indent(2):
187 q.breakable()
188 q.text("dst = ");
189 q.text("%#x" % self.dst)
190 q.breakable()
191 q.text('}')
192
Rich Lane7dcdf022013-12-11 14:45:27 -0800193bsn.subtypes[2] = bsn_set_tunnel_dst
194
195class copy_ttl_in(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700196 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -0700197
198 def __init__(self):
199 return
200
201 def pack(self):
202 packed = []
203 packed.append(struct.pack("!H", self.type))
204 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
205 packed.append('\x00' * 4)
206 length = sum([len(x) for x in packed])
207 packed[1] = struct.pack("!H", length)
208 return ''.join(packed)
209
210 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800211 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700212 obj = copy_ttl_in()
Dan Talaycof6202252013-07-02 01:00:29 -0700213 _type = reader.read("!H")[0]
214 assert(_type == 12)
215 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800216 orig_reader = reader
217 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700218 reader.skip(4)
219 return obj
220
221 def __eq__(self, other):
222 if type(self) != type(other): return False
223 return True
224
Rich Lanec2ee4b82013-04-24 17:12:38 -0700225 def pretty_print(self, q):
226 q.text("copy_ttl_in {")
227 with q.group():
228 with q.indent(2):
229 q.breakable()
230 q.breakable()
231 q.text('}')
232
Rich Lane7dcdf022013-12-11 14:45:27 -0800233action.subtypes[12] = copy_ttl_in
234
235class copy_ttl_out(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700236 type = 11
Rich Lanec2ee4b82013-04-24 17:12:38 -0700237
238 def __init__(self):
239 return
240
241 def pack(self):
242 packed = []
243 packed.append(struct.pack("!H", self.type))
244 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
245 packed.append('\x00' * 4)
246 length = sum([len(x) for x in packed])
247 packed[1] = struct.pack("!H", length)
248 return ''.join(packed)
249
250 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800251 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700252 obj = copy_ttl_out()
Dan Talaycof6202252013-07-02 01:00:29 -0700253 _type = reader.read("!H")[0]
254 assert(_type == 11)
255 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800256 orig_reader = reader
257 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700258 reader.skip(4)
259 return obj
260
261 def __eq__(self, other):
262 if type(self) != type(other): return False
263 return True
264
Rich Lanec2ee4b82013-04-24 17:12:38 -0700265 def pretty_print(self, q):
266 q.text("copy_ttl_out {")
267 with q.group():
268 with q.indent(2):
269 q.breakable()
270 q.breakable()
271 q.text('}')
272
Rich Lane7dcdf022013-12-11 14:45:27 -0800273action.subtypes[11] = copy_ttl_out
274
275class dec_mpls_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700276 type = 16
Rich Lanec2ee4b82013-04-24 17:12:38 -0700277
278 def __init__(self):
279 return
280
281 def pack(self):
282 packed = []
283 packed.append(struct.pack("!H", self.type))
284 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
285 packed.append('\x00' * 4)
286 length = sum([len(x) for x in packed])
287 packed[1] = struct.pack("!H", length)
288 return ''.join(packed)
289
290 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800291 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700292 obj = dec_mpls_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700293 _type = reader.read("!H")[0]
294 assert(_type == 16)
295 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800296 orig_reader = reader
297 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700298 reader.skip(4)
299 return obj
300
301 def __eq__(self, other):
302 if type(self) != type(other): return False
303 return True
304
Rich Lanec2ee4b82013-04-24 17:12:38 -0700305 def pretty_print(self, q):
306 q.text("dec_mpls_ttl {")
307 with q.group():
308 with q.indent(2):
309 q.breakable()
310 q.breakable()
311 q.text('}')
312
Rich Lane7dcdf022013-12-11 14:45:27 -0800313action.subtypes[16] = dec_mpls_ttl
314
315class dec_nw_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700316 type = 24
Rich Lanec2ee4b82013-04-24 17:12:38 -0700317
318 def __init__(self):
319 return
320
321 def pack(self):
322 packed = []
323 packed.append(struct.pack("!H", self.type))
324 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
325 packed.append('\x00' * 4)
326 length = sum([len(x) for x in packed])
327 packed[1] = struct.pack("!H", length)
328 return ''.join(packed)
329
330 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800331 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700332 obj = dec_nw_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700333 _type = reader.read("!H")[0]
334 assert(_type == 24)
335 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800336 orig_reader = reader
337 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700338 reader.skip(4)
339 return obj
340
341 def __eq__(self, other):
342 if type(self) != type(other): return False
343 return True
344
Rich Lanec2ee4b82013-04-24 17:12:38 -0700345 def pretty_print(self, q):
346 q.text("dec_nw_ttl {")
347 with q.group():
348 with q.indent(2):
349 q.breakable()
350 q.breakable()
351 q.text('}')
352
Rich Lane7dcdf022013-12-11 14:45:27 -0800353action.subtypes[24] = dec_nw_ttl
354
355class group(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700356 type = 22
Rich Lanec2ee4b82013-04-24 17:12:38 -0700357
358 def __init__(self, group_id=None):
359 if group_id != None:
360 self.group_id = group_id
361 else:
362 self.group_id = 0
363 return
364
365 def pack(self):
366 packed = []
367 packed.append(struct.pack("!H", self.type))
368 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
369 packed.append(struct.pack("!L", self.group_id))
370 length = sum([len(x) for x in packed])
371 packed[1] = struct.pack("!H", length)
372 return ''.join(packed)
373
374 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800375 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700376 obj = group()
Dan Talaycof6202252013-07-02 01:00:29 -0700377 _type = reader.read("!H")[0]
378 assert(_type == 22)
379 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800380 orig_reader = reader
381 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700382 obj.group_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700383 return obj
384
385 def __eq__(self, other):
386 if type(self) != type(other): return False
387 if self.group_id != other.group_id: return False
388 return True
389
Rich Lanec2ee4b82013-04-24 17:12:38 -0700390 def pretty_print(self, q):
391 q.text("group {")
392 with q.group():
393 with q.indent(2):
394 q.breakable()
395 q.text("group_id = ");
396 q.text("%#x" % self.group_id)
397 q.breakable()
398 q.text('}')
399
Rich Lane7dcdf022013-12-11 14:45:27 -0800400action.subtypes[22] = group
401
402class nicira(experimenter):
403 subtypes = {}
404
405 @staticmethod
406 def unpack(reader):
407 subtype, = reader.peek('!H', 8)
408 try:
409 subclass = nicira.subtypes[subtype]
410 except KeyError:
411 raise loxi.ProtocolError("unknown nicira experimenter action subtype %#x" % subtype)
412 return subclass.unpack(reader)
413
414experimenter.subtypes[8992] = nicira
415
416class nicira_dec_ttl(nicira):
Dan Talaycof6202252013-07-02 01:00:29 -0700417 type = 65535
418 experimenter = 8992
Rich Lanec2ee4b82013-04-24 17:12:38 -0700419 subtype = 18
420
421 def __init__(self):
422 return
423
424 def pack(self):
425 packed = []
426 packed.append(struct.pack("!H", self.type))
427 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
428 packed.append(struct.pack("!L", self.experimenter))
429 packed.append(struct.pack("!H", self.subtype))
430 packed.append('\x00' * 2)
431 packed.append('\x00' * 4)
432 length = sum([len(x) for x in packed])
433 packed[1] = struct.pack("!H", length)
434 return ''.join(packed)
435
436 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800437 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700438 obj = nicira_dec_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700439 _type = reader.read("!H")[0]
440 assert(_type == 65535)
441 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800442 orig_reader = reader
443 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700444 _experimenter = reader.read("!L")[0]
445 assert(_experimenter == 8992)
446 _subtype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700447 assert(_subtype == 18)
448 reader.skip(2)
449 reader.skip(4)
450 return obj
451
452 def __eq__(self, other):
453 if type(self) != type(other): return False
454 return True
455
Rich Lanec2ee4b82013-04-24 17:12:38 -0700456 def pretty_print(self, q):
457 q.text("nicira_dec_ttl {")
458 with q.group():
459 with q.indent(2):
460 q.breakable()
461 q.breakable()
462 q.text('}')
463
Rich Lane7dcdf022013-12-11 14:45:27 -0800464nicira.subtypes[18] = nicira_dec_ttl
465
466class output(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700467 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700468
469 def __init__(self, port=None, max_len=None):
470 if port != None:
471 self.port = port
472 else:
473 self.port = 0
474 if max_len != None:
475 self.max_len = max_len
476 else:
477 self.max_len = 0
478 return
479
480 def pack(self):
481 packed = []
482 packed.append(struct.pack("!H", self.type))
483 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700484 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700485 packed.append(struct.pack("!H", self.max_len))
486 packed.append('\x00' * 6)
487 length = sum([len(x) for x in packed])
488 packed[1] = struct.pack("!H", length)
489 return ''.join(packed)
490
491 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800492 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700493 obj = output()
Dan Talaycof6202252013-07-02 01:00:29 -0700494 _type = reader.read("!H")[0]
495 assert(_type == 0)
496 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800497 orig_reader = reader
498 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700499 obj.port = util.unpack_port_no(reader)
500 obj.max_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700501 reader.skip(6)
502 return obj
503
504 def __eq__(self, other):
505 if type(self) != type(other): return False
506 if self.port != other.port: return False
507 if self.max_len != other.max_len: return False
508 return True
509
Rich Lanec2ee4b82013-04-24 17:12:38 -0700510 def pretty_print(self, q):
511 q.text("output {")
512 with q.group():
513 with q.indent(2):
514 q.breakable()
515 q.text("port = ");
516 q.text(util.pretty_port(self.port))
517 q.text(","); q.breakable()
518 q.text("max_len = ");
519 q.text("%#x" % self.max_len)
520 q.breakable()
521 q.text('}')
522
Rich Lane7dcdf022013-12-11 14:45:27 -0800523action.subtypes[0] = output
524
525class pop_mpls(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700526 type = 20
Rich Lanec2ee4b82013-04-24 17:12:38 -0700527
528 def __init__(self, ethertype=None):
529 if ethertype != None:
530 self.ethertype = ethertype
531 else:
532 self.ethertype = 0
533 return
534
535 def pack(self):
536 packed = []
537 packed.append(struct.pack("!H", self.type))
538 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
539 packed.append(struct.pack("!H", self.ethertype))
540 packed.append('\x00' * 2)
541 length = sum([len(x) for x in packed])
542 packed[1] = struct.pack("!H", length)
543 return ''.join(packed)
544
545 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800546 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700547 obj = pop_mpls()
Dan Talaycof6202252013-07-02 01:00:29 -0700548 _type = reader.read("!H")[0]
549 assert(_type == 20)
550 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800551 orig_reader = reader
552 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700553 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700554 reader.skip(2)
555 return obj
556
557 def __eq__(self, other):
558 if type(self) != type(other): return False
559 if self.ethertype != other.ethertype: return False
560 return True
561
Rich Lanec2ee4b82013-04-24 17:12:38 -0700562 def pretty_print(self, q):
563 q.text("pop_mpls {")
564 with q.group():
565 with q.indent(2):
566 q.breakable()
567 q.text("ethertype = ");
568 q.text("%#x" % self.ethertype)
569 q.breakable()
570 q.text('}')
571
Rich Lane7dcdf022013-12-11 14:45:27 -0800572action.subtypes[20] = pop_mpls
573
574class pop_pbb(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700575 type = 27
Rich Lanec2ee4b82013-04-24 17:12:38 -0700576
577 def __init__(self):
578 return
579
580 def pack(self):
581 packed = []
582 packed.append(struct.pack("!H", self.type))
583 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
584 packed.append('\x00' * 4)
585 length = sum([len(x) for x in packed])
586 packed[1] = struct.pack("!H", length)
587 return ''.join(packed)
588
589 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800590 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700591 obj = pop_pbb()
Dan Talaycof6202252013-07-02 01:00:29 -0700592 _type = reader.read("!H")[0]
593 assert(_type == 27)
594 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800595 orig_reader = reader
596 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700597 reader.skip(4)
598 return obj
599
600 def __eq__(self, other):
601 if type(self) != type(other): return False
602 return True
603
Rich Lanec2ee4b82013-04-24 17:12:38 -0700604 def pretty_print(self, q):
605 q.text("pop_pbb {")
606 with q.group():
607 with q.indent(2):
608 q.breakable()
609 q.breakable()
610 q.text('}')
611
Rich Lane7dcdf022013-12-11 14:45:27 -0800612action.subtypes[27] = pop_pbb
613
614class pop_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700615 type = 18
Rich Lanec2ee4b82013-04-24 17:12:38 -0700616
617 def __init__(self):
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('\x00' * 4)
625 length = sum([len(x) for x in packed])
626 packed[1] = struct.pack("!H", length)
627 return ''.join(packed)
628
629 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800630 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700631 obj = pop_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -0700632 _type = reader.read("!H")[0]
633 assert(_type == 18)
634 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800635 orig_reader = reader
636 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700637 reader.skip(4)
638 return obj
639
640 def __eq__(self, other):
641 if type(self) != type(other): return False
642 return True
643
Rich Lanec2ee4b82013-04-24 17:12:38 -0700644 def pretty_print(self, q):
645 q.text("pop_vlan {")
646 with q.group():
647 with q.indent(2):
648 q.breakable()
649 q.breakable()
650 q.text('}')
651
Rich Lane7dcdf022013-12-11 14:45:27 -0800652action.subtypes[18] = pop_vlan
653
654class push_mpls(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700655 type = 19
Rich Lanec2ee4b82013-04-24 17:12:38 -0700656
657 def __init__(self, ethertype=None):
658 if ethertype != None:
659 self.ethertype = ethertype
660 else:
661 self.ethertype = 0
662 return
663
664 def pack(self):
665 packed = []
666 packed.append(struct.pack("!H", self.type))
667 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
668 packed.append(struct.pack("!H", self.ethertype))
669 packed.append('\x00' * 2)
670 length = sum([len(x) for x in packed])
671 packed[1] = struct.pack("!H", length)
672 return ''.join(packed)
673
674 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800675 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700676 obj = push_mpls()
Dan Talaycof6202252013-07-02 01:00:29 -0700677 _type = reader.read("!H")[0]
678 assert(_type == 19)
679 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800680 orig_reader = reader
681 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700682 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700683 reader.skip(2)
684 return obj
685
686 def __eq__(self, other):
687 if type(self) != type(other): return False
688 if self.ethertype != other.ethertype: return False
689 return True
690
Rich Lanec2ee4b82013-04-24 17:12:38 -0700691 def pretty_print(self, q):
692 q.text("push_mpls {")
693 with q.group():
694 with q.indent(2):
695 q.breakable()
696 q.text("ethertype = ");
697 q.text("%#x" % self.ethertype)
698 q.breakable()
699 q.text('}')
700
Rich Lane7dcdf022013-12-11 14:45:27 -0800701action.subtypes[19] = push_mpls
702
703class push_pbb(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700704 type = 26
Rich Lanec2ee4b82013-04-24 17:12:38 -0700705
706 def __init__(self, ethertype=None):
707 if ethertype != None:
708 self.ethertype = ethertype
709 else:
710 self.ethertype = 0
711 return
712
713 def pack(self):
714 packed = []
715 packed.append(struct.pack("!H", self.type))
716 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
717 packed.append(struct.pack("!H", self.ethertype))
718 packed.append('\x00' * 2)
719 length = sum([len(x) for x in packed])
720 packed[1] = struct.pack("!H", length)
721 return ''.join(packed)
722
723 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800724 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700725 obj = push_pbb()
Dan Talaycof6202252013-07-02 01:00:29 -0700726 _type = reader.read("!H")[0]
727 assert(_type == 26)
728 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800729 orig_reader = reader
730 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700731 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700732 reader.skip(2)
733 return obj
734
735 def __eq__(self, other):
736 if type(self) != type(other): return False
737 if self.ethertype != other.ethertype: return False
738 return True
739
Rich Lanec2ee4b82013-04-24 17:12:38 -0700740 def pretty_print(self, q):
741 q.text("push_pbb {")
742 with q.group():
743 with q.indent(2):
744 q.breakable()
745 q.text("ethertype = ");
746 q.text("%#x" % self.ethertype)
747 q.breakable()
748 q.text('}')
749
Rich Lane7dcdf022013-12-11 14:45:27 -0800750action.subtypes[26] = push_pbb
751
752class push_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700753 type = 17
Rich Lanec2ee4b82013-04-24 17:12:38 -0700754
755 def __init__(self, ethertype=None):
756 if ethertype != None:
757 self.ethertype = ethertype
758 else:
759 self.ethertype = 0
760 return
761
762 def pack(self):
763 packed = []
764 packed.append(struct.pack("!H", self.type))
765 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
766 packed.append(struct.pack("!H", self.ethertype))
767 packed.append('\x00' * 2)
768 length = sum([len(x) for x in packed])
769 packed[1] = struct.pack("!H", length)
770 return ''.join(packed)
771
772 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800773 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700774 obj = push_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -0700775 _type = reader.read("!H")[0]
776 assert(_type == 17)
777 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800778 orig_reader = reader
779 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700780 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700781 reader.skip(2)
782 return obj
783
784 def __eq__(self, other):
785 if type(self) != type(other): return False
786 if self.ethertype != other.ethertype: return False
787 return True
788
Rich Lanec2ee4b82013-04-24 17:12:38 -0700789 def pretty_print(self, q):
790 q.text("push_vlan {")
791 with q.group():
792 with q.indent(2):
793 q.breakable()
794 q.text("ethertype = ");
795 q.text("%#x" % self.ethertype)
796 q.breakable()
797 q.text('}')
798
Rich Lane7dcdf022013-12-11 14:45:27 -0800799action.subtypes[17] = push_vlan
800
801class set_field(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700802 type = 25
Rich Lanec2ee4b82013-04-24 17:12:38 -0700803
804 def __init__(self, field=None):
805 if field != None:
806 self.field = field
807 else:
Rich Laned53156a2013-08-05 17:17:33 -0700808 self.field = None
Rich Lanec2ee4b82013-04-24 17:12:38 -0700809 return
810
811 def pack(self):
812 packed = []
813 packed.append(struct.pack("!H", self.type))
814 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Rich Laned53156a2013-08-05 17:17:33 -0700815 packed.append(self.field.pack())
Rich Lanec2ee4b82013-04-24 17:12:38 -0700816 length = sum([len(x) for x in packed])
Rich Laned53156a2013-08-05 17:17:33 -0700817 packed.append(loxi.generic_util.pad_to(8, length))
818 length += len(packed[-1])
Rich Lanec2ee4b82013-04-24 17:12:38 -0700819 packed[1] = struct.pack("!H", length)
820 return ''.join(packed)
821
822 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800823 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700824 obj = set_field()
Dan Talaycof6202252013-07-02 01:00:29 -0700825 _type = reader.read("!H")[0]
826 assert(_type == 25)
827 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800828 orig_reader = reader
829 reader = orig_reader.slice(_len - (2 + 2))
830 obj.field = oxm.oxm.unpack(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700831 return obj
832
833 def __eq__(self, other):
834 if type(self) != type(other): return False
835 if self.field != other.field: return False
836 return True
837
Rich Lanec2ee4b82013-04-24 17:12:38 -0700838 def pretty_print(self, q):
839 q.text("set_field {")
840 with q.group():
841 with q.indent(2):
842 q.breakable()
843 q.text("field = ");
844 q.pp(self.field)
845 q.breakable()
846 q.text('}')
847
Rich Lane7dcdf022013-12-11 14:45:27 -0800848action.subtypes[25] = set_field
849
850class set_mpls_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700851 type = 15
Rich Lanec2ee4b82013-04-24 17:12:38 -0700852
853 def __init__(self, mpls_ttl=None):
854 if mpls_ttl != None:
855 self.mpls_ttl = mpls_ttl
856 else:
857 self.mpls_ttl = 0
858 return
859
860 def pack(self):
861 packed = []
862 packed.append(struct.pack("!H", self.type))
863 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
864 packed.append(struct.pack("!B", self.mpls_ttl))
865 packed.append('\x00' * 3)
866 length = sum([len(x) for x in packed])
867 packed[1] = struct.pack("!H", length)
868 return ''.join(packed)
869
870 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800871 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700872 obj = set_mpls_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700873 _type = reader.read("!H")[0]
874 assert(_type == 15)
875 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800876 orig_reader = reader
877 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700878 obj.mpls_ttl = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700879 reader.skip(3)
880 return obj
881
882 def __eq__(self, other):
883 if type(self) != type(other): return False
884 if self.mpls_ttl != other.mpls_ttl: return False
885 return True
886
Rich Lanec2ee4b82013-04-24 17:12:38 -0700887 def pretty_print(self, q):
888 q.text("set_mpls_ttl {")
889 with q.group():
890 with q.indent(2):
891 q.breakable()
892 q.text("mpls_ttl = ");
893 q.text("%#x" % self.mpls_ttl)
894 q.breakable()
895 q.text('}')
896
Rich Lane7dcdf022013-12-11 14:45:27 -0800897action.subtypes[15] = set_mpls_ttl
898
899class set_nw_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700900 type = 23
Rich Lanec2ee4b82013-04-24 17:12:38 -0700901
902 def __init__(self, nw_ttl=None):
903 if nw_ttl != None:
904 self.nw_ttl = nw_ttl
905 else:
906 self.nw_ttl = 0
907 return
908
909 def pack(self):
910 packed = []
911 packed.append(struct.pack("!H", self.type))
912 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
913 packed.append(struct.pack("!B", self.nw_ttl))
914 packed.append('\x00' * 3)
915 length = sum([len(x) for x in packed])
916 packed[1] = struct.pack("!H", length)
917 return ''.join(packed)
918
919 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800920 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700921 obj = set_nw_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700922 _type = reader.read("!H")[0]
923 assert(_type == 23)
924 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800925 orig_reader = reader
926 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700927 obj.nw_ttl = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700928 reader.skip(3)
929 return obj
930
931 def __eq__(self, other):
932 if type(self) != type(other): return False
933 if self.nw_ttl != other.nw_ttl: return False
934 return True
935
Rich Lanec2ee4b82013-04-24 17:12:38 -0700936 def pretty_print(self, q):
937 q.text("set_nw_ttl {")
938 with q.group():
939 with q.indent(2):
940 q.breakable()
941 q.text("nw_ttl = ");
942 q.text("%#x" % self.nw_ttl)
943 q.breakable()
944 q.text('}')
945
Rich Lane7dcdf022013-12-11 14:45:27 -0800946action.subtypes[23] = set_nw_ttl
947
948class set_queue(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700949 type = 21
Rich Lanec2ee4b82013-04-24 17:12:38 -0700950
951 def __init__(self, queue_id=None):
952 if queue_id != None:
953 self.queue_id = queue_id
954 else:
955 self.queue_id = 0
956 return
957
958 def pack(self):
959 packed = []
960 packed.append(struct.pack("!H", self.type))
961 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
962 packed.append(struct.pack("!L", self.queue_id))
963 length = sum([len(x) for x in packed])
964 packed[1] = struct.pack("!H", length)
965 return ''.join(packed)
966
967 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800968 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700969 obj = set_queue()
Dan Talaycof6202252013-07-02 01:00:29 -0700970 _type = reader.read("!H")[0]
971 assert(_type == 21)
972 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800973 orig_reader = reader
974 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700975 obj.queue_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700976 return obj
977
978 def __eq__(self, other):
979 if type(self) != type(other): return False
980 if self.queue_id != other.queue_id: return False
981 return True
982
Rich Lanec2ee4b82013-04-24 17:12:38 -0700983 def pretty_print(self, q):
984 q.text("set_queue {")
985 with q.group():
986 with q.indent(2):
987 q.breakable()
988 q.text("queue_id = ");
989 q.text("%#x" % self.queue_id)
990 q.breakable()
991 q.text('}')
992
Rich Lane7dcdf022013-12-11 14:45:27 -0800993action.subtypes[21] = set_queue
Rich Lanec2ee4b82013-04-24 17:12:38 -0700994
Rich Lanec2ee4b82013-04-24 17:12:38 -0700995