blob: c9f479be4fd5200e244cdf031d0cca28fe390e7f [file] [log] [blame]
Matteo Scandoloa229eca2017-08-08 13:05:28 -07001
2# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
Rich Lanec2ee4b82013-04-24 17:12:38 -070017# Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
18# Copyright (c) 2011, 2012 Open Networking Foundation
19# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
Dan Talaycof6202252013-07-02 01:00:29 -070020# See the file LICENSE.pyloxi which should have been included in the source distribution
Rich Laneb658ddd2013-03-12 10:15:10 -070021
Rich Lane7dcdf022013-12-11 14:45:27 -080022# Automatically generated by LOXI from template module.py
Rich Laneb658ddd2013-03-12 10:15:10 -070023# Do not modify
24
25import struct
Rich Lane7dcdf022013-12-11 14:45:27 -080026import loxi
Rich Laneb658ddd2013-03-12 10:15:10 -070027import util
Rich Lanec2ee4b82013-04-24 17:12:38 -070028import loxi.generic_util
Rich Laneb658ddd2013-03-12 10:15:10 -070029
Rich Lanee2567702015-01-26 15:04:35 -080030import sys
31ofp = sys.modules['loxi.of10']
32
Rich Lane7dcdf022013-12-11 14:45:27 -080033class action(loxi.OFObject):
34 subtypes = {}
Rich Laneb658ddd2013-03-12 10:15:10 -070035
Rich Lane95f7fc92014-01-27 17:08:16 -080036
37 def __init__(self, type=None):
38 if type != None:
39 self.type = type
40 else:
41 self.type = 0
42 return
43
44 def pack(self):
45 packed = []
46 packed.append(struct.pack("!H", self.type))
47 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
48 packed.append('\x00' * 4)
49 length = sum([len(x) for x in packed])
50 packed[1] = struct.pack("!H", length)
51 return ''.join(packed)
52
Rich Lane7dcdf022013-12-11 14:45:27 -080053 @staticmethod
54 def unpack(reader):
55 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -080056 subclass = action.subtypes.get(subtype)
57 if subclass:
58 return subclass.unpack(reader)
59
60 obj = action()
61 obj.type = reader.read("!H")[0]
62 _len = reader.read("!H")[0]
63 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -080064 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -080065 reader.skip(4)
66 return obj
67
68 def __eq__(self, other):
69 if type(self) != type(other): return False
70 if self.type != other.type: return False
71 return True
72
73 def pretty_print(self, q):
74 q.text("action {")
75 with q.group():
76 with q.indent(2):
77 q.breakable()
78 q.breakable()
79 q.text('}')
Rich Laneb658ddd2013-03-12 10:15:10 -070080
Rich Lane7dcdf022013-12-11 14:45:27 -080081
82class experimenter(action):
83 subtypes = {}
84
Rich Lane95f7fc92014-01-27 17:08:16 -080085 type = 65535
86
87 def __init__(self, experimenter=None, data=None):
88 if experimenter != None:
89 self.experimenter = experimenter
90 else:
91 self.experimenter = 0
92 if data != None:
93 self.data = data
94 else:
95 self.data = ''
96 return
97
98 def pack(self):
99 packed = []
100 packed.append(struct.pack("!H", self.type))
101 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
102 packed.append(struct.pack("!L", self.experimenter))
103 packed.append(self.data)
104 length = sum([len(x) for x in packed])
105 packed[1] = struct.pack("!H", length)
106 return ''.join(packed)
107
Rich Lane7dcdf022013-12-11 14:45:27 -0800108 @staticmethod
109 def unpack(reader):
110 subtype, = reader.peek('!L', 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800111 subclass = experimenter.subtypes.get(subtype)
112 if subclass:
113 return subclass.unpack(reader)
114
115 obj = experimenter()
116 _type = reader.read("!H")[0]
117 assert(_type == 65535)
118 _len = reader.read("!H")[0]
119 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800120 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800121 obj.experimenter = reader.read("!L")[0]
122 obj.data = str(reader.read_all())
123 return obj
124
125 def __eq__(self, other):
126 if type(self) != type(other): return False
127 if self.experimenter != other.experimenter: return False
128 if self.data != other.data: return False
129 return True
130
131 def pretty_print(self, q):
132 q.text("experimenter {")
133 with q.group():
134 with q.indent(2):
135 q.breakable()
136 q.text("data = ");
137 q.pp(self.data)
138 q.breakable()
139 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800140
141action.subtypes[65535] = experimenter
142
143class bsn(experimenter):
144 subtypes = {}
145
Rich Lane95f7fc92014-01-27 17:08:16 -0800146 type = 65535
147 experimenter = 6035143
148
149 def __init__(self, subtype=None):
150 if subtype != None:
151 self.subtype = subtype
152 else:
153 self.subtype = 0
154 return
155
156 def pack(self):
157 packed = []
158 packed.append(struct.pack("!H", self.type))
159 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
160 packed.append(struct.pack("!L", self.experimenter))
161 packed.append(struct.pack("!L", self.subtype))
162 packed.append('\x00' * 4)
163 length = sum([len(x) for x in packed])
164 packed[1] = struct.pack("!H", length)
165 return ''.join(packed)
166
Rich Lane7dcdf022013-12-11 14:45:27 -0800167 @staticmethod
168 def unpack(reader):
169 subtype, = reader.peek('!L', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800170 subclass = bsn.subtypes.get(subtype)
171 if subclass:
172 return subclass.unpack(reader)
173
174 obj = bsn()
175 _type = reader.read("!H")[0]
176 assert(_type == 65535)
177 _len = reader.read("!H")[0]
178 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800179 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800180 _experimenter = reader.read("!L")[0]
181 assert(_experimenter == 6035143)
182 obj.subtype = reader.read("!L")[0]
183 reader.skip(4)
184 return obj
185
186 def __eq__(self, other):
187 if type(self) != type(other): return False
188 if self.subtype != other.subtype: return False
189 return True
190
191 def pretty_print(self, q):
192 q.text("bsn {")
193 with q.group():
194 with q.indent(2):
195 q.breakable()
196 q.breakable()
197 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800198
199experimenter.subtypes[6035143] = bsn
200
Rich Lane5587ab12014-06-30 11:19:09 -0700201class bsn_checksum(bsn):
202 type = 65535
203 experimenter = 6035143
204 subtype = 4
205
206 def __init__(self, checksum=None):
207 if checksum != None:
208 self.checksum = checksum
209 else:
210 self.checksum = 0
211 return
212
213 def pack(self):
214 packed = []
215 packed.append(struct.pack("!H", self.type))
216 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
217 packed.append(struct.pack("!L", self.experimenter))
218 packed.append(struct.pack("!L", self.subtype))
219 packed.append(util.pack_checksum_128(self.checksum))
220 length = sum([len(x) for x in packed])
221 packed[1] = struct.pack("!H", length)
222 return ''.join(packed)
223
224 @staticmethod
225 def unpack(reader):
226 obj = bsn_checksum()
227 _type = reader.read("!H")[0]
228 assert(_type == 65535)
229 _len = reader.read("!H")[0]
230 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800231 reader = orig_reader.slice(_len, 4)
Rich Lane5587ab12014-06-30 11:19:09 -0700232 _experimenter = reader.read("!L")[0]
233 assert(_experimenter == 6035143)
234 _subtype = reader.read("!L")[0]
235 assert(_subtype == 4)
236 obj.checksum = util.unpack_checksum_128(reader)
237 return obj
238
239 def __eq__(self, other):
240 if type(self) != type(other): return False
241 if self.checksum != other.checksum: return False
242 return True
243
244 def pretty_print(self, q):
245 q.text("bsn_checksum {")
246 with q.group():
247 with q.indent(2):
248 q.breakable()
249 q.text("checksum = ");
250 q.pp(self.checksum)
251 q.breakable()
252 q.text('}')
253
254bsn.subtypes[4] = bsn_checksum
255
Rich Lane7dcdf022013-12-11 14:45:27 -0800256class bsn_mirror(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700257 type = 65535
258 experimenter = 6035143
Rich Laneb658ddd2013-03-12 10:15:10 -0700259 subtype = 1
260
Rich Lanec2ee4b82013-04-24 17:12:38 -0700261 def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700262 if dest_port != None:
263 self.dest_port = dest_port
264 else:
265 self.dest_port = 0
266 if vlan_tag != None:
267 self.vlan_tag = vlan_tag
268 else:
269 self.vlan_tag = 0
270 if copy_stage != None:
271 self.copy_stage = copy_stage
272 else:
273 self.copy_stage = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700274 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700275
276 def pack(self):
277 packed = []
278 packed.append(struct.pack("!H", self.type))
279 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
280 packed.append(struct.pack("!L", self.experimenter))
281 packed.append(struct.pack("!L", self.subtype))
282 packed.append(struct.pack("!L", self.dest_port))
283 packed.append(struct.pack("!L", self.vlan_tag))
284 packed.append(struct.pack("!B", self.copy_stage))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700285 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700286 length = sum([len(x) for x in packed])
287 packed[1] = struct.pack("!H", length)
288 return ''.join(packed)
289
290 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800291 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700292 obj = bsn_mirror()
Dan Talaycof6202252013-07-02 01:00:29 -0700293 _type = reader.read("!H")[0]
294 assert(_type == 65535)
295 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800296 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800297 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700298 _experimenter = reader.read("!L")[0]
299 assert(_experimenter == 6035143)
300 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700301 assert(_subtype == 1)
Dan Talaycof6202252013-07-02 01:00:29 -0700302 obj.dest_port = reader.read("!L")[0]
303 obj.vlan_tag = reader.read("!L")[0]
304 obj.copy_stage = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700305 reader.skip(3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700306 return obj
307
308 def __eq__(self, other):
309 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700310 if self.dest_port != other.dest_port: return False
311 if self.vlan_tag != other.vlan_tag: return False
312 if self.copy_stage != other.copy_stage: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700313 return True
314
Rich Laneb658ddd2013-03-12 10:15:10 -0700315 def pretty_print(self, q):
316 q.text("bsn_mirror {")
317 with q.group():
318 with q.indent(2):
319 q.breakable()
320 q.text("dest_port = ");
321 q.text("%#x" % self.dest_port)
322 q.text(","); q.breakable()
323 q.text("vlan_tag = ");
324 q.text("%#x" % self.vlan_tag)
325 q.text(","); q.breakable()
326 q.text("copy_stage = ");
327 q.text("%#x" % self.copy_stage)
Rich Laneb658ddd2013-03-12 10:15:10 -0700328 q.breakable()
329 q.text('}')
330
Rich Lane7dcdf022013-12-11 14:45:27 -0800331bsn.subtypes[1] = bsn_mirror
332
333class bsn_set_tunnel_dst(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700334 type = 65535
335 experimenter = 6035143
Rich Laneb658ddd2013-03-12 10:15:10 -0700336 subtype = 2
337
338 def __init__(self, dst=None):
339 if dst != None:
340 self.dst = dst
341 else:
342 self.dst = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700343 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700344
345 def pack(self):
346 packed = []
347 packed.append(struct.pack("!H", self.type))
348 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
349 packed.append(struct.pack("!L", self.experimenter))
350 packed.append(struct.pack("!L", self.subtype))
351 packed.append(struct.pack("!L", self.dst))
352 length = sum([len(x) for x in packed])
353 packed[1] = struct.pack("!H", length)
354 return ''.join(packed)
355
356 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800357 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700358 obj = bsn_set_tunnel_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700359 _type = reader.read("!H")[0]
360 assert(_type == 65535)
361 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800362 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800363 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700364 _experimenter = reader.read("!L")[0]
365 assert(_experimenter == 6035143)
366 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700367 assert(_subtype == 2)
Dan Talaycof6202252013-07-02 01:00:29 -0700368 obj.dst = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -0700369 return obj
370
371 def __eq__(self, other):
372 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700373 if self.dst != other.dst: return False
374 return True
375
Rich Laneb658ddd2013-03-12 10:15:10 -0700376 def pretty_print(self, q):
377 q.text("bsn_set_tunnel_dst {")
378 with q.group():
379 with q.indent(2):
380 q.breakable()
381 q.text("dst = ");
382 q.text("%#x" % self.dst)
383 q.breakable()
384 q.text('}')
385
Rich Lane7dcdf022013-12-11 14:45:27 -0800386bsn.subtypes[2] = bsn_set_tunnel_dst
387
388class enqueue(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700389 type = 11
Rich Laneb658ddd2013-03-12 10:15:10 -0700390
Rich Lanec2ee4b82013-04-24 17:12:38 -0700391 def __init__(self, port=None, queue_id=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700392 if port != None:
393 self.port = port
394 else:
395 self.port = 0
Rich Laneb658ddd2013-03-12 10:15:10 -0700396 if queue_id != None:
397 self.queue_id = queue_id
398 else:
399 self.queue_id = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700400 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700401
402 def pack(self):
403 packed = []
404 packed.append(struct.pack("!H", self.type))
405 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700406 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700407 packed.append('\x00' * 6)
Rich Laneb658ddd2013-03-12 10:15:10 -0700408 packed.append(struct.pack("!L", self.queue_id))
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 Laneb658ddd2013-03-12 10:15:10 -0700415 obj = enqueue()
Dan Talaycof6202252013-07-02 01:00:29 -0700416 _type = reader.read("!H")[0]
417 assert(_type == 11)
418 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800419 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800420 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700421 obj.port = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700422 reader.skip(6)
Dan Talaycof6202252013-07-02 01:00:29 -0700423 obj.queue_id = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -0700424 return obj
425
426 def __eq__(self, other):
427 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700428 if self.port != other.port: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700429 if self.queue_id != other.queue_id: return False
430 return True
431
Rich Laneb658ddd2013-03-12 10:15:10 -0700432 def pretty_print(self, q):
433 q.text("enqueue {")
434 with q.group():
435 with q.indent(2):
436 q.breakable()
437 q.text("port = ");
438 q.text(util.pretty_port(self.port))
439 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -0700440 q.text("queue_id = ");
441 q.text("%#x" % self.queue_id)
442 q.breakable()
443 q.text('}')
444
Rich Lane7dcdf022013-12-11 14:45:27 -0800445action.subtypes[11] = enqueue
446
447class nicira(experimenter):
448 subtypes = {}
449
Rich Lane95f7fc92014-01-27 17:08:16 -0800450 type = 65535
451 experimenter = 8992
452
453 def __init__(self, subtype=None):
454 if subtype != None:
455 self.subtype = subtype
456 else:
457 self.subtype = 0
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(struct.pack("!L", self.experimenter))
465 packed.append(struct.pack("!H", self.subtype))
466 packed.append('\x00' * 2)
467 packed.append('\x00' * 4)
468 length = sum([len(x) for x in packed])
469 packed[1] = struct.pack("!H", length)
470 return ''.join(packed)
471
Rich Lane7dcdf022013-12-11 14:45:27 -0800472 @staticmethod
473 def unpack(reader):
474 subtype, = reader.peek('!H', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800475 subclass = nicira.subtypes.get(subtype)
476 if subclass:
477 return subclass.unpack(reader)
478
479 obj = nicira()
480 _type = reader.read("!H")[0]
481 assert(_type == 65535)
482 _len = reader.read("!H")[0]
483 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800484 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800485 _experimenter = reader.read("!L")[0]
486 assert(_experimenter == 8992)
487 obj.subtype = reader.read("!H")[0]
488 reader.skip(2)
489 reader.skip(4)
490 return obj
491
492 def __eq__(self, other):
493 if type(self) != type(other): return False
494 if self.subtype != other.subtype: return False
495 return True
496
497 def pretty_print(self, q):
498 q.text("nicira {")
499 with q.group():
500 with q.indent(2):
501 q.breakable()
502 q.breakable()
503 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800504
505experimenter.subtypes[8992] = nicira
506
507class nicira_dec_ttl(nicira):
Dan Talaycof6202252013-07-02 01:00:29 -0700508 type = 65535
509 experimenter = 8992
Rich Laneb658ddd2013-03-12 10:15:10 -0700510 subtype = 18
511
Rich Lanec2ee4b82013-04-24 17:12:38 -0700512 def __init__(self):
513 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700514
515 def pack(self):
516 packed = []
517 packed.append(struct.pack("!H", self.type))
518 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
519 packed.append(struct.pack("!L", self.experimenter))
520 packed.append(struct.pack("!H", self.subtype))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700521 packed.append('\x00' * 2)
522 packed.append('\x00' * 4)
Rich Laneb658ddd2013-03-12 10:15:10 -0700523 length = sum([len(x) for x in packed])
524 packed[1] = struct.pack("!H", length)
525 return ''.join(packed)
526
527 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800528 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700529 obj = nicira_dec_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700530 _type = reader.read("!H")[0]
531 assert(_type == 65535)
532 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800533 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800534 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700535 _experimenter = reader.read("!L")[0]
536 assert(_experimenter == 8992)
537 _subtype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700538 assert(_subtype == 18)
539 reader.skip(2)
540 reader.skip(4)
Rich Laneb658ddd2013-03-12 10:15:10 -0700541 return obj
542
543 def __eq__(self, other):
544 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700545 return True
546
Rich Laneb658ddd2013-03-12 10:15:10 -0700547 def pretty_print(self, q):
548 q.text("nicira_dec_ttl {")
549 with q.group():
550 with q.indent(2):
551 q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -0700552 q.breakable()
553 q.text('}')
554
Rich Lane7dcdf022013-12-11 14:45:27 -0800555nicira.subtypes[18] = nicira_dec_ttl
556
557class output(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700558 type = 0
Rich Laneb658ddd2013-03-12 10:15:10 -0700559
560 def __init__(self, port=None, max_len=None):
561 if port != None:
562 self.port = port
563 else:
564 self.port = 0
565 if max_len != None:
566 self.max_len = max_len
567 else:
568 self.max_len = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700569 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700570
571 def pack(self):
572 packed = []
573 packed.append(struct.pack("!H", self.type))
574 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700575 packed.append(util.pack_port_no(self.port))
Rich Laneb658ddd2013-03-12 10:15:10 -0700576 packed.append(struct.pack("!H", self.max_len))
577 length = sum([len(x) for x in packed])
578 packed[1] = struct.pack("!H", length)
579 return ''.join(packed)
580
581 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800582 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700583 obj = output()
Dan Talaycof6202252013-07-02 01:00:29 -0700584 _type = reader.read("!H")[0]
585 assert(_type == 0)
586 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800587 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800588 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700589 obj.port = util.unpack_port_no(reader)
590 obj.max_len = reader.read("!H")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -0700591 return obj
592
593 def __eq__(self, other):
594 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700595 if self.port != other.port: return False
596 if self.max_len != other.max_len: return False
597 return True
598
Rich Laneb658ddd2013-03-12 10:15:10 -0700599 def pretty_print(self, q):
600 q.text("output {")
601 with q.group():
602 with q.indent(2):
603 q.breakable()
604 q.text("port = ");
605 q.text(util.pretty_port(self.port))
606 q.text(","); q.breakable()
607 q.text("max_len = ");
608 q.text("%#x" % self.max_len)
609 q.breakable()
610 q.text('}')
611
Rich Lane7dcdf022013-12-11 14:45:27 -0800612action.subtypes[0] = output
613
614class set_dl_dst(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700615 type = 5
Rich Laneb658ddd2013-03-12 10:15:10 -0700616
Rich Lanec2ee4b82013-04-24 17:12:38 -0700617 def __init__(self, dl_addr=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700618 if dl_addr != None:
619 self.dl_addr = dl_addr
620 else:
621 self.dl_addr = [0,0,0,0,0,0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700622 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700623
624 def pack(self):
625 packed = []
626 packed.append(struct.pack("!H", self.type))
627 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
628 packed.append(struct.pack("!6B", *self.dl_addr))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700629 packed.append('\x00' * 6)
Rich Laneb658ddd2013-03-12 10:15:10 -0700630 length = sum([len(x) for x in packed])
631 packed[1] = struct.pack("!H", length)
632 return ''.join(packed)
633
634 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800635 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700636 obj = set_dl_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700637 _type = reader.read("!H")[0]
638 assert(_type == 5)
639 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800640 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800641 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700642 obj.dl_addr = list(reader.read('!6B'))
643 reader.skip(6)
Rich Laneb658ddd2013-03-12 10:15:10 -0700644 return obj
645
646 def __eq__(self, other):
647 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700648 if self.dl_addr != other.dl_addr: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700649 return True
650
Rich Laneb658ddd2013-03-12 10:15:10 -0700651 def pretty_print(self, q):
652 q.text("set_dl_dst {")
653 with q.group():
654 with q.indent(2):
655 q.breakable()
656 q.text("dl_addr = ");
657 q.text(util.pretty_mac(self.dl_addr))
Rich Laneb658ddd2013-03-12 10:15:10 -0700658 q.breakable()
659 q.text('}')
660
Rich Lane7dcdf022013-12-11 14:45:27 -0800661action.subtypes[5] = set_dl_dst
662
663class set_dl_src(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700664 type = 4
Rich Laneb658ddd2013-03-12 10:15:10 -0700665
Rich Lanec2ee4b82013-04-24 17:12:38 -0700666 def __init__(self, dl_addr=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700667 if dl_addr != None:
668 self.dl_addr = dl_addr
669 else:
670 self.dl_addr = [0,0,0,0,0,0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700671 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700672
673 def pack(self):
674 packed = []
675 packed.append(struct.pack("!H", self.type))
676 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
677 packed.append(struct.pack("!6B", *self.dl_addr))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700678 packed.append('\x00' * 6)
Rich Laneb658ddd2013-03-12 10:15:10 -0700679 length = sum([len(x) for x in packed])
680 packed[1] = struct.pack("!H", length)
681 return ''.join(packed)
682
683 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800684 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700685 obj = set_dl_src()
Dan Talaycof6202252013-07-02 01:00:29 -0700686 _type = reader.read("!H")[0]
687 assert(_type == 4)
688 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800689 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800690 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700691 obj.dl_addr = list(reader.read('!6B'))
692 reader.skip(6)
Rich Laneb658ddd2013-03-12 10:15:10 -0700693 return obj
694
695 def __eq__(self, other):
696 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700697 if self.dl_addr != other.dl_addr: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700698 return True
699
Rich Laneb658ddd2013-03-12 10:15:10 -0700700 def pretty_print(self, q):
701 q.text("set_dl_src {")
702 with q.group():
703 with q.indent(2):
704 q.breakable()
705 q.text("dl_addr = ");
706 q.text(util.pretty_mac(self.dl_addr))
Rich Laneb658ddd2013-03-12 10:15:10 -0700707 q.breakable()
708 q.text('}')
709
Rich Lane7dcdf022013-12-11 14:45:27 -0800710action.subtypes[4] = set_dl_src
711
712class set_nw_dst(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700713 type = 7
Rich Laneb658ddd2013-03-12 10:15:10 -0700714
715 def __init__(self, nw_addr=None):
716 if nw_addr != None:
717 self.nw_addr = nw_addr
718 else:
719 self.nw_addr = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700720 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700721
722 def pack(self):
723 packed = []
724 packed.append(struct.pack("!H", self.type))
725 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
726 packed.append(struct.pack("!L", self.nw_addr))
727 length = sum([len(x) for x in packed])
728 packed[1] = struct.pack("!H", length)
729 return ''.join(packed)
730
731 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800732 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700733 obj = set_nw_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700734 _type = reader.read("!H")[0]
735 assert(_type == 7)
736 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800737 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800738 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700739 obj.nw_addr = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -0700740 return obj
741
742 def __eq__(self, other):
743 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700744 if self.nw_addr != other.nw_addr: return False
745 return True
746
Rich Laneb658ddd2013-03-12 10:15:10 -0700747 def pretty_print(self, q):
748 q.text("set_nw_dst {")
749 with q.group():
750 with q.indent(2):
751 q.breakable()
752 q.text("nw_addr = ");
753 q.text("%#x" % self.nw_addr)
754 q.breakable()
755 q.text('}')
756
Rich Lane7dcdf022013-12-11 14:45:27 -0800757action.subtypes[7] = set_nw_dst
758
759class set_nw_src(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700760 type = 6
Rich Laneb658ddd2013-03-12 10:15:10 -0700761
762 def __init__(self, nw_addr=None):
763 if nw_addr != None:
764 self.nw_addr = nw_addr
765 else:
766 self.nw_addr = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700767 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700768
769 def pack(self):
770 packed = []
771 packed.append(struct.pack("!H", self.type))
772 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
773 packed.append(struct.pack("!L", self.nw_addr))
774 length = sum([len(x) for x in packed])
775 packed[1] = struct.pack("!H", length)
776 return ''.join(packed)
777
778 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800779 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700780 obj = set_nw_src()
Dan Talaycof6202252013-07-02 01:00:29 -0700781 _type = reader.read("!H")[0]
782 assert(_type == 6)
783 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800784 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800785 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700786 obj.nw_addr = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -0700787 return obj
788
789 def __eq__(self, other):
790 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700791 if self.nw_addr != other.nw_addr: return False
792 return True
793
Rich Laneb658ddd2013-03-12 10:15:10 -0700794 def pretty_print(self, q):
795 q.text("set_nw_src {")
796 with q.group():
797 with q.indent(2):
798 q.breakable()
799 q.text("nw_addr = ");
800 q.text("%#x" % self.nw_addr)
801 q.breakable()
802 q.text('}')
803
Rich Lane7dcdf022013-12-11 14:45:27 -0800804action.subtypes[6] = set_nw_src
805
806class set_nw_tos(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700807 type = 8
Rich Laneb658ddd2013-03-12 10:15:10 -0700808
Rich Lanec2ee4b82013-04-24 17:12:38 -0700809 def __init__(self, nw_tos=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700810 if nw_tos != None:
811 self.nw_tos = nw_tos
812 else:
813 self.nw_tos = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700814 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700815
816 def pack(self):
817 packed = []
818 packed.append(struct.pack("!H", self.type))
819 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
820 packed.append(struct.pack("!B", self.nw_tos))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700821 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700822 length = sum([len(x) for x in packed])
823 packed[1] = struct.pack("!H", length)
824 return ''.join(packed)
825
826 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800827 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700828 obj = set_nw_tos()
Dan Talaycof6202252013-07-02 01:00:29 -0700829 _type = reader.read("!H")[0]
830 assert(_type == 8)
831 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800832 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800833 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700834 obj.nw_tos = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700835 reader.skip(3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700836 return obj
837
838 def __eq__(self, other):
839 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700840 if self.nw_tos != other.nw_tos: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700841 return True
842
Rich Laneb658ddd2013-03-12 10:15:10 -0700843 def pretty_print(self, q):
844 q.text("set_nw_tos {")
845 with q.group():
846 with q.indent(2):
847 q.breakable()
848 q.text("nw_tos = ");
849 q.text("%#x" % self.nw_tos)
Rich Laneb658ddd2013-03-12 10:15:10 -0700850 q.breakable()
851 q.text('}')
852
Rich Lane7dcdf022013-12-11 14:45:27 -0800853action.subtypes[8] = set_nw_tos
854
855class set_tp_dst(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700856 type = 10
Rich Laneb658ddd2013-03-12 10:15:10 -0700857
Rich Lanec2ee4b82013-04-24 17:12:38 -0700858 def __init__(self, tp_port=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700859 if tp_port != None:
860 self.tp_port = tp_port
861 else:
862 self.tp_port = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700863 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700864
865 def pack(self):
866 packed = []
867 packed.append(struct.pack("!H", self.type))
868 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
869 packed.append(struct.pack("!H", self.tp_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700870 packed.append('\x00' * 2)
Rich Laneb658ddd2013-03-12 10:15:10 -0700871 length = sum([len(x) for x in packed])
872 packed[1] = struct.pack("!H", length)
873 return ''.join(packed)
874
875 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800876 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700877 obj = set_tp_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700878 _type = reader.read("!H")[0]
879 assert(_type == 10)
880 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800881 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800882 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700883 obj.tp_port = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700884 reader.skip(2)
Rich Laneb658ddd2013-03-12 10:15:10 -0700885 return obj
886
887 def __eq__(self, other):
888 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700889 if self.tp_port != other.tp_port: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700890 return True
891
Rich Laneb658ddd2013-03-12 10:15:10 -0700892 def pretty_print(self, q):
893 q.text("set_tp_dst {")
894 with q.group():
895 with q.indent(2):
896 q.breakable()
897 q.text("tp_port = ");
898 q.text("%#x" % self.tp_port)
Rich Laneb658ddd2013-03-12 10:15:10 -0700899 q.breakable()
900 q.text('}')
901
Rich Lane7dcdf022013-12-11 14:45:27 -0800902action.subtypes[10] = set_tp_dst
903
904class set_tp_src(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700905 type = 9
Rich Laneb658ddd2013-03-12 10:15:10 -0700906
Rich Lanec2ee4b82013-04-24 17:12:38 -0700907 def __init__(self, tp_port=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700908 if tp_port != None:
909 self.tp_port = tp_port
910 else:
911 self.tp_port = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700912 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700913
914 def pack(self):
915 packed = []
916 packed.append(struct.pack("!H", self.type))
917 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
918 packed.append(struct.pack("!H", self.tp_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700919 packed.append('\x00' * 2)
Rich Laneb658ddd2013-03-12 10:15:10 -0700920 length = sum([len(x) for x in packed])
921 packed[1] = struct.pack("!H", length)
922 return ''.join(packed)
923
924 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800925 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700926 obj = set_tp_src()
Dan Talaycof6202252013-07-02 01:00:29 -0700927 _type = reader.read("!H")[0]
928 assert(_type == 9)
929 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800930 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800931 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700932 obj.tp_port = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700933 reader.skip(2)
Rich Laneb658ddd2013-03-12 10:15:10 -0700934 return obj
935
936 def __eq__(self, other):
937 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700938 if self.tp_port != other.tp_port: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700939 return True
940
Rich Laneb658ddd2013-03-12 10:15:10 -0700941 def pretty_print(self, q):
942 q.text("set_tp_src {")
943 with q.group():
944 with q.indent(2):
945 q.breakable()
946 q.text("tp_port = ");
947 q.text("%#x" % self.tp_port)
Rich Laneb658ddd2013-03-12 10:15:10 -0700948 q.breakable()
949 q.text('}')
950
Rich Lane7dcdf022013-12-11 14:45:27 -0800951action.subtypes[9] = set_tp_src
952
953class set_vlan_pcp(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700954 type = 2
Rich Laneb658ddd2013-03-12 10:15:10 -0700955
Rich Lanec2ee4b82013-04-24 17:12:38 -0700956 def __init__(self, vlan_pcp=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700957 if vlan_pcp != None:
958 self.vlan_pcp = vlan_pcp
959 else:
960 self.vlan_pcp = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700961 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700962
963 def pack(self):
964 packed = []
965 packed.append(struct.pack("!H", self.type))
966 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
967 packed.append(struct.pack("!B", self.vlan_pcp))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700968 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700969 length = sum([len(x) for x in packed])
970 packed[1] = struct.pack("!H", length)
971 return ''.join(packed)
972
973 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800974 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700975 obj = set_vlan_pcp()
Dan Talaycof6202252013-07-02 01:00:29 -0700976 _type = reader.read("!H")[0]
977 assert(_type == 2)
978 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800979 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800980 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700981 obj.vlan_pcp = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700982 reader.skip(3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700983 return obj
984
985 def __eq__(self, other):
986 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700987 if self.vlan_pcp != other.vlan_pcp: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700988 return True
989
Rich Laneb658ddd2013-03-12 10:15:10 -0700990 def pretty_print(self, q):
991 q.text("set_vlan_pcp {")
992 with q.group():
993 with q.indent(2):
994 q.breakable()
995 q.text("vlan_pcp = ");
996 q.text("%#x" % self.vlan_pcp)
Rich Laneb658ddd2013-03-12 10:15:10 -0700997 q.breakable()
998 q.text('}')
999
Rich Lane7dcdf022013-12-11 14:45:27 -08001000action.subtypes[2] = set_vlan_pcp
1001
1002class set_vlan_vid(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001003 type = 1
Rich Laneb658ddd2013-03-12 10:15:10 -07001004
Rich Lanec2ee4b82013-04-24 17:12:38 -07001005 def __init__(self, vlan_vid=None):
Rich Laneb658ddd2013-03-12 10:15:10 -07001006 if vlan_vid != None:
1007 self.vlan_vid = vlan_vid
1008 else:
1009 self.vlan_vid = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -07001010 return
Rich Laneb658ddd2013-03-12 10:15:10 -07001011
1012 def pack(self):
1013 packed = []
1014 packed.append(struct.pack("!H", self.type))
1015 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1016 packed.append(struct.pack("!H", self.vlan_vid))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001017 packed.append('\x00' * 2)
Rich Laneb658ddd2013-03-12 10:15:10 -07001018 length = sum([len(x) for x in packed])
1019 packed[1] = struct.pack("!H", length)
1020 return ''.join(packed)
1021
1022 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001023 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -07001024 obj = set_vlan_vid()
Dan Talaycof6202252013-07-02 01:00:29 -07001025 _type = reader.read("!H")[0]
1026 assert(_type == 1)
1027 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001028 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001029 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -07001030 obj.vlan_vid = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001031 reader.skip(2)
Rich Laneb658ddd2013-03-12 10:15:10 -07001032 return obj
1033
1034 def __eq__(self, other):
1035 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -07001036 if self.vlan_vid != other.vlan_vid: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07001037 return True
1038
Rich Laneb658ddd2013-03-12 10:15:10 -07001039 def pretty_print(self, q):
1040 q.text("set_vlan_vid {")
1041 with q.group():
1042 with q.indent(2):
1043 q.breakable()
1044 q.text("vlan_vid = ");
1045 q.text("%#x" % self.vlan_vid)
Rich Laneb658ddd2013-03-12 10:15:10 -07001046 q.breakable()
1047 q.text('}')
1048
Rich Lane7dcdf022013-12-11 14:45:27 -08001049action.subtypes[1] = set_vlan_vid
1050
1051class strip_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001052 type = 3
Rich Laneb658ddd2013-03-12 10:15:10 -07001053
Rich Lanec2ee4b82013-04-24 17:12:38 -07001054 def __init__(self):
1055 return
Rich Laneb658ddd2013-03-12 10:15:10 -07001056
1057 def pack(self):
1058 packed = []
1059 packed.append(struct.pack("!H", self.type))
1060 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07001061 packed.append('\x00' * 4)
Rich Laneb658ddd2013-03-12 10:15:10 -07001062 length = sum([len(x) for x in packed])
1063 packed[1] = struct.pack("!H", length)
1064 return ''.join(packed)
1065
1066 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001067 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -07001068 obj = strip_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -07001069 _type = reader.read("!H")[0]
1070 assert(_type == 3)
1071 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001072 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001073 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001074 reader.skip(4)
Rich Laneb658ddd2013-03-12 10:15:10 -07001075 return obj
1076
1077 def __eq__(self, other):
1078 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -07001079 return True
1080
Rich Laneb658ddd2013-03-12 10:15:10 -07001081 def pretty_print(self, q):
1082 q.text("strip_vlan {")
1083 with q.group():
1084 with q.indent(2):
1085 q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07001086 q.breakable()
1087 q.text('}')
1088
Rich Lane7dcdf022013-12-11 14:45:27 -08001089action.subtypes[3] = strip_vlan
Rich Laneb658ddd2013-03-12 10:15:10 -07001090
Rich Laneb658ddd2013-03-12 10:15:10 -07001091