blob: 53056ea98724e4685194c90a7114a11905bab84f [file] [log] [blame]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001# Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2# Copyright (c) 2011, 2012 Open Networking Foundation
3# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
Dan Talaycof6202252013-07-02 01:00:29 -07004# See the file LICENSE.pyloxi which should have been included in the source distribution
Rich Lanec2ee4b82013-04-24 17:12:38 -07005
Rich Lane7dcdf022013-12-11 14:45:27 -08006# Automatically generated by LOXI from template module.py
Rich Lanec2ee4b82013-04-24 17:12:38 -07007# Do not modify
8
9import struct
Rich Lane7dcdf022013-12-11 14:45:27 -080010import loxi
Rich Lanec2ee4b82013-04-24 17:12:38 -070011import const
Rich Lane7dcdf022013-12-11 14:45:27 -080012import common
13import action
14import instruction
Rich Lanec2ee4b82013-04-24 17:12:38 -070015import util
16import loxi.generic_util
Rich Lanec2ee4b82013-04-24 17:12:38 -070017
Rich Lane7dcdf022013-12-11 14:45:27 -080018class action(loxi.OFObject):
19 subtypes = {}
Rich Lanec2ee4b82013-04-24 17:12:38 -070020
Rich Lane95f7fc92014-01-27 17:08:16 -080021
22 def __init__(self, type=None):
23 if type != None:
24 self.type = type
25 else:
26 self.type = 0
27 return
28
29 def pack(self):
30 packed = []
31 packed.append(struct.pack("!H", self.type))
32 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
33 packed.append('\x00' * 4)
34 length = sum([len(x) for x in packed])
35 packed[1] = struct.pack("!H", length)
36 return ''.join(packed)
37
Rich Lane7dcdf022013-12-11 14:45:27 -080038 @staticmethod
39 def unpack(reader):
40 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -080041 subclass = action.subtypes.get(subtype)
42 if subclass:
43 return subclass.unpack(reader)
44
45 obj = action()
46 obj.type = reader.read("!H")[0]
47 _len = reader.read("!H")[0]
48 orig_reader = reader
49 reader = orig_reader.slice(_len - (2 + 2))
50 reader.skip(4)
51 return obj
52
53 def __eq__(self, other):
54 if type(self) != type(other): return False
55 if self.type != other.type: return False
56 return True
57
58 def pretty_print(self, q):
59 q.text("action {")
60 with q.group():
61 with q.indent(2):
62 q.breakable()
63 q.breakable()
64 q.text('}')
Rich Lanec2ee4b82013-04-24 17:12:38 -070065
Rich Lane7dcdf022013-12-11 14:45:27 -080066
67class experimenter(action):
68 subtypes = {}
69
Rich Lane95f7fc92014-01-27 17:08:16 -080070 type = 65535
71
72 def __init__(self, experimenter=None, data=None):
73 if experimenter != None:
74 self.experimenter = experimenter
75 else:
76 self.experimenter = 0
77 if data != None:
78 self.data = data
79 else:
80 self.data = ''
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(self.data)
89 length = sum([len(x) for x in packed])
90 packed[1] = struct.pack("!H", length)
91 return ''.join(packed)
92
Rich Lane7dcdf022013-12-11 14:45:27 -080093 @staticmethod
94 def unpack(reader):
95 subtype, = reader.peek('!L', 4)
Rich Lane95f7fc92014-01-27 17:08:16 -080096 subclass = experimenter.subtypes.get(subtype)
97 if subclass:
98 return subclass.unpack(reader)
99
100 obj = experimenter()
101 _type = reader.read("!H")[0]
102 assert(_type == 65535)
103 _len = reader.read("!H")[0]
104 orig_reader = reader
105 reader = orig_reader.slice(_len - (2 + 2))
106 obj.experimenter = reader.read("!L")[0]
107 obj.data = str(reader.read_all())
108 return obj
109
110 def __eq__(self, other):
111 if type(self) != type(other): return False
112 if self.experimenter != other.experimenter: return False
113 if self.data != other.data: return False
114 return True
115
116 def pretty_print(self, q):
117 q.text("experimenter {")
118 with q.group():
119 with q.indent(2):
120 q.breakable()
121 q.text("data = ");
122 q.pp(self.data)
123 q.breakable()
124 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800125
126action.subtypes[65535] = experimenter
127
128class bsn(experimenter):
129 subtypes = {}
130
Rich Lane95f7fc92014-01-27 17:08:16 -0800131 type = 65535
132 experimenter = 6035143
133
134 def __init__(self, subtype=None):
135 if subtype != None:
136 self.subtype = subtype
137 else:
138 self.subtype = 0
139 return
140
141 def pack(self):
142 packed = []
143 packed.append(struct.pack("!H", self.type))
144 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
145 packed.append(struct.pack("!L", self.experimenter))
146 packed.append(struct.pack("!L", self.subtype))
147 packed.append('\x00' * 4)
148 length = sum([len(x) for x in packed])
149 packed[1] = struct.pack("!H", length)
150 return ''.join(packed)
151
Rich Lane7dcdf022013-12-11 14:45:27 -0800152 @staticmethod
153 def unpack(reader):
154 subtype, = reader.peek('!L', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800155 subclass = bsn.subtypes.get(subtype)
156 if subclass:
157 return subclass.unpack(reader)
158
159 obj = bsn()
160 _type = reader.read("!H")[0]
161 assert(_type == 65535)
162 _len = reader.read("!H")[0]
163 orig_reader = reader
164 reader = orig_reader.slice(_len - (2 + 2))
165 _experimenter = reader.read("!L")[0]
166 assert(_experimenter == 6035143)
167 obj.subtype = reader.read("!L")[0]
168 reader.skip(4)
169 return obj
170
171 def __eq__(self, other):
172 if type(self) != type(other): return False
173 if self.subtype != other.subtype: return False
174 return True
175
176 def pretty_print(self, q):
177 q.text("bsn {")
178 with q.group():
179 with q.indent(2):
180 q.breakable()
181 q.breakable()
182 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800183
184experimenter.subtypes[6035143] = bsn
185
186class bsn_mirror(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700187 type = 65535
188 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -0700189 subtype = 1
190
191 def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None):
192 if dest_port != None:
193 self.dest_port = dest_port
194 else:
195 self.dest_port = 0
196 if vlan_tag != None:
197 self.vlan_tag = vlan_tag
198 else:
199 self.vlan_tag = 0
200 if copy_stage != None:
201 self.copy_stage = copy_stage
202 else:
203 self.copy_stage = 0
204 return
205
206 def pack(self):
207 packed = []
208 packed.append(struct.pack("!H", self.type))
209 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
210 packed.append(struct.pack("!L", self.experimenter))
211 packed.append(struct.pack("!L", self.subtype))
212 packed.append(struct.pack("!L", self.dest_port))
213 packed.append(struct.pack("!L", self.vlan_tag))
214 packed.append(struct.pack("!B", self.copy_stage))
215 packed.append('\x00' * 3)
216 length = sum([len(x) for x in packed])
217 packed[1] = struct.pack("!H", length)
218 return ''.join(packed)
219
220 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800221 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700222 obj = bsn_mirror()
Dan Talaycof6202252013-07-02 01:00:29 -0700223 _type = reader.read("!H")[0]
224 assert(_type == 65535)
225 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800226 orig_reader = reader
227 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700228 _experimenter = reader.read("!L")[0]
229 assert(_experimenter == 6035143)
230 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700231 assert(_subtype == 1)
Dan Talaycof6202252013-07-02 01:00:29 -0700232 obj.dest_port = reader.read("!L")[0]
233 obj.vlan_tag = reader.read("!L")[0]
234 obj.copy_stage = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700235 reader.skip(3)
236 return obj
237
238 def __eq__(self, other):
239 if type(self) != type(other): return False
240 if self.dest_port != other.dest_port: return False
241 if self.vlan_tag != other.vlan_tag: return False
242 if self.copy_stage != other.copy_stage: return False
243 return True
244
Rich Lanec2ee4b82013-04-24 17:12:38 -0700245 def pretty_print(self, q):
246 q.text("bsn_mirror {")
247 with q.group():
248 with q.indent(2):
249 q.breakable()
250 q.text("dest_port = ");
251 q.text("%#x" % self.dest_port)
252 q.text(","); q.breakable()
253 q.text("vlan_tag = ");
254 q.text("%#x" % self.vlan_tag)
255 q.text(","); q.breakable()
256 q.text("copy_stage = ");
257 q.text("%#x" % self.copy_stage)
258 q.breakable()
259 q.text('}')
260
Rich Lane7dcdf022013-12-11 14:45:27 -0800261bsn.subtypes[1] = bsn_mirror
262
263class bsn_set_tunnel_dst(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700264 type = 65535
265 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -0700266 subtype = 2
267
268 def __init__(self, dst=None):
269 if dst != None:
270 self.dst = dst
271 else:
272 self.dst = 0
273 return
274
275 def pack(self):
276 packed = []
277 packed.append(struct.pack("!H", self.type))
278 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
279 packed.append(struct.pack("!L", self.experimenter))
280 packed.append(struct.pack("!L", self.subtype))
281 packed.append(struct.pack("!L", self.dst))
282 length = sum([len(x) for x in packed])
283 packed[1] = struct.pack("!H", length)
284 return ''.join(packed)
285
286 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800287 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700288 obj = bsn_set_tunnel_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700289 _type = reader.read("!H")[0]
290 assert(_type == 65535)
291 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800292 orig_reader = reader
293 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700294 _experimenter = reader.read("!L")[0]
295 assert(_experimenter == 6035143)
296 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700297 assert(_subtype == 2)
Dan Talaycof6202252013-07-02 01:00:29 -0700298 obj.dst = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700299 return obj
300
301 def __eq__(self, other):
302 if type(self) != type(other): return False
303 if self.dst != other.dst: return False
304 return True
305
Rich Lanec2ee4b82013-04-24 17:12:38 -0700306 def pretty_print(self, q):
307 q.text("bsn_set_tunnel_dst {")
308 with q.group():
309 with q.indent(2):
310 q.breakable()
311 q.text("dst = ");
312 q.text("%#x" % self.dst)
313 q.breakable()
314 q.text('}')
315
Rich Lane7dcdf022013-12-11 14:45:27 -0800316bsn.subtypes[2] = bsn_set_tunnel_dst
317
318class copy_ttl_in(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700319 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -0700320
321 def __init__(self):
322 return
323
324 def pack(self):
325 packed = []
326 packed.append(struct.pack("!H", self.type))
327 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
328 packed.append('\x00' * 4)
329 length = sum([len(x) for x in packed])
330 packed[1] = struct.pack("!H", length)
331 return ''.join(packed)
332
333 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800334 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700335 obj = copy_ttl_in()
Dan Talaycof6202252013-07-02 01:00:29 -0700336 _type = reader.read("!H")[0]
337 assert(_type == 12)
338 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800339 orig_reader = reader
340 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700341 reader.skip(4)
342 return obj
343
344 def __eq__(self, other):
345 if type(self) != type(other): return False
346 return True
347
Rich Lanec2ee4b82013-04-24 17:12:38 -0700348 def pretty_print(self, q):
349 q.text("copy_ttl_in {")
350 with q.group():
351 with q.indent(2):
352 q.breakable()
353 q.breakable()
354 q.text('}')
355
Rich Lane7dcdf022013-12-11 14:45:27 -0800356action.subtypes[12] = copy_ttl_in
357
358class copy_ttl_out(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700359 type = 11
Rich Lanec2ee4b82013-04-24 17:12:38 -0700360
361 def __init__(self):
362 return
363
364 def pack(self):
365 packed = []
366 packed.append(struct.pack("!H", self.type))
367 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
368 packed.append('\x00' * 4)
369 length = sum([len(x) for x in packed])
370 packed[1] = struct.pack("!H", length)
371 return ''.join(packed)
372
373 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800374 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700375 obj = copy_ttl_out()
Dan Talaycof6202252013-07-02 01:00:29 -0700376 _type = reader.read("!H")[0]
377 assert(_type == 11)
378 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800379 orig_reader = reader
380 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700381 reader.skip(4)
382 return obj
383
384 def __eq__(self, other):
385 if type(self) != type(other): return False
386 return True
387
Rich Lanec2ee4b82013-04-24 17:12:38 -0700388 def pretty_print(self, q):
389 q.text("copy_ttl_out {")
390 with q.group():
391 with q.indent(2):
392 q.breakable()
393 q.breakable()
394 q.text('}')
395
Rich Lane7dcdf022013-12-11 14:45:27 -0800396action.subtypes[11] = copy_ttl_out
397
398class dec_mpls_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700399 type = 16
Rich Lanec2ee4b82013-04-24 17:12:38 -0700400
401 def __init__(self):
402 return
403
404 def pack(self):
405 packed = []
406 packed.append(struct.pack("!H", self.type))
407 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
408 packed.append('\x00' * 4)
409 length = sum([len(x) for x in packed])
410 packed[1] = struct.pack("!H", length)
411 return ''.join(packed)
412
413 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800414 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700415 obj = dec_mpls_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700416 _type = reader.read("!H")[0]
417 assert(_type == 16)
418 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800419 orig_reader = reader
420 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700421 reader.skip(4)
422 return obj
423
424 def __eq__(self, other):
425 if type(self) != type(other): return False
426 return True
427
Rich Lanec2ee4b82013-04-24 17:12:38 -0700428 def pretty_print(self, q):
429 q.text("dec_mpls_ttl {")
430 with q.group():
431 with q.indent(2):
432 q.breakable()
433 q.breakable()
434 q.text('}')
435
Rich Lane7dcdf022013-12-11 14:45:27 -0800436action.subtypes[16] = dec_mpls_ttl
437
438class dec_nw_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700439 type = 24
Rich Lanec2ee4b82013-04-24 17:12:38 -0700440
441 def __init__(self):
442 return
443
444 def pack(self):
445 packed = []
446 packed.append(struct.pack("!H", self.type))
447 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
448 packed.append('\x00' * 4)
449 length = sum([len(x) for x in packed])
450 packed[1] = struct.pack("!H", length)
451 return ''.join(packed)
452
453 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800454 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700455 obj = dec_nw_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700456 _type = reader.read("!H")[0]
457 assert(_type == 24)
458 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800459 orig_reader = reader
460 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700461 reader.skip(4)
462 return obj
463
464 def __eq__(self, other):
465 if type(self) != type(other): return False
466 return True
467
Rich Lanec2ee4b82013-04-24 17:12:38 -0700468 def pretty_print(self, q):
469 q.text("dec_nw_ttl {")
470 with q.group():
471 with q.indent(2):
472 q.breakable()
473 q.breakable()
474 q.text('}')
475
Rich Lane7dcdf022013-12-11 14:45:27 -0800476action.subtypes[24] = dec_nw_ttl
477
478class group(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700479 type = 22
Rich Lanec2ee4b82013-04-24 17:12:38 -0700480
481 def __init__(self, group_id=None):
482 if group_id != None:
483 self.group_id = group_id
484 else:
485 self.group_id = 0
486 return
487
488 def pack(self):
489 packed = []
490 packed.append(struct.pack("!H", self.type))
491 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
492 packed.append(struct.pack("!L", self.group_id))
493 length = sum([len(x) for x in packed])
494 packed[1] = struct.pack("!H", length)
495 return ''.join(packed)
496
497 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800498 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700499 obj = group()
Dan Talaycof6202252013-07-02 01:00:29 -0700500 _type = reader.read("!H")[0]
501 assert(_type == 22)
502 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800503 orig_reader = reader
504 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700505 obj.group_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700506 return obj
507
508 def __eq__(self, other):
509 if type(self) != type(other): return False
510 if self.group_id != other.group_id: return False
511 return True
512
Rich Lanec2ee4b82013-04-24 17:12:38 -0700513 def pretty_print(self, q):
514 q.text("group {")
515 with q.group():
516 with q.indent(2):
517 q.breakable()
518 q.text("group_id = ");
519 q.text("%#x" % self.group_id)
520 q.breakable()
521 q.text('}')
522
Rich Lane7dcdf022013-12-11 14:45:27 -0800523action.subtypes[22] = group
524
525class nicira(experimenter):
526 subtypes = {}
527
Rich Lane95f7fc92014-01-27 17:08:16 -0800528 type = 65535
529 experimenter = 8992
530
531 def __init__(self, subtype=None):
532 if subtype != None:
533 self.subtype = subtype
534 else:
535 self.subtype = 0
536 return
537
538 def pack(self):
539 packed = []
540 packed.append(struct.pack("!H", self.type))
541 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
542 packed.append(struct.pack("!L", self.experimenter))
543 packed.append(struct.pack("!H", self.subtype))
544 packed.append('\x00' * 2)
545 packed.append('\x00' * 4)
546 length = sum([len(x) for x in packed])
547 packed[1] = struct.pack("!H", length)
548 return ''.join(packed)
549
Rich Lane7dcdf022013-12-11 14:45:27 -0800550 @staticmethod
551 def unpack(reader):
552 subtype, = reader.peek('!H', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800553 subclass = nicira.subtypes.get(subtype)
554 if subclass:
555 return subclass.unpack(reader)
556
557 obj = nicira()
558 _type = reader.read("!H")[0]
559 assert(_type == 65535)
560 _len = reader.read("!H")[0]
561 orig_reader = reader
562 reader = orig_reader.slice(_len - (2 + 2))
563 _experimenter = reader.read("!L")[0]
564 assert(_experimenter == 8992)
565 obj.subtype = reader.read("!H")[0]
566 reader.skip(2)
567 reader.skip(4)
568 return obj
569
570 def __eq__(self, other):
571 if type(self) != type(other): return False
572 if self.subtype != other.subtype: return False
573 return True
574
575 def pretty_print(self, q):
576 q.text("nicira {")
577 with q.group():
578 with q.indent(2):
579 q.breakable()
580 q.breakable()
581 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800582
583experimenter.subtypes[8992] = nicira
584
585class nicira_dec_ttl(nicira):
Dan Talaycof6202252013-07-02 01:00:29 -0700586 type = 65535
587 experimenter = 8992
Rich Lanec2ee4b82013-04-24 17:12:38 -0700588 subtype = 18
589
590 def __init__(self):
591 return
592
593 def pack(self):
594 packed = []
595 packed.append(struct.pack("!H", self.type))
596 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
597 packed.append(struct.pack("!L", self.experimenter))
598 packed.append(struct.pack("!H", self.subtype))
599 packed.append('\x00' * 2)
600 packed.append('\x00' * 4)
601 length = sum([len(x) for x in packed])
602 packed[1] = struct.pack("!H", length)
603 return ''.join(packed)
604
605 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800606 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700607 obj = nicira_dec_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700608 _type = reader.read("!H")[0]
609 assert(_type == 65535)
610 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800611 orig_reader = reader
612 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700613 _experimenter = reader.read("!L")[0]
614 assert(_experimenter == 8992)
615 _subtype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700616 assert(_subtype == 18)
617 reader.skip(2)
618 reader.skip(4)
619 return obj
620
621 def __eq__(self, other):
622 if type(self) != type(other): return False
623 return True
624
Rich Lanec2ee4b82013-04-24 17:12:38 -0700625 def pretty_print(self, q):
626 q.text("nicira_dec_ttl {")
627 with q.group():
628 with q.indent(2):
629 q.breakable()
630 q.breakable()
631 q.text('}')
632
Rich Lane7dcdf022013-12-11 14:45:27 -0800633nicira.subtypes[18] = nicira_dec_ttl
634
635class output(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700636 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700637
638 def __init__(self, port=None, max_len=None):
639 if port != None:
640 self.port = port
641 else:
642 self.port = 0
643 if max_len != None:
644 self.max_len = max_len
645 else:
646 self.max_len = 0
647 return
648
649 def pack(self):
650 packed = []
651 packed.append(struct.pack("!H", self.type))
652 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700653 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700654 packed.append(struct.pack("!H", self.max_len))
655 packed.append('\x00' * 6)
656 length = sum([len(x) for x in packed])
657 packed[1] = struct.pack("!H", length)
658 return ''.join(packed)
659
660 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800661 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700662 obj = output()
Dan Talaycof6202252013-07-02 01:00:29 -0700663 _type = reader.read("!H")[0]
664 assert(_type == 0)
665 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800666 orig_reader = reader
667 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700668 obj.port = util.unpack_port_no(reader)
669 obj.max_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700670 reader.skip(6)
671 return obj
672
673 def __eq__(self, other):
674 if type(self) != type(other): return False
675 if self.port != other.port: return False
676 if self.max_len != other.max_len: return False
677 return True
678
Rich Lanec2ee4b82013-04-24 17:12:38 -0700679 def pretty_print(self, q):
680 q.text("output {")
681 with q.group():
682 with q.indent(2):
683 q.breakable()
684 q.text("port = ");
685 q.text(util.pretty_port(self.port))
686 q.text(","); q.breakable()
687 q.text("max_len = ");
688 q.text("%#x" % self.max_len)
689 q.breakable()
690 q.text('}')
691
Rich Lane7dcdf022013-12-11 14:45:27 -0800692action.subtypes[0] = output
693
694class pop_mpls(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700695 type = 20
Rich Lanec2ee4b82013-04-24 17:12:38 -0700696
697 def __init__(self, ethertype=None):
698 if ethertype != None:
699 self.ethertype = ethertype
700 else:
701 self.ethertype = 0
702 return
703
704 def pack(self):
705 packed = []
706 packed.append(struct.pack("!H", self.type))
707 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
708 packed.append(struct.pack("!H", self.ethertype))
709 packed.append('\x00' * 2)
710 length = sum([len(x) for x in packed])
711 packed[1] = struct.pack("!H", length)
712 return ''.join(packed)
713
714 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800715 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700716 obj = pop_mpls()
Dan Talaycof6202252013-07-02 01:00:29 -0700717 _type = reader.read("!H")[0]
718 assert(_type == 20)
719 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800720 orig_reader = reader
721 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700722 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700723 reader.skip(2)
724 return obj
725
726 def __eq__(self, other):
727 if type(self) != type(other): return False
728 if self.ethertype != other.ethertype: return False
729 return True
730
Rich Lanec2ee4b82013-04-24 17:12:38 -0700731 def pretty_print(self, q):
732 q.text("pop_mpls {")
733 with q.group():
734 with q.indent(2):
735 q.breakable()
736 q.text("ethertype = ");
737 q.text("%#x" % self.ethertype)
738 q.breakable()
739 q.text('}')
740
Rich Lane7dcdf022013-12-11 14:45:27 -0800741action.subtypes[20] = pop_mpls
742
743class pop_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700744 type = 18
Rich Lanec2ee4b82013-04-24 17:12:38 -0700745
746 def __init__(self):
747 return
748
749 def pack(self):
750 packed = []
751 packed.append(struct.pack("!H", self.type))
752 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
753 packed.append('\x00' * 4)
754 length = sum([len(x) for x in packed])
755 packed[1] = struct.pack("!H", length)
756 return ''.join(packed)
757
758 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800759 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700760 obj = pop_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -0700761 _type = reader.read("!H")[0]
762 assert(_type == 18)
763 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800764 orig_reader = reader
765 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700766 reader.skip(4)
767 return obj
768
769 def __eq__(self, other):
770 if type(self) != type(other): return False
771 return True
772
Rich Lanec2ee4b82013-04-24 17:12:38 -0700773 def pretty_print(self, q):
774 q.text("pop_vlan {")
775 with q.group():
776 with q.indent(2):
777 q.breakable()
778 q.breakable()
779 q.text('}')
780
Rich Lane7dcdf022013-12-11 14:45:27 -0800781action.subtypes[18] = pop_vlan
782
783class push_mpls(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700784 type = 19
Rich Lanec2ee4b82013-04-24 17:12:38 -0700785
786 def __init__(self, ethertype=None):
787 if ethertype != None:
788 self.ethertype = ethertype
789 else:
790 self.ethertype = 0
791 return
792
793 def pack(self):
794 packed = []
795 packed.append(struct.pack("!H", self.type))
796 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
797 packed.append(struct.pack("!H", self.ethertype))
798 packed.append('\x00' * 2)
799 length = sum([len(x) for x in packed])
800 packed[1] = struct.pack("!H", length)
801 return ''.join(packed)
802
803 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800804 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700805 obj = push_mpls()
Dan Talaycof6202252013-07-02 01:00:29 -0700806 _type = reader.read("!H")[0]
807 assert(_type == 19)
808 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800809 orig_reader = reader
810 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700811 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700812 reader.skip(2)
813 return obj
814
815 def __eq__(self, other):
816 if type(self) != type(other): return False
817 if self.ethertype != other.ethertype: return False
818 return True
819
Rich Lanec2ee4b82013-04-24 17:12:38 -0700820 def pretty_print(self, q):
821 q.text("push_mpls {")
822 with q.group():
823 with q.indent(2):
824 q.breakable()
825 q.text("ethertype = ");
826 q.text("%#x" % self.ethertype)
827 q.breakable()
828 q.text('}')
829
Rich Lane7dcdf022013-12-11 14:45:27 -0800830action.subtypes[19] = push_mpls
831
832class push_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700833 type = 17
Rich Lanec2ee4b82013-04-24 17:12:38 -0700834
835 def __init__(self, ethertype=None):
836 if ethertype != None:
837 self.ethertype = ethertype
838 else:
839 self.ethertype = 0
840 return
841
842 def pack(self):
843 packed = []
844 packed.append(struct.pack("!H", self.type))
845 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
846 packed.append(struct.pack("!H", self.ethertype))
847 packed.append('\x00' * 2)
848 length = sum([len(x) for x in packed])
849 packed[1] = struct.pack("!H", length)
850 return ''.join(packed)
851
852 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800853 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700854 obj = push_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -0700855 _type = reader.read("!H")[0]
856 assert(_type == 17)
857 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800858 orig_reader = reader
859 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700860 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700861 reader.skip(2)
862 return obj
863
864 def __eq__(self, other):
865 if type(self) != type(other): return False
866 if self.ethertype != other.ethertype: return False
867 return True
868
Rich Lanec2ee4b82013-04-24 17:12:38 -0700869 def pretty_print(self, q):
870 q.text("push_vlan {")
871 with q.group():
872 with q.indent(2):
873 q.breakable()
874 q.text("ethertype = ");
875 q.text("%#x" % self.ethertype)
876 q.breakable()
877 q.text('}')
878
Rich Lane7dcdf022013-12-11 14:45:27 -0800879action.subtypes[17] = push_vlan
880
881class set_dl_dst(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700882 type = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -0700883
884 def __init__(self, dl_addr=None):
885 if dl_addr != None:
886 self.dl_addr = dl_addr
887 else:
888 self.dl_addr = [0,0,0,0,0,0]
889 return
890
891 def pack(self):
892 packed = []
893 packed.append(struct.pack("!H", self.type))
894 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
895 packed.append(struct.pack("!6B", *self.dl_addr))
896 packed.append('\x00' * 6)
897 length = sum([len(x) for x in packed])
898 packed[1] = struct.pack("!H", length)
899 return ''.join(packed)
900
901 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800902 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700903 obj = set_dl_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700904 _type = reader.read("!H")[0]
905 assert(_type == 4)
906 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800907 orig_reader = reader
908 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700909 obj.dl_addr = list(reader.read('!6B'))
910 reader.skip(6)
911 return obj
912
913 def __eq__(self, other):
914 if type(self) != type(other): return False
915 if self.dl_addr != other.dl_addr: return False
916 return True
917
Rich Lanec2ee4b82013-04-24 17:12:38 -0700918 def pretty_print(self, q):
919 q.text("set_dl_dst {")
920 with q.group():
921 with q.indent(2):
922 q.breakable()
923 q.text("dl_addr = ");
924 q.text(util.pretty_mac(self.dl_addr))
925 q.breakable()
926 q.text('}')
927
Rich Lane7dcdf022013-12-11 14:45:27 -0800928action.subtypes[4] = set_dl_dst
929
930class set_dl_src(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700931 type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -0700932
933 def __init__(self, dl_addr=None):
934 if dl_addr != None:
935 self.dl_addr = dl_addr
936 else:
937 self.dl_addr = [0,0,0,0,0,0]
938 return
939
940 def pack(self):
941 packed = []
942 packed.append(struct.pack("!H", self.type))
943 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
944 packed.append(struct.pack("!6B", *self.dl_addr))
945 packed.append('\x00' * 6)
946 length = sum([len(x) for x in packed])
947 packed[1] = struct.pack("!H", length)
948 return ''.join(packed)
949
950 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800951 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700952 obj = set_dl_src()
Dan Talaycof6202252013-07-02 01:00:29 -0700953 _type = reader.read("!H")[0]
954 assert(_type == 3)
955 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800956 orig_reader = reader
957 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700958 obj.dl_addr = list(reader.read('!6B'))
959 reader.skip(6)
960 return obj
961
962 def __eq__(self, other):
963 if type(self) != type(other): return False
964 if self.dl_addr != other.dl_addr: return False
965 return True
966
Rich Lanec2ee4b82013-04-24 17:12:38 -0700967 def pretty_print(self, q):
968 q.text("set_dl_src {")
969 with q.group():
970 with q.indent(2):
971 q.breakable()
972 q.text("dl_addr = ");
973 q.text(util.pretty_mac(self.dl_addr))
974 q.breakable()
975 q.text('}')
976
Rich Lane7dcdf022013-12-11 14:45:27 -0800977action.subtypes[3] = set_dl_src
978
979class set_mpls_label(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700980 type = 13
Rich Lanec2ee4b82013-04-24 17:12:38 -0700981
982 def __init__(self, mpls_label=None):
983 if mpls_label != None:
984 self.mpls_label = mpls_label
985 else:
986 self.mpls_label = 0
987 return
988
989 def pack(self):
990 packed = []
991 packed.append(struct.pack("!H", self.type))
992 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
993 packed.append(struct.pack("!L", self.mpls_label))
994 length = sum([len(x) for x in packed])
995 packed[1] = struct.pack("!H", length)
996 return ''.join(packed)
997
998 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800999 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001000 obj = set_mpls_label()
Dan Talaycof6202252013-07-02 01:00:29 -07001001 _type = reader.read("!H")[0]
1002 assert(_type == 13)
1003 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001004 orig_reader = reader
1005 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001006 obj.mpls_label = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001007 return obj
1008
1009 def __eq__(self, other):
1010 if type(self) != type(other): return False
1011 if self.mpls_label != other.mpls_label: return False
1012 return True
1013
Rich Lanec2ee4b82013-04-24 17:12:38 -07001014 def pretty_print(self, q):
1015 q.text("set_mpls_label {")
1016 with q.group():
1017 with q.indent(2):
1018 q.breakable()
1019 q.text("mpls_label = ");
1020 q.text("%#x" % self.mpls_label)
1021 q.breakable()
1022 q.text('}')
1023
Rich Lane7dcdf022013-12-11 14:45:27 -08001024action.subtypes[13] = set_mpls_label
1025
1026class set_mpls_tc(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001027 type = 14
Rich Lanec2ee4b82013-04-24 17:12:38 -07001028
1029 def __init__(self, mpls_tc=None):
1030 if mpls_tc != None:
1031 self.mpls_tc = mpls_tc
1032 else:
1033 self.mpls_tc = 0
1034 return
1035
1036 def pack(self):
1037 packed = []
1038 packed.append(struct.pack("!H", self.type))
1039 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1040 packed.append(struct.pack("!B", self.mpls_tc))
1041 packed.append('\x00' * 3)
1042 length = sum([len(x) for x in packed])
1043 packed[1] = struct.pack("!H", length)
1044 return ''.join(packed)
1045
1046 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001047 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001048 obj = set_mpls_tc()
Dan Talaycof6202252013-07-02 01:00:29 -07001049 _type = reader.read("!H")[0]
1050 assert(_type == 14)
1051 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001052 orig_reader = reader
1053 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001054 obj.mpls_tc = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001055 reader.skip(3)
1056 return obj
1057
1058 def __eq__(self, other):
1059 if type(self) != type(other): return False
1060 if self.mpls_tc != other.mpls_tc: return False
1061 return True
1062
Rich Lanec2ee4b82013-04-24 17:12:38 -07001063 def pretty_print(self, q):
1064 q.text("set_mpls_tc {")
1065 with q.group():
1066 with q.indent(2):
1067 q.breakable()
1068 q.text("mpls_tc = ");
1069 q.text("%#x" % self.mpls_tc)
1070 q.breakable()
1071 q.text('}')
1072
Rich Lane7dcdf022013-12-11 14:45:27 -08001073action.subtypes[14] = set_mpls_tc
1074
1075class set_mpls_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001076 type = 15
Rich Lanec2ee4b82013-04-24 17:12:38 -07001077
1078 def __init__(self, mpls_ttl=None):
1079 if mpls_ttl != None:
1080 self.mpls_ttl = mpls_ttl
1081 else:
1082 self.mpls_ttl = 0
1083 return
1084
1085 def pack(self):
1086 packed = []
1087 packed.append(struct.pack("!H", self.type))
1088 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1089 packed.append(struct.pack("!B", self.mpls_ttl))
1090 packed.append('\x00' * 3)
1091 length = sum([len(x) for x in packed])
1092 packed[1] = struct.pack("!H", length)
1093 return ''.join(packed)
1094
1095 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001096 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001097 obj = set_mpls_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -07001098 _type = reader.read("!H")[0]
1099 assert(_type == 15)
1100 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001101 orig_reader = reader
1102 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001103 obj.mpls_ttl = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001104 reader.skip(3)
1105 return obj
1106
1107 def __eq__(self, other):
1108 if type(self) != type(other): return False
1109 if self.mpls_ttl != other.mpls_ttl: return False
1110 return True
1111
Rich Lanec2ee4b82013-04-24 17:12:38 -07001112 def pretty_print(self, q):
1113 q.text("set_mpls_ttl {")
1114 with q.group():
1115 with q.indent(2):
1116 q.breakable()
1117 q.text("mpls_ttl = ");
1118 q.text("%#x" % self.mpls_ttl)
1119 q.breakable()
1120 q.text('}')
1121
Rich Lane7dcdf022013-12-11 14:45:27 -08001122action.subtypes[15] = set_mpls_ttl
1123
1124class set_nw_dst(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001125 type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07001126
1127 def __init__(self, nw_addr=None):
1128 if nw_addr != None:
1129 self.nw_addr = nw_addr
1130 else:
1131 self.nw_addr = 0
1132 return
1133
1134 def pack(self):
1135 packed = []
1136 packed.append(struct.pack("!H", self.type))
1137 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1138 packed.append(struct.pack("!L", self.nw_addr))
1139 length = sum([len(x) for x in packed])
1140 packed[1] = struct.pack("!H", length)
1141 return ''.join(packed)
1142
1143 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001144 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001145 obj = set_nw_dst()
Dan Talaycof6202252013-07-02 01:00:29 -07001146 _type = reader.read("!H")[0]
1147 assert(_type == 6)
1148 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001149 orig_reader = reader
1150 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001151 obj.nw_addr = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001152 return obj
1153
1154 def __eq__(self, other):
1155 if type(self) != type(other): return False
1156 if self.nw_addr != other.nw_addr: return False
1157 return True
1158
Rich Lanec2ee4b82013-04-24 17:12:38 -07001159 def pretty_print(self, q):
1160 q.text("set_nw_dst {")
1161 with q.group():
1162 with q.indent(2):
1163 q.breakable()
1164 q.text("nw_addr = ");
1165 q.text("%#x" % self.nw_addr)
1166 q.breakable()
1167 q.text('}')
1168
Rich Lane7dcdf022013-12-11 14:45:27 -08001169action.subtypes[6] = set_nw_dst
1170
1171class set_nw_ecn(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001172 type = 8
Rich Lanec2ee4b82013-04-24 17:12:38 -07001173
1174 def __init__(self, nw_ecn=None):
1175 if nw_ecn != None:
1176 self.nw_ecn = nw_ecn
1177 else:
1178 self.nw_ecn = 0
1179 return
1180
1181 def pack(self):
1182 packed = []
1183 packed.append(struct.pack("!H", self.type))
1184 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1185 packed.append(struct.pack("!B", self.nw_ecn))
1186 packed.append('\x00' * 3)
1187 length = sum([len(x) for x in packed])
1188 packed[1] = struct.pack("!H", length)
1189 return ''.join(packed)
1190
1191 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001192 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001193 obj = set_nw_ecn()
Dan Talaycof6202252013-07-02 01:00:29 -07001194 _type = reader.read("!H")[0]
1195 assert(_type == 8)
1196 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001197 orig_reader = reader
1198 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001199 obj.nw_ecn = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001200 reader.skip(3)
1201 return obj
1202
1203 def __eq__(self, other):
1204 if type(self) != type(other): return False
1205 if self.nw_ecn != other.nw_ecn: return False
1206 return True
1207
Rich Lanec2ee4b82013-04-24 17:12:38 -07001208 def pretty_print(self, q):
1209 q.text("set_nw_ecn {")
1210 with q.group():
1211 with q.indent(2):
1212 q.breakable()
1213 q.text("nw_ecn = ");
1214 q.text("%#x" % self.nw_ecn)
1215 q.breakable()
1216 q.text('}')
1217
Rich Lane7dcdf022013-12-11 14:45:27 -08001218action.subtypes[8] = set_nw_ecn
1219
1220class set_nw_src(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001221 type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07001222
1223 def __init__(self, nw_addr=None):
1224 if nw_addr != None:
1225 self.nw_addr = nw_addr
1226 else:
1227 self.nw_addr = 0
1228 return
1229
1230 def pack(self):
1231 packed = []
1232 packed.append(struct.pack("!H", self.type))
1233 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1234 packed.append(struct.pack("!L", self.nw_addr))
1235 length = sum([len(x) for x in packed])
1236 packed[1] = struct.pack("!H", length)
1237 return ''.join(packed)
1238
1239 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001240 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001241 obj = set_nw_src()
Dan Talaycof6202252013-07-02 01:00:29 -07001242 _type = reader.read("!H")[0]
1243 assert(_type == 5)
1244 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001245 orig_reader = reader
1246 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001247 obj.nw_addr = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001248 return obj
1249
1250 def __eq__(self, other):
1251 if type(self) != type(other): return False
1252 if self.nw_addr != other.nw_addr: return False
1253 return True
1254
Rich Lanec2ee4b82013-04-24 17:12:38 -07001255 def pretty_print(self, q):
1256 q.text("set_nw_src {")
1257 with q.group():
1258 with q.indent(2):
1259 q.breakable()
1260 q.text("nw_addr = ");
1261 q.text("%#x" % self.nw_addr)
1262 q.breakable()
1263 q.text('}')
1264
Rich Lane7dcdf022013-12-11 14:45:27 -08001265action.subtypes[5] = set_nw_src
1266
1267class set_nw_tos(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001268 type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07001269
1270 def __init__(self, nw_tos=None):
1271 if nw_tos != None:
1272 self.nw_tos = nw_tos
1273 else:
1274 self.nw_tos = 0
1275 return
1276
1277 def pack(self):
1278 packed = []
1279 packed.append(struct.pack("!H", self.type))
1280 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1281 packed.append(struct.pack("!B", self.nw_tos))
1282 packed.append('\x00' * 3)
1283 length = sum([len(x) for x in packed])
1284 packed[1] = struct.pack("!H", length)
1285 return ''.join(packed)
1286
1287 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001288 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001289 obj = set_nw_tos()
Dan Talaycof6202252013-07-02 01:00:29 -07001290 _type = reader.read("!H")[0]
1291 assert(_type == 7)
1292 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001293 orig_reader = reader
1294 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001295 obj.nw_tos = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001296 reader.skip(3)
1297 return obj
1298
1299 def __eq__(self, other):
1300 if type(self) != type(other): return False
1301 if self.nw_tos != other.nw_tos: return False
1302 return True
1303
Rich Lanec2ee4b82013-04-24 17:12:38 -07001304 def pretty_print(self, q):
1305 q.text("set_nw_tos {")
1306 with q.group():
1307 with q.indent(2):
1308 q.breakable()
1309 q.text("nw_tos = ");
1310 q.text("%#x" % self.nw_tos)
1311 q.breakable()
1312 q.text('}')
1313
Rich Lane7dcdf022013-12-11 14:45:27 -08001314action.subtypes[7] = set_nw_tos
1315
1316class set_nw_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001317 type = 23
Rich Lanec2ee4b82013-04-24 17:12:38 -07001318
1319 def __init__(self, nw_ttl=None):
1320 if nw_ttl != None:
1321 self.nw_ttl = nw_ttl
1322 else:
1323 self.nw_ttl = 0
1324 return
1325
1326 def pack(self):
1327 packed = []
1328 packed.append(struct.pack("!H", self.type))
1329 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1330 packed.append(struct.pack("!B", self.nw_ttl))
1331 packed.append('\x00' * 3)
1332 length = sum([len(x) for x in packed])
1333 packed[1] = struct.pack("!H", length)
1334 return ''.join(packed)
1335
1336 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001337 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001338 obj = set_nw_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -07001339 _type = reader.read("!H")[0]
1340 assert(_type == 23)
1341 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001342 orig_reader = reader
1343 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001344 obj.nw_ttl = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001345 reader.skip(3)
1346 return obj
1347
1348 def __eq__(self, other):
1349 if type(self) != type(other): return False
1350 if self.nw_ttl != other.nw_ttl: return False
1351 return True
1352
Rich Lanec2ee4b82013-04-24 17:12:38 -07001353 def pretty_print(self, q):
1354 q.text("set_nw_ttl {")
1355 with q.group():
1356 with q.indent(2):
1357 q.breakable()
1358 q.text("nw_ttl = ");
1359 q.text("%#x" % self.nw_ttl)
1360 q.breakable()
1361 q.text('}')
1362
Rich Lane7dcdf022013-12-11 14:45:27 -08001363action.subtypes[23] = set_nw_ttl
1364
1365class set_queue(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001366 type = 21
Rich Lanec2ee4b82013-04-24 17:12:38 -07001367
1368 def __init__(self, queue_id=None):
1369 if queue_id != None:
1370 self.queue_id = queue_id
1371 else:
1372 self.queue_id = 0
1373 return
1374
1375 def pack(self):
1376 packed = []
1377 packed.append(struct.pack("!H", self.type))
1378 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1379 packed.append(struct.pack("!L", self.queue_id))
1380 length = sum([len(x) for x in packed])
1381 packed[1] = struct.pack("!H", length)
1382 return ''.join(packed)
1383
1384 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001385 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001386 obj = set_queue()
Dan Talaycof6202252013-07-02 01:00:29 -07001387 _type = reader.read("!H")[0]
1388 assert(_type == 21)
1389 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001390 orig_reader = reader
1391 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001392 obj.queue_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001393 return obj
1394
1395 def __eq__(self, other):
1396 if type(self) != type(other): return False
1397 if self.queue_id != other.queue_id: return False
1398 return True
1399
Rich Lanec2ee4b82013-04-24 17:12:38 -07001400 def pretty_print(self, q):
1401 q.text("set_queue {")
1402 with q.group():
1403 with q.indent(2):
1404 q.breakable()
1405 q.text("queue_id = ");
1406 q.text("%#x" % self.queue_id)
1407 q.breakable()
1408 q.text('}')
1409
Rich Lane7dcdf022013-12-11 14:45:27 -08001410action.subtypes[21] = set_queue
1411
1412class set_tp_dst(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001413 type = 10
Rich Lanec2ee4b82013-04-24 17:12:38 -07001414
1415 def __init__(self, tp_port=None):
1416 if tp_port != None:
1417 self.tp_port = tp_port
1418 else:
1419 self.tp_port = 0
1420 return
1421
1422 def pack(self):
1423 packed = []
1424 packed.append(struct.pack("!H", self.type))
1425 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1426 packed.append(struct.pack("!H", self.tp_port))
1427 packed.append('\x00' * 2)
1428 length = sum([len(x) for x in packed])
1429 packed[1] = struct.pack("!H", length)
1430 return ''.join(packed)
1431
1432 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001433 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001434 obj = set_tp_dst()
Dan Talaycof6202252013-07-02 01:00:29 -07001435 _type = reader.read("!H")[0]
1436 assert(_type == 10)
1437 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001438 orig_reader = reader
1439 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001440 obj.tp_port = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001441 reader.skip(2)
1442 return obj
1443
1444 def __eq__(self, other):
1445 if type(self) != type(other): return False
1446 if self.tp_port != other.tp_port: return False
1447 return True
1448
Rich Lanec2ee4b82013-04-24 17:12:38 -07001449 def pretty_print(self, q):
1450 q.text("set_tp_dst {")
1451 with q.group():
1452 with q.indent(2):
1453 q.breakable()
1454 q.text("tp_port = ");
1455 q.text("%#x" % self.tp_port)
1456 q.breakable()
1457 q.text('}')
1458
Rich Lane7dcdf022013-12-11 14:45:27 -08001459action.subtypes[10] = set_tp_dst
1460
1461class set_tp_src(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001462 type = 9
Rich Lanec2ee4b82013-04-24 17:12:38 -07001463
1464 def __init__(self, tp_port=None):
1465 if tp_port != None:
1466 self.tp_port = tp_port
1467 else:
1468 self.tp_port = 0
1469 return
1470
1471 def pack(self):
1472 packed = []
1473 packed.append(struct.pack("!H", self.type))
1474 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1475 packed.append(struct.pack("!H", self.tp_port))
1476 packed.append('\x00' * 2)
1477 length = sum([len(x) for x in packed])
1478 packed[1] = struct.pack("!H", length)
1479 return ''.join(packed)
1480
1481 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001482 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001483 obj = set_tp_src()
Dan Talaycof6202252013-07-02 01:00:29 -07001484 _type = reader.read("!H")[0]
1485 assert(_type == 9)
1486 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001487 orig_reader = reader
1488 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001489 obj.tp_port = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001490 reader.skip(2)
1491 return obj
1492
1493 def __eq__(self, other):
1494 if type(self) != type(other): return False
1495 if self.tp_port != other.tp_port: return False
1496 return True
1497
Rich Lanec2ee4b82013-04-24 17:12:38 -07001498 def pretty_print(self, q):
1499 q.text("set_tp_src {")
1500 with q.group():
1501 with q.indent(2):
1502 q.breakable()
1503 q.text("tp_port = ");
1504 q.text("%#x" % self.tp_port)
1505 q.breakable()
1506 q.text('}')
1507
Rich Lane7dcdf022013-12-11 14:45:27 -08001508action.subtypes[9] = set_tp_src
1509
1510class set_vlan_pcp(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001511 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07001512
1513 def __init__(self, vlan_pcp=None):
1514 if vlan_pcp != None:
1515 self.vlan_pcp = vlan_pcp
1516 else:
1517 self.vlan_pcp = 0
1518 return
1519
1520 def pack(self):
1521 packed = []
1522 packed.append(struct.pack("!H", self.type))
1523 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1524 packed.append(struct.pack("!B", self.vlan_pcp))
1525 packed.append('\x00' * 3)
1526 length = sum([len(x) for x in packed])
1527 packed[1] = struct.pack("!H", length)
1528 return ''.join(packed)
1529
1530 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001531 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001532 obj = set_vlan_pcp()
Dan Talaycof6202252013-07-02 01:00:29 -07001533 _type = reader.read("!H")[0]
1534 assert(_type == 2)
1535 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001536 orig_reader = reader
1537 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001538 obj.vlan_pcp = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001539 reader.skip(3)
1540 return obj
1541
1542 def __eq__(self, other):
1543 if type(self) != type(other): return False
1544 if self.vlan_pcp != other.vlan_pcp: return False
1545 return True
1546
Rich Lanec2ee4b82013-04-24 17:12:38 -07001547 def pretty_print(self, q):
1548 q.text("set_vlan_pcp {")
1549 with q.group():
1550 with q.indent(2):
1551 q.breakable()
1552 q.text("vlan_pcp = ");
1553 q.text("%#x" % self.vlan_pcp)
1554 q.breakable()
1555 q.text('}')
1556
Rich Lane7dcdf022013-12-11 14:45:27 -08001557action.subtypes[2] = set_vlan_pcp
1558
1559class set_vlan_vid(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001560 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07001561
1562 def __init__(self, vlan_vid=None):
1563 if vlan_vid != None:
1564 self.vlan_vid = vlan_vid
1565 else:
1566 self.vlan_vid = 0
1567 return
1568
1569 def pack(self):
1570 packed = []
1571 packed.append(struct.pack("!H", self.type))
1572 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1573 packed.append(struct.pack("!H", self.vlan_vid))
1574 packed.append('\x00' * 2)
1575 length = sum([len(x) for x in packed])
1576 packed[1] = struct.pack("!H", length)
1577 return ''.join(packed)
1578
1579 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001580 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001581 obj = set_vlan_vid()
Dan Talaycof6202252013-07-02 01:00:29 -07001582 _type = reader.read("!H")[0]
1583 assert(_type == 1)
1584 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001585 orig_reader = reader
1586 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001587 obj.vlan_vid = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001588 reader.skip(2)
1589 return obj
1590
1591 def __eq__(self, other):
1592 if type(self) != type(other): return False
1593 if self.vlan_vid != other.vlan_vid: return False
1594 return True
1595
Rich Lanec2ee4b82013-04-24 17:12:38 -07001596 def pretty_print(self, q):
1597 q.text("set_vlan_vid {")
1598 with q.group():
1599 with q.indent(2):
1600 q.breakable()
1601 q.text("vlan_vid = ");
1602 q.text("%#x" % self.vlan_vid)
1603 q.breakable()
1604 q.text('}')
1605
Rich Lane7dcdf022013-12-11 14:45:27 -08001606action.subtypes[1] = set_vlan_vid
Rich Lanec2ee4b82013-04-24 17:12:38 -07001607
Rich Lanec2ee4b82013-04-24 17:12:38 -07001608