blob: 6dc8b98202cf045928565662f71cae70e77d828f [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 action
Harshmeet Singh1db46332014-10-14 16:29:13 -070013import message
Rich Lane7dcdf022013-12-11 14:45:27 -080014import instruction
Harshmeet Singh1db46332014-10-14 16:29:13 -070015import common
Rich Lanec2ee4b82013-04-24 17:12:38 -070016import util
17import loxi.generic_util
Rich Lanec2ee4b82013-04-24 17:12:38 -070018
Rich Lane7dcdf022013-12-11 14:45:27 -080019class action(loxi.OFObject):
20 subtypes = {}
Rich Lanec2ee4b82013-04-24 17:12:38 -070021
Rich Lane95f7fc92014-01-27 17:08:16 -080022
23 def __init__(self, type=None):
24 if type != None:
25 self.type = type
26 else:
27 self.type = 0
28 return
29
30 def pack(self):
31 packed = []
32 packed.append(struct.pack("!H", self.type))
33 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
34 packed.append('\x00' * 4)
35 length = sum([len(x) for x in packed])
36 packed[1] = struct.pack("!H", length)
37 return ''.join(packed)
38
Rich Lane7dcdf022013-12-11 14:45:27 -080039 @staticmethod
40 def unpack(reader):
41 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -080042 subclass = action.subtypes.get(subtype)
43 if subclass:
44 return subclass.unpack(reader)
45
46 obj = action()
47 obj.type = reader.read("!H")[0]
48 _len = reader.read("!H")[0]
49 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -080050 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -080051 reader.skip(4)
52 return obj
53
54 def __eq__(self, other):
55 if type(self) != type(other): return False
56 if self.type != other.type: return False
57 return True
58
59 def pretty_print(self, q):
60 q.text("action {")
61 with q.group():
62 with q.indent(2):
63 q.breakable()
64 q.breakable()
65 q.text('}')
Rich Lanec2ee4b82013-04-24 17:12:38 -070066
Rich Lane7dcdf022013-12-11 14:45:27 -080067
68class experimenter(action):
69 subtypes = {}
70
Rich Lane95f7fc92014-01-27 17:08:16 -080071 type = 65535
72
73 def __init__(self, experimenter=None, data=None):
74 if experimenter != None:
75 self.experimenter = experimenter
76 else:
77 self.experimenter = 0
78 if data != None:
79 self.data = data
80 else:
81 self.data = ''
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(self.data)
90 length = sum([len(x) for x in packed])
91 packed[1] = struct.pack("!H", length)
92 return ''.join(packed)
93
Rich Lane7dcdf022013-12-11 14:45:27 -080094 @staticmethod
95 def unpack(reader):
96 subtype, = reader.peek('!L', 4)
Rich Lane95f7fc92014-01-27 17:08:16 -080097 subclass = experimenter.subtypes.get(subtype)
98 if subclass:
99 return subclass.unpack(reader)
100
101 obj = experimenter()
102 _type = reader.read("!H")[0]
103 assert(_type == 65535)
104 _len = reader.read("!H")[0]
105 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800106 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800107 obj.experimenter = reader.read("!L")[0]
108 obj.data = str(reader.read_all())
109 return obj
110
111 def __eq__(self, other):
112 if type(self) != type(other): return False
113 if self.experimenter != other.experimenter: return False
114 if self.data != other.data: return False
115 return True
116
117 def pretty_print(self, q):
118 q.text("experimenter {")
119 with q.group():
120 with q.indent(2):
121 q.breakable()
122 q.text("data = ");
123 q.pp(self.data)
124 q.breakable()
125 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800126
127action.subtypes[65535] = experimenter
128
129class bsn(experimenter):
130 subtypes = {}
131
Rich Lane95f7fc92014-01-27 17:08:16 -0800132 type = 65535
133 experimenter = 6035143
134
135 def __init__(self, subtype=None):
136 if subtype != None:
137 self.subtype = subtype
138 else:
139 self.subtype = 0
140 return
141
142 def pack(self):
143 packed = []
144 packed.append(struct.pack("!H", self.type))
145 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
146 packed.append(struct.pack("!L", self.experimenter))
147 packed.append(struct.pack("!L", self.subtype))
148 packed.append('\x00' * 4)
149 length = sum([len(x) for x in packed])
150 packed[1] = struct.pack("!H", length)
151 return ''.join(packed)
152
Rich Lane7dcdf022013-12-11 14:45:27 -0800153 @staticmethod
154 def unpack(reader):
155 subtype, = reader.peek('!L', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800156 subclass = bsn.subtypes.get(subtype)
157 if subclass:
158 return subclass.unpack(reader)
159
160 obj = bsn()
161 _type = reader.read("!H")[0]
162 assert(_type == 65535)
163 _len = reader.read("!H")[0]
164 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800165 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800166 _experimenter = reader.read("!L")[0]
167 assert(_experimenter == 6035143)
168 obj.subtype = reader.read("!L")[0]
169 reader.skip(4)
170 return obj
171
172 def __eq__(self, other):
173 if type(self) != type(other): return False
174 if self.subtype != other.subtype: return False
175 return True
176
177 def pretty_print(self, q):
178 q.text("bsn {")
179 with q.group():
180 with q.indent(2):
181 q.breakable()
182 q.breakable()
183 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800184
185experimenter.subtypes[6035143] = bsn
186
Rich Lane5587ab12014-06-30 11:19:09 -0700187class bsn_checksum(bsn):
188 type = 65535
189 experimenter = 6035143
190 subtype = 4
191
192 def __init__(self, checksum=None):
193 if checksum != None:
194 self.checksum = checksum
195 else:
196 self.checksum = 0
197 return
198
199 def pack(self):
200 packed = []
201 packed.append(struct.pack("!H", self.type))
202 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
203 packed.append(struct.pack("!L", self.experimenter))
204 packed.append(struct.pack("!L", self.subtype))
205 packed.append(util.pack_checksum_128(self.checksum))
206 length = sum([len(x) for x in packed])
207 packed[1] = struct.pack("!H", length)
208 return ''.join(packed)
209
210 @staticmethod
211 def unpack(reader):
212 obj = bsn_checksum()
213 _type = reader.read("!H")[0]
214 assert(_type == 65535)
215 _len = reader.read("!H")[0]
216 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800217 reader = orig_reader.slice(_len, 4)
Rich Lane5587ab12014-06-30 11:19:09 -0700218 _experimenter = reader.read("!L")[0]
219 assert(_experimenter == 6035143)
220 _subtype = reader.read("!L")[0]
221 assert(_subtype == 4)
222 obj.checksum = util.unpack_checksum_128(reader)
223 return obj
224
225 def __eq__(self, other):
226 if type(self) != type(other): return False
227 if self.checksum != other.checksum: return False
228 return True
229
230 def pretty_print(self, q):
231 q.text("bsn_checksum {")
232 with q.group():
233 with q.indent(2):
234 q.breakable()
235 q.text("checksum = ");
236 q.pp(self.checksum)
237 q.breakable()
238 q.text('}')
239
240bsn.subtypes[4] = bsn_checksum
241
Rich Lane7dcdf022013-12-11 14:45:27 -0800242class bsn_mirror(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700243 type = 65535
244 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -0700245 subtype = 1
246
247 def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None):
248 if dest_port != None:
249 self.dest_port = dest_port
250 else:
251 self.dest_port = 0
252 if vlan_tag != None:
253 self.vlan_tag = vlan_tag
254 else:
255 self.vlan_tag = 0
256 if copy_stage != None:
257 self.copy_stage = copy_stage
258 else:
259 self.copy_stage = 0
260 return
261
262 def pack(self):
263 packed = []
264 packed.append(struct.pack("!H", self.type))
265 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
266 packed.append(struct.pack("!L", self.experimenter))
267 packed.append(struct.pack("!L", self.subtype))
268 packed.append(struct.pack("!L", self.dest_port))
269 packed.append(struct.pack("!L", self.vlan_tag))
270 packed.append(struct.pack("!B", self.copy_stage))
271 packed.append('\x00' * 3)
272 length = sum([len(x) for x in packed])
273 packed[1] = struct.pack("!H", length)
274 return ''.join(packed)
275
276 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800277 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700278 obj = bsn_mirror()
Dan Talaycof6202252013-07-02 01:00:29 -0700279 _type = reader.read("!H")[0]
280 assert(_type == 65535)
281 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800282 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800283 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700284 _experimenter = reader.read("!L")[0]
285 assert(_experimenter == 6035143)
286 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700287 assert(_subtype == 1)
Dan Talaycof6202252013-07-02 01:00:29 -0700288 obj.dest_port = reader.read("!L")[0]
289 obj.vlan_tag = reader.read("!L")[0]
290 obj.copy_stage = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700291 reader.skip(3)
292 return obj
293
294 def __eq__(self, other):
295 if type(self) != type(other): return False
296 if self.dest_port != other.dest_port: return False
297 if self.vlan_tag != other.vlan_tag: return False
298 if self.copy_stage != other.copy_stage: return False
299 return True
300
Rich Lanec2ee4b82013-04-24 17:12:38 -0700301 def pretty_print(self, q):
302 q.text("bsn_mirror {")
303 with q.group():
304 with q.indent(2):
305 q.breakable()
306 q.text("dest_port = ");
307 q.text("%#x" % self.dest_port)
308 q.text(","); q.breakable()
309 q.text("vlan_tag = ");
310 q.text("%#x" % self.vlan_tag)
311 q.text(","); q.breakable()
312 q.text("copy_stage = ");
313 q.text("%#x" % self.copy_stage)
314 q.breakable()
315 q.text('}')
316
Rich Lane7dcdf022013-12-11 14:45:27 -0800317bsn.subtypes[1] = bsn_mirror
318
319class bsn_set_tunnel_dst(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700320 type = 65535
321 experimenter = 6035143
Rich Lanec2ee4b82013-04-24 17:12:38 -0700322 subtype = 2
323
324 def __init__(self, dst=None):
325 if dst != None:
326 self.dst = dst
327 else:
328 self.dst = 0
329 return
330
331 def pack(self):
332 packed = []
333 packed.append(struct.pack("!H", self.type))
334 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
335 packed.append(struct.pack("!L", self.experimenter))
336 packed.append(struct.pack("!L", self.subtype))
337 packed.append(struct.pack("!L", self.dst))
338 length = sum([len(x) for x in packed])
339 packed[1] = struct.pack("!H", length)
340 return ''.join(packed)
341
342 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800343 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700344 obj = bsn_set_tunnel_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700345 _type = reader.read("!H")[0]
346 assert(_type == 65535)
347 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800348 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800349 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700350 _experimenter = reader.read("!L")[0]
351 assert(_experimenter == 6035143)
352 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700353 assert(_subtype == 2)
Dan Talaycof6202252013-07-02 01:00:29 -0700354 obj.dst = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700355 return obj
356
357 def __eq__(self, other):
358 if type(self) != type(other): return False
359 if self.dst != other.dst: return False
360 return True
361
Rich Lanec2ee4b82013-04-24 17:12:38 -0700362 def pretty_print(self, q):
363 q.text("bsn_set_tunnel_dst {")
364 with q.group():
365 with q.indent(2):
366 q.breakable()
367 q.text("dst = ");
368 q.text("%#x" % self.dst)
369 q.breakable()
370 q.text('}')
371
Rich Lane7dcdf022013-12-11 14:45:27 -0800372bsn.subtypes[2] = bsn_set_tunnel_dst
373
374class copy_ttl_in(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700375 type = 12
Rich Lanec2ee4b82013-04-24 17:12:38 -0700376
377 def __init__(self):
378 return
379
380 def pack(self):
381 packed = []
382 packed.append(struct.pack("!H", self.type))
383 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
384 packed.append('\x00' * 4)
385 length = sum([len(x) for x in packed])
386 packed[1] = struct.pack("!H", length)
387 return ''.join(packed)
388
389 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800390 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700391 obj = copy_ttl_in()
Dan Talaycof6202252013-07-02 01:00:29 -0700392 _type = reader.read("!H")[0]
393 assert(_type == 12)
394 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800395 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800396 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700397 reader.skip(4)
398 return obj
399
400 def __eq__(self, other):
401 if type(self) != type(other): return False
402 return True
403
Rich Lanec2ee4b82013-04-24 17:12:38 -0700404 def pretty_print(self, q):
405 q.text("copy_ttl_in {")
406 with q.group():
407 with q.indent(2):
408 q.breakable()
409 q.breakable()
410 q.text('}')
411
Rich Lane7dcdf022013-12-11 14:45:27 -0800412action.subtypes[12] = copy_ttl_in
413
414class copy_ttl_out(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700415 type = 11
Rich Lanec2ee4b82013-04-24 17:12:38 -0700416
417 def __init__(self):
418 return
419
420 def pack(self):
421 packed = []
422 packed.append(struct.pack("!H", self.type))
423 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
424 packed.append('\x00' * 4)
425 length = sum([len(x) for x in packed])
426 packed[1] = struct.pack("!H", length)
427 return ''.join(packed)
428
429 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800430 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700431 obj = copy_ttl_out()
Dan Talaycof6202252013-07-02 01:00:29 -0700432 _type = reader.read("!H")[0]
433 assert(_type == 11)
434 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800435 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800436 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700437 reader.skip(4)
438 return obj
439
440 def __eq__(self, other):
441 if type(self) != type(other): return False
442 return True
443
Rich Lanec2ee4b82013-04-24 17:12:38 -0700444 def pretty_print(self, q):
445 q.text("copy_ttl_out {")
446 with q.group():
447 with q.indent(2):
448 q.breakable()
449 q.breakable()
450 q.text('}')
451
Rich Lane7dcdf022013-12-11 14:45:27 -0800452action.subtypes[11] = copy_ttl_out
453
454class dec_mpls_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700455 type = 16
Rich Lanec2ee4b82013-04-24 17:12:38 -0700456
457 def __init__(self):
458 return
459
460 def pack(self):
461 packed = []
462 packed.append(struct.pack("!H", self.type))
463 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
464 packed.append('\x00' * 4)
465 length = sum([len(x) for x in packed])
466 packed[1] = struct.pack("!H", length)
467 return ''.join(packed)
468
469 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800470 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700471 obj = dec_mpls_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700472 _type = reader.read("!H")[0]
473 assert(_type == 16)
474 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800475 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800476 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700477 reader.skip(4)
478 return obj
479
480 def __eq__(self, other):
481 if type(self) != type(other): return False
482 return True
483
Rich Lanec2ee4b82013-04-24 17:12:38 -0700484 def pretty_print(self, q):
485 q.text("dec_mpls_ttl {")
486 with q.group():
487 with q.indent(2):
488 q.breakable()
489 q.breakable()
490 q.text('}')
491
Rich Lane7dcdf022013-12-11 14:45:27 -0800492action.subtypes[16] = dec_mpls_ttl
493
494class dec_nw_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700495 type = 24
Rich Lanec2ee4b82013-04-24 17:12:38 -0700496
497 def __init__(self):
498 return
499
500 def pack(self):
501 packed = []
502 packed.append(struct.pack("!H", self.type))
503 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
504 packed.append('\x00' * 4)
505 length = sum([len(x) for x in packed])
506 packed[1] = struct.pack("!H", length)
507 return ''.join(packed)
508
509 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800510 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700511 obj = dec_nw_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700512 _type = reader.read("!H")[0]
513 assert(_type == 24)
514 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800515 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800516 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700517 reader.skip(4)
518 return obj
519
520 def __eq__(self, other):
521 if type(self) != type(other): return False
522 return True
523
Rich Lanec2ee4b82013-04-24 17:12:38 -0700524 def pretty_print(self, q):
525 q.text("dec_nw_ttl {")
526 with q.group():
527 with q.indent(2):
528 q.breakable()
529 q.breakable()
530 q.text('}')
531
Rich Lane7dcdf022013-12-11 14:45:27 -0800532action.subtypes[24] = dec_nw_ttl
533
534class group(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700535 type = 22
Rich Lanec2ee4b82013-04-24 17:12:38 -0700536
537 def __init__(self, group_id=None):
538 if group_id != None:
539 self.group_id = group_id
540 else:
541 self.group_id = 0
542 return
543
544 def pack(self):
545 packed = []
546 packed.append(struct.pack("!H", self.type))
547 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
548 packed.append(struct.pack("!L", self.group_id))
549 length = sum([len(x) for x in packed])
550 packed[1] = struct.pack("!H", length)
551 return ''.join(packed)
552
553 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800554 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700555 obj = group()
Dan Talaycof6202252013-07-02 01:00:29 -0700556 _type = reader.read("!H")[0]
557 assert(_type == 22)
558 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800559 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800560 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700561 obj.group_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700562 return obj
563
564 def __eq__(self, other):
565 if type(self) != type(other): return False
566 if self.group_id != other.group_id: return False
567 return True
568
Rich Lanec2ee4b82013-04-24 17:12:38 -0700569 def pretty_print(self, q):
570 q.text("group {")
571 with q.group():
572 with q.indent(2):
573 q.breakable()
574 q.text("group_id = ");
575 q.text("%#x" % self.group_id)
576 q.breakable()
577 q.text('}')
578
Rich Lane7dcdf022013-12-11 14:45:27 -0800579action.subtypes[22] = group
580
581class nicira(experimenter):
582 subtypes = {}
583
Rich Lane95f7fc92014-01-27 17:08:16 -0800584 type = 65535
585 experimenter = 8992
586
587 def __init__(self, subtype=None):
588 if subtype != None:
589 self.subtype = subtype
590 else:
591 self.subtype = 0
592 return
593
594 def pack(self):
595 packed = []
596 packed.append(struct.pack("!H", self.type))
597 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
598 packed.append(struct.pack("!L", self.experimenter))
599 packed.append(struct.pack("!H", self.subtype))
600 packed.append('\x00' * 2)
601 packed.append('\x00' * 4)
602 length = sum([len(x) for x in packed])
603 packed[1] = struct.pack("!H", length)
604 return ''.join(packed)
605
Rich Lane7dcdf022013-12-11 14:45:27 -0800606 @staticmethod
607 def unpack(reader):
608 subtype, = reader.peek('!H', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800609 subclass = nicira.subtypes.get(subtype)
610 if subclass:
611 return subclass.unpack(reader)
612
613 obj = nicira()
614 _type = reader.read("!H")[0]
615 assert(_type == 65535)
616 _len = reader.read("!H")[0]
617 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800618 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800619 _experimenter = reader.read("!L")[0]
620 assert(_experimenter == 8992)
621 obj.subtype = reader.read("!H")[0]
622 reader.skip(2)
623 reader.skip(4)
624 return obj
625
626 def __eq__(self, other):
627 if type(self) != type(other): return False
628 if self.subtype != other.subtype: return False
629 return True
630
631 def pretty_print(self, q):
632 q.text("nicira {")
633 with q.group():
634 with q.indent(2):
635 q.breakable()
636 q.breakable()
637 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800638
639experimenter.subtypes[8992] = nicira
640
641class nicira_dec_ttl(nicira):
Dan Talaycof6202252013-07-02 01:00:29 -0700642 type = 65535
643 experimenter = 8992
Rich Lanec2ee4b82013-04-24 17:12:38 -0700644 subtype = 18
645
646 def __init__(self):
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
653 packed.append(struct.pack("!L", self.experimenter))
654 packed.append(struct.pack("!H", self.subtype))
655 packed.append('\x00' * 2)
656 packed.append('\x00' * 4)
657 length = sum([len(x) for x in packed])
658 packed[1] = struct.pack("!H", length)
659 return ''.join(packed)
660
661 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800662 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700663 obj = nicira_dec_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700664 _type = reader.read("!H")[0]
665 assert(_type == 65535)
666 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800667 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800668 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700669 _experimenter = reader.read("!L")[0]
670 assert(_experimenter == 8992)
671 _subtype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700672 assert(_subtype == 18)
673 reader.skip(2)
674 reader.skip(4)
675 return obj
676
677 def __eq__(self, other):
678 if type(self) != type(other): return False
679 return True
680
Rich Lanec2ee4b82013-04-24 17:12:38 -0700681 def pretty_print(self, q):
682 q.text("nicira_dec_ttl {")
683 with q.group():
684 with q.indent(2):
685 q.breakable()
686 q.breakable()
687 q.text('}')
688
Rich Lane7dcdf022013-12-11 14:45:27 -0800689nicira.subtypes[18] = nicira_dec_ttl
690
691class output(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700692 type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700693
694 def __init__(self, port=None, max_len=None):
695 if port != None:
696 self.port = port
697 else:
698 self.port = 0
699 if max_len != None:
700 self.max_len = max_len
701 else:
702 self.max_len = 0
703 return
704
705 def pack(self):
706 packed = []
707 packed.append(struct.pack("!H", self.type))
708 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700709 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700710 packed.append(struct.pack("!H", self.max_len))
711 packed.append('\x00' * 6)
712 length = sum([len(x) for x in packed])
713 packed[1] = struct.pack("!H", length)
714 return ''.join(packed)
715
716 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800717 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700718 obj = output()
Dan Talaycof6202252013-07-02 01:00:29 -0700719 _type = reader.read("!H")[0]
720 assert(_type == 0)
721 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800722 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800723 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700724 obj.port = util.unpack_port_no(reader)
725 obj.max_len = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700726 reader.skip(6)
727 return obj
728
729 def __eq__(self, other):
730 if type(self) != type(other): return False
731 if self.port != other.port: return False
732 if self.max_len != other.max_len: return False
733 return True
734
Rich Lanec2ee4b82013-04-24 17:12:38 -0700735 def pretty_print(self, q):
736 q.text("output {")
737 with q.group():
738 with q.indent(2):
739 q.breakable()
740 q.text("port = ");
741 q.text(util.pretty_port(self.port))
742 q.text(","); q.breakable()
743 q.text("max_len = ");
744 q.text("%#x" % self.max_len)
745 q.breakable()
746 q.text('}')
747
Rich Lane7dcdf022013-12-11 14:45:27 -0800748action.subtypes[0] = output
749
750class pop_mpls(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700751 type = 20
Rich Lanec2ee4b82013-04-24 17:12:38 -0700752
753 def __init__(self, ethertype=None):
754 if ethertype != None:
755 self.ethertype = ethertype
756 else:
757 self.ethertype = 0
758 return
759
760 def pack(self):
761 packed = []
762 packed.append(struct.pack("!H", self.type))
763 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
764 packed.append(struct.pack("!H", self.ethertype))
765 packed.append('\x00' * 2)
766 length = sum([len(x) for x in packed])
767 packed[1] = struct.pack("!H", length)
768 return ''.join(packed)
769
770 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800771 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700772 obj = pop_mpls()
Dan Talaycof6202252013-07-02 01:00:29 -0700773 _type = reader.read("!H")[0]
774 assert(_type == 20)
775 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800776 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800777 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700778 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700779 reader.skip(2)
780 return obj
781
782 def __eq__(self, other):
783 if type(self) != type(other): return False
784 if self.ethertype != other.ethertype: return False
785 return True
786
Rich Lanec2ee4b82013-04-24 17:12:38 -0700787 def pretty_print(self, q):
788 q.text("pop_mpls {")
789 with q.group():
790 with q.indent(2):
791 q.breakable()
792 q.text("ethertype = ");
793 q.text("%#x" % self.ethertype)
794 q.breakable()
795 q.text('}')
796
Rich Lane7dcdf022013-12-11 14:45:27 -0800797action.subtypes[20] = pop_mpls
798
799class pop_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700800 type = 18
Rich Lanec2ee4b82013-04-24 17:12:38 -0700801
802 def __init__(self):
803 return
804
805 def pack(self):
806 packed = []
807 packed.append(struct.pack("!H", self.type))
808 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
809 packed.append('\x00' * 4)
810 length = sum([len(x) for x in packed])
811 packed[1] = struct.pack("!H", length)
812 return ''.join(packed)
813
814 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800815 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700816 obj = pop_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -0700817 _type = reader.read("!H")[0]
818 assert(_type == 18)
819 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800820 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800821 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700822 reader.skip(4)
823 return obj
824
825 def __eq__(self, other):
826 if type(self) != type(other): return False
827 return True
828
Rich Lanec2ee4b82013-04-24 17:12:38 -0700829 def pretty_print(self, q):
830 q.text("pop_vlan {")
831 with q.group():
832 with q.indent(2):
833 q.breakable()
834 q.breakable()
835 q.text('}')
836
Rich Lane7dcdf022013-12-11 14:45:27 -0800837action.subtypes[18] = pop_vlan
838
839class push_mpls(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700840 type = 19
Rich Lanec2ee4b82013-04-24 17:12:38 -0700841
842 def __init__(self, ethertype=None):
843 if ethertype != None:
844 self.ethertype = ethertype
845 else:
846 self.ethertype = 0
847 return
848
849 def pack(self):
850 packed = []
851 packed.append(struct.pack("!H", self.type))
852 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
853 packed.append(struct.pack("!H", self.ethertype))
854 packed.append('\x00' * 2)
855 length = sum([len(x) for x in packed])
856 packed[1] = struct.pack("!H", length)
857 return ''.join(packed)
858
859 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800860 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700861 obj = push_mpls()
Dan Talaycof6202252013-07-02 01:00:29 -0700862 _type = reader.read("!H")[0]
863 assert(_type == 19)
864 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800865 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800866 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700867 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700868 reader.skip(2)
869 return obj
870
871 def __eq__(self, other):
872 if type(self) != type(other): return False
873 if self.ethertype != other.ethertype: return False
874 return True
875
Rich Lanec2ee4b82013-04-24 17:12:38 -0700876 def pretty_print(self, q):
877 q.text("push_mpls {")
878 with q.group():
879 with q.indent(2):
880 q.breakable()
881 q.text("ethertype = ");
882 q.text("%#x" % self.ethertype)
883 q.breakable()
884 q.text('}')
885
Rich Lane7dcdf022013-12-11 14:45:27 -0800886action.subtypes[19] = push_mpls
887
888class push_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700889 type = 17
Rich Lanec2ee4b82013-04-24 17:12:38 -0700890
891 def __init__(self, ethertype=None):
892 if ethertype != None:
893 self.ethertype = ethertype
894 else:
895 self.ethertype = 0
896 return
897
898 def pack(self):
899 packed = []
900 packed.append(struct.pack("!H", self.type))
901 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
902 packed.append(struct.pack("!H", self.ethertype))
903 packed.append('\x00' * 2)
904 length = sum([len(x) for x in packed])
905 packed[1] = struct.pack("!H", length)
906 return ''.join(packed)
907
908 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800909 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700910 obj = push_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -0700911 _type = reader.read("!H")[0]
912 assert(_type == 17)
913 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800914 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800915 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700916 obj.ethertype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700917 reader.skip(2)
918 return obj
919
920 def __eq__(self, other):
921 if type(self) != type(other): return False
922 if self.ethertype != other.ethertype: return False
923 return True
924
Rich Lanec2ee4b82013-04-24 17:12:38 -0700925 def pretty_print(self, q):
926 q.text("push_vlan {")
927 with q.group():
928 with q.indent(2):
929 q.breakable()
930 q.text("ethertype = ");
931 q.text("%#x" % self.ethertype)
932 q.breakable()
933 q.text('}')
934
Rich Lane7dcdf022013-12-11 14:45:27 -0800935action.subtypes[17] = push_vlan
936
937class set_dl_dst(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700938 type = 4
Rich Lanec2ee4b82013-04-24 17:12:38 -0700939
940 def __init__(self, dl_addr=None):
941 if dl_addr != None:
942 self.dl_addr = dl_addr
943 else:
944 self.dl_addr = [0,0,0,0,0,0]
945 return
946
947 def pack(self):
948 packed = []
949 packed.append(struct.pack("!H", self.type))
950 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
951 packed.append(struct.pack("!6B", *self.dl_addr))
952 packed.append('\x00' * 6)
953 length = sum([len(x) for x in packed])
954 packed[1] = struct.pack("!H", length)
955 return ''.join(packed)
956
957 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800958 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700959 obj = set_dl_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700960 _type = reader.read("!H")[0]
961 assert(_type == 4)
962 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800963 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800964 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700965 obj.dl_addr = list(reader.read('!6B'))
966 reader.skip(6)
967 return obj
968
969 def __eq__(self, other):
970 if type(self) != type(other): return False
971 if self.dl_addr != other.dl_addr: return False
972 return True
973
Rich Lanec2ee4b82013-04-24 17:12:38 -0700974 def pretty_print(self, q):
975 q.text("set_dl_dst {")
976 with q.group():
977 with q.indent(2):
978 q.breakable()
979 q.text("dl_addr = ");
980 q.text(util.pretty_mac(self.dl_addr))
981 q.breakable()
982 q.text('}')
983
Rich Lane7dcdf022013-12-11 14:45:27 -0800984action.subtypes[4] = set_dl_dst
985
986class set_dl_src(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700987 type = 3
Rich Lanec2ee4b82013-04-24 17:12:38 -0700988
989 def __init__(self, dl_addr=None):
990 if dl_addr != None:
991 self.dl_addr = dl_addr
992 else:
993 self.dl_addr = [0,0,0,0,0,0]
994 return
995
996 def pack(self):
997 packed = []
998 packed.append(struct.pack("!H", self.type))
999 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1000 packed.append(struct.pack("!6B", *self.dl_addr))
1001 packed.append('\x00' * 6)
1002 length = sum([len(x) for x in packed])
1003 packed[1] = struct.pack("!H", length)
1004 return ''.join(packed)
1005
1006 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001007 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001008 obj = set_dl_src()
Dan Talaycof6202252013-07-02 01:00:29 -07001009 _type = reader.read("!H")[0]
1010 assert(_type == 3)
1011 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001012 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001013 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001014 obj.dl_addr = list(reader.read('!6B'))
1015 reader.skip(6)
1016 return obj
1017
1018 def __eq__(self, other):
1019 if type(self) != type(other): return False
1020 if self.dl_addr != other.dl_addr: return False
1021 return True
1022
Rich Lanec2ee4b82013-04-24 17:12:38 -07001023 def pretty_print(self, q):
1024 q.text("set_dl_src {")
1025 with q.group():
1026 with q.indent(2):
1027 q.breakable()
1028 q.text("dl_addr = ");
1029 q.text(util.pretty_mac(self.dl_addr))
1030 q.breakable()
1031 q.text('}')
1032
Rich Lane7dcdf022013-12-11 14:45:27 -08001033action.subtypes[3] = set_dl_src
1034
1035class set_mpls_label(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001036 type = 13
Rich Lanec2ee4b82013-04-24 17:12:38 -07001037
1038 def __init__(self, mpls_label=None):
1039 if mpls_label != None:
1040 self.mpls_label = mpls_label
1041 else:
1042 self.mpls_label = 0
1043 return
1044
1045 def pack(self):
1046 packed = []
1047 packed.append(struct.pack("!H", self.type))
1048 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1049 packed.append(struct.pack("!L", self.mpls_label))
1050 length = sum([len(x) for x in packed])
1051 packed[1] = struct.pack("!H", length)
1052 return ''.join(packed)
1053
1054 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001055 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001056 obj = set_mpls_label()
Dan Talaycof6202252013-07-02 01:00:29 -07001057 _type = reader.read("!H")[0]
1058 assert(_type == 13)
1059 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001060 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001061 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001062 obj.mpls_label = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001063 return obj
1064
1065 def __eq__(self, other):
1066 if type(self) != type(other): return False
1067 if self.mpls_label != other.mpls_label: return False
1068 return True
1069
Rich Lanec2ee4b82013-04-24 17:12:38 -07001070 def pretty_print(self, q):
1071 q.text("set_mpls_label {")
1072 with q.group():
1073 with q.indent(2):
1074 q.breakable()
1075 q.text("mpls_label = ");
1076 q.text("%#x" % self.mpls_label)
1077 q.breakable()
1078 q.text('}')
1079
Rich Lane7dcdf022013-12-11 14:45:27 -08001080action.subtypes[13] = set_mpls_label
1081
1082class set_mpls_tc(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001083 type = 14
Rich Lanec2ee4b82013-04-24 17:12:38 -07001084
1085 def __init__(self, mpls_tc=None):
1086 if mpls_tc != None:
1087 self.mpls_tc = mpls_tc
1088 else:
1089 self.mpls_tc = 0
1090 return
1091
1092 def pack(self):
1093 packed = []
1094 packed.append(struct.pack("!H", self.type))
1095 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1096 packed.append(struct.pack("!B", self.mpls_tc))
1097 packed.append('\x00' * 3)
1098 length = sum([len(x) for x in packed])
1099 packed[1] = struct.pack("!H", length)
1100 return ''.join(packed)
1101
1102 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001103 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001104 obj = set_mpls_tc()
Dan Talaycof6202252013-07-02 01:00:29 -07001105 _type = reader.read("!H")[0]
1106 assert(_type == 14)
1107 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001108 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001109 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001110 obj.mpls_tc = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001111 reader.skip(3)
1112 return obj
1113
1114 def __eq__(self, other):
1115 if type(self) != type(other): return False
1116 if self.mpls_tc != other.mpls_tc: return False
1117 return True
1118
Rich Lanec2ee4b82013-04-24 17:12:38 -07001119 def pretty_print(self, q):
1120 q.text("set_mpls_tc {")
1121 with q.group():
1122 with q.indent(2):
1123 q.breakable()
1124 q.text("mpls_tc = ");
1125 q.text("%#x" % self.mpls_tc)
1126 q.breakable()
1127 q.text('}')
1128
Rich Lane7dcdf022013-12-11 14:45:27 -08001129action.subtypes[14] = set_mpls_tc
1130
1131class set_mpls_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001132 type = 15
Rich Lanec2ee4b82013-04-24 17:12:38 -07001133
1134 def __init__(self, mpls_ttl=None):
1135 if mpls_ttl != None:
1136 self.mpls_ttl = mpls_ttl
1137 else:
1138 self.mpls_ttl = 0
1139 return
1140
1141 def pack(self):
1142 packed = []
1143 packed.append(struct.pack("!H", self.type))
1144 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1145 packed.append(struct.pack("!B", self.mpls_ttl))
1146 packed.append('\x00' * 3)
1147 length = sum([len(x) for x in packed])
1148 packed[1] = struct.pack("!H", length)
1149 return ''.join(packed)
1150
1151 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001152 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001153 obj = set_mpls_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -07001154 _type = reader.read("!H")[0]
1155 assert(_type == 15)
1156 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001157 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001158 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001159 obj.mpls_ttl = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001160 reader.skip(3)
1161 return obj
1162
1163 def __eq__(self, other):
1164 if type(self) != type(other): return False
1165 if self.mpls_ttl != other.mpls_ttl: return False
1166 return True
1167
Rich Lanec2ee4b82013-04-24 17:12:38 -07001168 def pretty_print(self, q):
1169 q.text("set_mpls_ttl {")
1170 with q.group():
1171 with q.indent(2):
1172 q.breakable()
1173 q.text("mpls_ttl = ");
1174 q.text("%#x" % self.mpls_ttl)
1175 q.breakable()
1176 q.text('}')
1177
Rich Lane7dcdf022013-12-11 14:45:27 -08001178action.subtypes[15] = set_mpls_ttl
1179
1180class set_nw_dst(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001181 type = 6
Rich Lanec2ee4b82013-04-24 17:12:38 -07001182
1183 def __init__(self, nw_addr=None):
1184 if nw_addr != None:
1185 self.nw_addr = nw_addr
1186 else:
1187 self.nw_addr = 0
1188 return
1189
1190 def pack(self):
1191 packed = []
1192 packed.append(struct.pack("!H", self.type))
1193 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1194 packed.append(struct.pack("!L", self.nw_addr))
1195 length = sum([len(x) for x in packed])
1196 packed[1] = struct.pack("!H", length)
1197 return ''.join(packed)
1198
1199 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001200 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001201 obj = set_nw_dst()
Dan Talaycof6202252013-07-02 01:00:29 -07001202 _type = reader.read("!H")[0]
1203 assert(_type == 6)
1204 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001205 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001206 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001207 obj.nw_addr = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001208 return obj
1209
1210 def __eq__(self, other):
1211 if type(self) != type(other): return False
1212 if self.nw_addr != other.nw_addr: return False
1213 return True
1214
Rich Lanec2ee4b82013-04-24 17:12:38 -07001215 def pretty_print(self, q):
1216 q.text("set_nw_dst {")
1217 with q.group():
1218 with q.indent(2):
1219 q.breakable()
1220 q.text("nw_addr = ");
1221 q.text("%#x" % self.nw_addr)
1222 q.breakable()
1223 q.text('}')
1224
Rich Lane7dcdf022013-12-11 14:45:27 -08001225action.subtypes[6] = set_nw_dst
1226
1227class set_nw_ecn(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001228 type = 8
Rich Lanec2ee4b82013-04-24 17:12:38 -07001229
1230 def __init__(self, nw_ecn=None):
1231 if nw_ecn != None:
1232 self.nw_ecn = nw_ecn
1233 else:
1234 self.nw_ecn = 0
1235 return
1236
1237 def pack(self):
1238 packed = []
1239 packed.append(struct.pack("!H", self.type))
1240 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1241 packed.append(struct.pack("!B", self.nw_ecn))
1242 packed.append('\x00' * 3)
1243 length = sum([len(x) for x in packed])
1244 packed[1] = struct.pack("!H", length)
1245 return ''.join(packed)
1246
1247 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001248 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001249 obj = set_nw_ecn()
Dan Talaycof6202252013-07-02 01:00:29 -07001250 _type = reader.read("!H")[0]
1251 assert(_type == 8)
1252 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001253 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001254 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001255 obj.nw_ecn = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001256 reader.skip(3)
1257 return obj
1258
1259 def __eq__(self, other):
1260 if type(self) != type(other): return False
1261 if self.nw_ecn != other.nw_ecn: return False
1262 return True
1263
Rich Lanec2ee4b82013-04-24 17:12:38 -07001264 def pretty_print(self, q):
1265 q.text("set_nw_ecn {")
1266 with q.group():
1267 with q.indent(2):
1268 q.breakable()
1269 q.text("nw_ecn = ");
1270 q.text("%#x" % self.nw_ecn)
1271 q.breakable()
1272 q.text('}')
1273
Rich Lane7dcdf022013-12-11 14:45:27 -08001274action.subtypes[8] = set_nw_ecn
1275
1276class set_nw_src(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001277 type = 5
Rich Lanec2ee4b82013-04-24 17:12:38 -07001278
1279 def __init__(self, nw_addr=None):
1280 if nw_addr != None:
1281 self.nw_addr = nw_addr
1282 else:
1283 self.nw_addr = 0
1284 return
1285
1286 def pack(self):
1287 packed = []
1288 packed.append(struct.pack("!H", self.type))
1289 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1290 packed.append(struct.pack("!L", self.nw_addr))
1291 length = sum([len(x) for x in packed])
1292 packed[1] = struct.pack("!H", length)
1293 return ''.join(packed)
1294
1295 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001296 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001297 obj = set_nw_src()
Dan Talaycof6202252013-07-02 01:00:29 -07001298 _type = reader.read("!H")[0]
1299 assert(_type == 5)
1300 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001301 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001302 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001303 obj.nw_addr = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001304 return obj
1305
1306 def __eq__(self, other):
1307 if type(self) != type(other): return False
1308 if self.nw_addr != other.nw_addr: return False
1309 return True
1310
Rich Lanec2ee4b82013-04-24 17:12:38 -07001311 def pretty_print(self, q):
1312 q.text("set_nw_src {")
1313 with q.group():
1314 with q.indent(2):
1315 q.breakable()
1316 q.text("nw_addr = ");
1317 q.text("%#x" % self.nw_addr)
1318 q.breakable()
1319 q.text('}')
1320
Rich Lane7dcdf022013-12-11 14:45:27 -08001321action.subtypes[5] = set_nw_src
1322
1323class set_nw_tos(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001324 type = 7
Rich Lanec2ee4b82013-04-24 17:12:38 -07001325
1326 def __init__(self, nw_tos=None):
1327 if nw_tos != None:
1328 self.nw_tos = nw_tos
1329 else:
1330 self.nw_tos = 0
1331 return
1332
1333 def pack(self):
1334 packed = []
1335 packed.append(struct.pack("!H", self.type))
1336 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1337 packed.append(struct.pack("!B", self.nw_tos))
1338 packed.append('\x00' * 3)
1339 length = sum([len(x) for x in packed])
1340 packed[1] = struct.pack("!H", length)
1341 return ''.join(packed)
1342
1343 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001344 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001345 obj = set_nw_tos()
Dan Talaycof6202252013-07-02 01:00:29 -07001346 _type = reader.read("!H")[0]
1347 assert(_type == 7)
1348 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001349 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001350 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001351 obj.nw_tos = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001352 reader.skip(3)
1353 return obj
1354
1355 def __eq__(self, other):
1356 if type(self) != type(other): return False
1357 if self.nw_tos != other.nw_tos: return False
1358 return True
1359
Rich Lanec2ee4b82013-04-24 17:12:38 -07001360 def pretty_print(self, q):
1361 q.text("set_nw_tos {")
1362 with q.group():
1363 with q.indent(2):
1364 q.breakable()
1365 q.text("nw_tos = ");
1366 q.text("%#x" % self.nw_tos)
1367 q.breakable()
1368 q.text('}')
1369
Rich Lane7dcdf022013-12-11 14:45:27 -08001370action.subtypes[7] = set_nw_tos
1371
1372class set_nw_ttl(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001373 type = 23
Rich Lanec2ee4b82013-04-24 17:12:38 -07001374
1375 def __init__(self, nw_ttl=None):
1376 if nw_ttl != None:
1377 self.nw_ttl = nw_ttl
1378 else:
1379 self.nw_ttl = 0
1380 return
1381
1382 def pack(self):
1383 packed = []
1384 packed.append(struct.pack("!H", self.type))
1385 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1386 packed.append(struct.pack("!B", self.nw_ttl))
1387 packed.append('\x00' * 3)
1388 length = sum([len(x) for x in packed])
1389 packed[1] = struct.pack("!H", length)
1390 return ''.join(packed)
1391
1392 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001393 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001394 obj = set_nw_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -07001395 _type = reader.read("!H")[0]
1396 assert(_type == 23)
1397 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001398 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001399 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001400 obj.nw_ttl = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001401 reader.skip(3)
1402 return obj
1403
1404 def __eq__(self, other):
1405 if type(self) != type(other): return False
1406 if self.nw_ttl != other.nw_ttl: return False
1407 return True
1408
Rich Lanec2ee4b82013-04-24 17:12:38 -07001409 def pretty_print(self, q):
1410 q.text("set_nw_ttl {")
1411 with q.group():
1412 with q.indent(2):
1413 q.breakable()
1414 q.text("nw_ttl = ");
1415 q.text("%#x" % self.nw_ttl)
1416 q.breakable()
1417 q.text('}')
1418
Rich Lane7dcdf022013-12-11 14:45:27 -08001419action.subtypes[23] = set_nw_ttl
1420
1421class set_queue(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001422 type = 21
Rich Lanec2ee4b82013-04-24 17:12:38 -07001423
1424 def __init__(self, queue_id=None):
1425 if queue_id != None:
1426 self.queue_id = queue_id
1427 else:
1428 self.queue_id = 0
1429 return
1430
1431 def pack(self):
1432 packed = []
1433 packed.append(struct.pack("!H", self.type))
1434 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1435 packed.append(struct.pack("!L", self.queue_id))
1436 length = sum([len(x) for x in packed])
1437 packed[1] = struct.pack("!H", length)
1438 return ''.join(packed)
1439
1440 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001441 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001442 obj = set_queue()
Dan Talaycof6202252013-07-02 01:00:29 -07001443 _type = reader.read("!H")[0]
1444 assert(_type == 21)
1445 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001446 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001447 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001448 obj.queue_id = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001449 return obj
1450
1451 def __eq__(self, other):
1452 if type(self) != type(other): return False
1453 if self.queue_id != other.queue_id: return False
1454 return True
1455
Rich Lanec2ee4b82013-04-24 17:12:38 -07001456 def pretty_print(self, q):
1457 q.text("set_queue {")
1458 with q.group():
1459 with q.indent(2):
1460 q.breakable()
1461 q.text("queue_id = ");
1462 q.text("%#x" % self.queue_id)
1463 q.breakable()
1464 q.text('}')
1465
Rich Lane7dcdf022013-12-11 14:45:27 -08001466action.subtypes[21] = set_queue
1467
1468class set_tp_dst(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001469 type = 10
Rich Lanec2ee4b82013-04-24 17:12:38 -07001470
1471 def __init__(self, tp_port=None):
1472 if tp_port != None:
1473 self.tp_port = tp_port
1474 else:
1475 self.tp_port = 0
1476 return
1477
1478 def pack(self):
1479 packed = []
1480 packed.append(struct.pack("!H", self.type))
1481 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1482 packed.append(struct.pack("!H", self.tp_port))
1483 packed.append('\x00' * 2)
1484 length = sum([len(x) for x in packed])
1485 packed[1] = struct.pack("!H", length)
1486 return ''.join(packed)
1487
1488 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001489 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001490 obj = set_tp_dst()
Dan Talaycof6202252013-07-02 01:00:29 -07001491 _type = reader.read("!H")[0]
1492 assert(_type == 10)
1493 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001494 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001495 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001496 obj.tp_port = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001497 reader.skip(2)
1498 return obj
1499
1500 def __eq__(self, other):
1501 if type(self) != type(other): return False
1502 if self.tp_port != other.tp_port: return False
1503 return True
1504
Rich Lanec2ee4b82013-04-24 17:12:38 -07001505 def pretty_print(self, q):
1506 q.text("set_tp_dst {")
1507 with q.group():
1508 with q.indent(2):
1509 q.breakable()
1510 q.text("tp_port = ");
1511 q.text("%#x" % self.tp_port)
1512 q.breakable()
1513 q.text('}')
1514
Rich Lane7dcdf022013-12-11 14:45:27 -08001515action.subtypes[10] = set_tp_dst
1516
1517class set_tp_src(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001518 type = 9
Rich Lanec2ee4b82013-04-24 17:12:38 -07001519
1520 def __init__(self, tp_port=None):
1521 if tp_port != None:
1522 self.tp_port = tp_port
1523 else:
1524 self.tp_port = 0
1525 return
1526
1527 def pack(self):
1528 packed = []
1529 packed.append(struct.pack("!H", self.type))
1530 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1531 packed.append(struct.pack("!H", self.tp_port))
1532 packed.append('\x00' * 2)
1533 length = sum([len(x) for x in packed])
1534 packed[1] = struct.pack("!H", length)
1535 return ''.join(packed)
1536
1537 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001538 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001539 obj = set_tp_src()
Dan Talaycof6202252013-07-02 01:00:29 -07001540 _type = reader.read("!H")[0]
1541 assert(_type == 9)
1542 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001543 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001544 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001545 obj.tp_port = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001546 reader.skip(2)
1547 return obj
1548
1549 def __eq__(self, other):
1550 if type(self) != type(other): return False
1551 if self.tp_port != other.tp_port: return False
1552 return True
1553
Rich Lanec2ee4b82013-04-24 17:12:38 -07001554 def pretty_print(self, q):
1555 q.text("set_tp_src {")
1556 with q.group():
1557 with q.indent(2):
1558 q.breakable()
1559 q.text("tp_port = ");
1560 q.text("%#x" % self.tp_port)
1561 q.breakable()
1562 q.text('}')
1563
Rich Lane7dcdf022013-12-11 14:45:27 -08001564action.subtypes[9] = set_tp_src
1565
1566class set_vlan_pcp(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001567 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07001568
1569 def __init__(self, vlan_pcp=None):
1570 if vlan_pcp != None:
1571 self.vlan_pcp = vlan_pcp
1572 else:
1573 self.vlan_pcp = 0
1574 return
1575
1576 def pack(self):
1577 packed = []
1578 packed.append(struct.pack("!H", self.type))
1579 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1580 packed.append(struct.pack("!B", self.vlan_pcp))
1581 packed.append('\x00' * 3)
1582 length = sum([len(x) for x in packed])
1583 packed[1] = struct.pack("!H", length)
1584 return ''.join(packed)
1585
1586 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001587 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001588 obj = set_vlan_pcp()
Dan Talaycof6202252013-07-02 01:00:29 -07001589 _type = reader.read("!H")[0]
1590 assert(_type == 2)
1591 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001592 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001593 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001594 obj.vlan_pcp = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001595 reader.skip(3)
1596 return obj
1597
1598 def __eq__(self, other):
1599 if type(self) != type(other): return False
1600 if self.vlan_pcp != other.vlan_pcp: return False
1601 return True
1602
Rich Lanec2ee4b82013-04-24 17:12:38 -07001603 def pretty_print(self, q):
1604 q.text("set_vlan_pcp {")
1605 with q.group():
1606 with q.indent(2):
1607 q.breakable()
1608 q.text("vlan_pcp = ");
1609 q.text("%#x" % self.vlan_pcp)
1610 q.breakable()
1611 q.text('}')
1612
Rich Lane7dcdf022013-12-11 14:45:27 -08001613action.subtypes[2] = set_vlan_pcp
1614
1615class set_vlan_vid(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001616 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07001617
1618 def __init__(self, vlan_vid=None):
1619 if vlan_vid != None:
1620 self.vlan_vid = vlan_vid
1621 else:
1622 self.vlan_vid = 0
1623 return
1624
1625 def pack(self):
1626 packed = []
1627 packed.append(struct.pack("!H", self.type))
1628 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1629 packed.append(struct.pack("!H", self.vlan_vid))
1630 packed.append('\x00' * 2)
1631 length = sum([len(x) for x in packed])
1632 packed[1] = struct.pack("!H", length)
1633 return ''.join(packed)
1634
1635 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001636 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001637 obj = set_vlan_vid()
Dan Talaycof6202252013-07-02 01:00:29 -07001638 _type = reader.read("!H")[0]
1639 assert(_type == 1)
1640 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001641 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001642 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001643 obj.vlan_vid = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001644 reader.skip(2)
1645 return obj
1646
1647 def __eq__(self, other):
1648 if type(self) != type(other): return False
1649 if self.vlan_vid != other.vlan_vid: return False
1650 return True
1651
Rich Lanec2ee4b82013-04-24 17:12:38 -07001652 def pretty_print(self, q):
1653 q.text("set_vlan_vid {")
1654 with q.group():
1655 with q.indent(2):
1656 q.breakable()
1657 q.text("vlan_vid = ");
1658 q.text("%#x" % self.vlan_vid)
1659 q.breakable()
1660 q.text('}')
1661
Rich Lane7dcdf022013-12-11 14:45:27 -08001662action.subtypes[1] = set_vlan_vid
Rich Lanec2ee4b82013-04-24 17:12:38 -07001663
Rich Lanec2ee4b82013-04-24 17:12:38 -07001664