blob: e2cf539d7373639c6339fecddc35bc8c5b649742 [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 Laneb658ddd2013-03-12 10:15:10 -07005
Rich Lane7dcdf022013-12-11 14:45:27 -08006# Automatically generated by LOXI from template module.py
Rich Laneb658ddd2013-03-12 10:15:10 -07007# Do not modify
8
9import struct
Rich Lane7dcdf022013-12-11 14:45:27 -080010import loxi
Rich Laneb658ddd2013-03-12 10:15:10 -070011import const
Rich Lane7dcdf022013-12-11 14:45:27 -080012import action
Harshmeet Singh1db46332014-10-14 16:29:13 -070013import message
14import common
Rich Laneb658ddd2013-03-12 10:15:10 -070015import util
Rich Lanec2ee4b82013-04-24 17:12:38 -070016import loxi.generic_util
Rich Laneb658ddd2013-03-12 10:15:10 -070017
Rich Lane7dcdf022013-12-11 14:45:27 -080018class action(loxi.OFObject):
19 subtypes = {}
Rich Laneb658ddd2013-03-12 10:15:10 -070020
Rich Lane95f7fc92014-01-27 17:08:16 -080021
22 def __init__(self, type=None):
23 if type != None:
24 self.type = type
25 else:
26 self.type = 0
27 return
28
29 def pack(self):
30 packed = []
31 packed.append(struct.pack("!H", self.type))
32 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
33 packed.append('\x00' * 4)
34 length = sum([len(x) for x in packed])
35 packed[1] = struct.pack("!H", length)
36 return ''.join(packed)
37
Rich Lane7dcdf022013-12-11 14:45:27 -080038 @staticmethod
39 def unpack(reader):
40 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -080041 subclass = action.subtypes.get(subtype)
42 if subclass:
43 return subclass.unpack(reader)
44
45 obj = action()
46 obj.type = reader.read("!H")[0]
47 _len = reader.read("!H")[0]
48 orig_reader = reader
49 reader = orig_reader.slice(_len - (2 + 2))
50 reader.skip(4)
51 return obj
52
53 def __eq__(self, other):
54 if type(self) != type(other): return False
55 if self.type != other.type: return False
56 return True
57
58 def pretty_print(self, q):
59 q.text("action {")
60 with q.group():
61 with q.indent(2):
62 q.breakable()
63 q.breakable()
64 q.text('}')
Rich Laneb658ddd2013-03-12 10:15:10 -070065
Rich Lane7dcdf022013-12-11 14:45:27 -080066
67class experimenter(action):
68 subtypes = {}
69
Rich Lane95f7fc92014-01-27 17:08:16 -080070 type = 65535
71
72 def __init__(self, experimenter=None, data=None):
73 if experimenter != None:
74 self.experimenter = experimenter
75 else:
76 self.experimenter = 0
77 if data != None:
78 self.data = data
79 else:
80 self.data = ''
81 return
82
83 def pack(self):
84 packed = []
85 packed.append(struct.pack("!H", self.type))
86 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
87 packed.append(struct.pack("!L", self.experimenter))
88 packed.append(self.data)
89 length = sum([len(x) for x in packed])
90 packed[1] = struct.pack("!H", length)
91 return ''.join(packed)
92
Rich Lane7dcdf022013-12-11 14:45:27 -080093 @staticmethod
94 def unpack(reader):
95 subtype, = reader.peek('!L', 4)
Rich Lane95f7fc92014-01-27 17:08:16 -080096 subclass = experimenter.subtypes.get(subtype)
97 if subclass:
98 return subclass.unpack(reader)
99
100 obj = experimenter()
101 _type = reader.read("!H")[0]
102 assert(_type == 65535)
103 _len = reader.read("!H")[0]
104 orig_reader = reader
105 reader = orig_reader.slice(_len - (2 + 2))
106 obj.experimenter = reader.read("!L")[0]
107 obj.data = str(reader.read_all())
108 return obj
109
110 def __eq__(self, other):
111 if type(self) != type(other): return False
112 if self.experimenter != other.experimenter: return False
113 if self.data != other.data: return False
114 return True
115
116 def pretty_print(self, q):
117 q.text("experimenter {")
118 with q.group():
119 with q.indent(2):
120 q.breakable()
121 q.text("data = ");
122 q.pp(self.data)
123 q.breakable()
124 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800125
126action.subtypes[65535] = experimenter
127
128class bsn(experimenter):
129 subtypes = {}
130
Rich Lane95f7fc92014-01-27 17:08:16 -0800131 type = 65535
132 experimenter = 6035143
133
134 def __init__(self, subtype=None):
135 if subtype != None:
136 self.subtype = subtype
137 else:
138 self.subtype = 0
139 return
140
141 def pack(self):
142 packed = []
143 packed.append(struct.pack("!H", self.type))
144 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
145 packed.append(struct.pack("!L", self.experimenter))
146 packed.append(struct.pack("!L", self.subtype))
147 packed.append('\x00' * 4)
148 length = sum([len(x) for x in packed])
149 packed[1] = struct.pack("!H", length)
150 return ''.join(packed)
151
Rich Lane7dcdf022013-12-11 14:45:27 -0800152 @staticmethod
153 def unpack(reader):
154 subtype, = reader.peek('!L', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800155 subclass = bsn.subtypes.get(subtype)
156 if subclass:
157 return subclass.unpack(reader)
158
159 obj = bsn()
160 _type = reader.read("!H")[0]
161 assert(_type == 65535)
162 _len = reader.read("!H")[0]
163 orig_reader = reader
164 reader = orig_reader.slice(_len - (2 + 2))
165 _experimenter = reader.read("!L")[0]
166 assert(_experimenter == 6035143)
167 obj.subtype = reader.read("!L")[0]
168 reader.skip(4)
169 return obj
170
171 def __eq__(self, other):
172 if type(self) != type(other): return False
173 if self.subtype != other.subtype: return False
174 return True
175
176 def pretty_print(self, q):
177 q.text("bsn {")
178 with q.group():
179 with q.indent(2):
180 q.breakable()
181 q.breakable()
182 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800183
184experimenter.subtypes[6035143] = bsn
185
Rich Lane5587ab12014-06-30 11:19:09 -0700186class bsn_checksum(bsn):
187 type = 65535
188 experimenter = 6035143
189 subtype = 4
190
191 def __init__(self, checksum=None):
192 if checksum != None:
193 self.checksum = checksum
194 else:
195 self.checksum = 0
196 return
197
198 def pack(self):
199 packed = []
200 packed.append(struct.pack("!H", self.type))
201 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
202 packed.append(struct.pack("!L", self.experimenter))
203 packed.append(struct.pack("!L", self.subtype))
204 packed.append(util.pack_checksum_128(self.checksum))
205 length = sum([len(x) for x in packed])
206 packed[1] = struct.pack("!H", length)
207 return ''.join(packed)
208
209 @staticmethod
210 def unpack(reader):
211 obj = bsn_checksum()
212 _type = reader.read("!H")[0]
213 assert(_type == 65535)
214 _len = reader.read("!H")[0]
215 orig_reader = reader
216 reader = orig_reader.slice(_len - (2 + 2))
217 _experimenter = reader.read("!L")[0]
218 assert(_experimenter == 6035143)
219 _subtype = reader.read("!L")[0]
220 assert(_subtype == 4)
221 obj.checksum = util.unpack_checksum_128(reader)
222 return obj
223
224 def __eq__(self, other):
225 if type(self) != type(other): return False
226 if self.checksum != other.checksum: return False
227 return True
228
229 def pretty_print(self, q):
230 q.text("bsn_checksum {")
231 with q.group():
232 with q.indent(2):
233 q.breakable()
234 q.text("checksum = ");
235 q.pp(self.checksum)
236 q.breakable()
237 q.text('}')
238
239bsn.subtypes[4] = bsn_checksum
240
Rich Lane7dcdf022013-12-11 14:45:27 -0800241class bsn_mirror(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700242 type = 65535
243 experimenter = 6035143
Rich Laneb658ddd2013-03-12 10:15:10 -0700244 subtype = 1
245
Rich Lanec2ee4b82013-04-24 17:12:38 -0700246 def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700247 if dest_port != None:
248 self.dest_port = dest_port
249 else:
250 self.dest_port = 0
251 if vlan_tag != None:
252 self.vlan_tag = vlan_tag
253 else:
254 self.vlan_tag = 0
255 if copy_stage != None:
256 self.copy_stage = copy_stage
257 else:
258 self.copy_stage = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700259 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700260
261 def pack(self):
262 packed = []
263 packed.append(struct.pack("!H", self.type))
264 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
265 packed.append(struct.pack("!L", self.experimenter))
266 packed.append(struct.pack("!L", self.subtype))
267 packed.append(struct.pack("!L", self.dest_port))
268 packed.append(struct.pack("!L", self.vlan_tag))
269 packed.append(struct.pack("!B", self.copy_stage))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700270 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700271 length = sum([len(x) for x in packed])
272 packed[1] = struct.pack("!H", length)
273 return ''.join(packed)
274
275 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800276 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700277 obj = bsn_mirror()
Dan Talaycof6202252013-07-02 01:00:29 -0700278 _type = reader.read("!H")[0]
279 assert(_type == 65535)
280 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800281 orig_reader = reader
282 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700283 _experimenter = reader.read("!L")[0]
284 assert(_experimenter == 6035143)
285 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700286 assert(_subtype == 1)
Dan Talaycof6202252013-07-02 01:00:29 -0700287 obj.dest_port = reader.read("!L")[0]
288 obj.vlan_tag = reader.read("!L")[0]
289 obj.copy_stage = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700290 reader.skip(3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700291 return obj
292
293 def __eq__(self, other):
294 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700295 if self.dest_port != other.dest_port: return False
296 if self.vlan_tag != other.vlan_tag: return False
297 if self.copy_stage != other.copy_stage: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700298 return True
299
Rich Laneb658ddd2013-03-12 10:15:10 -0700300 def pretty_print(self, q):
301 q.text("bsn_mirror {")
302 with q.group():
303 with q.indent(2):
304 q.breakable()
305 q.text("dest_port = ");
306 q.text("%#x" % self.dest_port)
307 q.text(","); q.breakable()
308 q.text("vlan_tag = ");
309 q.text("%#x" % self.vlan_tag)
310 q.text(","); q.breakable()
311 q.text("copy_stage = ");
312 q.text("%#x" % self.copy_stage)
Rich Laneb658ddd2013-03-12 10:15:10 -0700313 q.breakable()
314 q.text('}')
315
Rich Lane7dcdf022013-12-11 14:45:27 -0800316bsn.subtypes[1] = bsn_mirror
317
318class bsn_set_tunnel_dst(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700319 type = 65535
320 experimenter = 6035143
Rich Laneb658ddd2013-03-12 10:15:10 -0700321 subtype = 2
322
323 def __init__(self, dst=None):
324 if dst != None:
325 self.dst = dst
326 else:
327 self.dst = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700328 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700329
330 def pack(self):
331 packed = []
332 packed.append(struct.pack("!H", self.type))
333 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
334 packed.append(struct.pack("!L", self.experimenter))
335 packed.append(struct.pack("!L", self.subtype))
336 packed.append(struct.pack("!L", self.dst))
337 length = sum([len(x) for x in packed])
338 packed[1] = struct.pack("!H", length)
339 return ''.join(packed)
340
341 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800342 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700343 obj = bsn_set_tunnel_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700344 _type = reader.read("!H")[0]
345 assert(_type == 65535)
346 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800347 orig_reader = reader
348 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700349 _experimenter = reader.read("!L")[0]
350 assert(_experimenter == 6035143)
351 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700352 assert(_subtype == 2)
Dan Talaycof6202252013-07-02 01:00:29 -0700353 obj.dst = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -0700354 return obj
355
356 def __eq__(self, other):
357 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700358 if self.dst != other.dst: return False
359 return True
360
Rich Laneb658ddd2013-03-12 10:15:10 -0700361 def pretty_print(self, q):
362 q.text("bsn_set_tunnel_dst {")
363 with q.group():
364 with q.indent(2):
365 q.breakable()
366 q.text("dst = ");
367 q.text("%#x" % self.dst)
368 q.breakable()
369 q.text('}')
370
Rich Lane7dcdf022013-12-11 14:45:27 -0800371bsn.subtypes[2] = bsn_set_tunnel_dst
372
373class enqueue(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700374 type = 11
Rich Laneb658ddd2013-03-12 10:15:10 -0700375
Rich Lanec2ee4b82013-04-24 17:12:38 -0700376 def __init__(self, port=None, queue_id=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700377 if port != None:
378 self.port = port
379 else:
380 self.port = 0
Rich Laneb658ddd2013-03-12 10:15:10 -0700381 if queue_id != None:
382 self.queue_id = queue_id
383 else:
384 self.queue_id = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700385 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700386
387 def pack(self):
388 packed = []
389 packed.append(struct.pack("!H", self.type))
390 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700391 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700392 packed.append('\x00' * 6)
Rich Laneb658ddd2013-03-12 10:15:10 -0700393 packed.append(struct.pack("!L", self.queue_id))
394 length = sum([len(x) for x in packed])
395 packed[1] = struct.pack("!H", length)
396 return ''.join(packed)
397
398 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800399 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700400 obj = enqueue()
Dan Talaycof6202252013-07-02 01:00:29 -0700401 _type = reader.read("!H")[0]
402 assert(_type == 11)
403 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800404 orig_reader = reader
405 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700406 obj.port = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700407 reader.skip(6)
Dan Talaycof6202252013-07-02 01:00:29 -0700408 obj.queue_id = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -0700409 return obj
410
411 def __eq__(self, other):
412 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700413 if self.port != other.port: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700414 if self.queue_id != other.queue_id: return False
415 return True
416
Rich Laneb658ddd2013-03-12 10:15:10 -0700417 def pretty_print(self, q):
418 q.text("enqueue {")
419 with q.group():
420 with q.indent(2):
421 q.breakable()
422 q.text("port = ");
423 q.text(util.pretty_port(self.port))
424 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -0700425 q.text("queue_id = ");
426 q.text("%#x" % self.queue_id)
427 q.breakable()
428 q.text('}')
429
Rich Lane7dcdf022013-12-11 14:45:27 -0800430action.subtypes[11] = enqueue
431
432class nicira(experimenter):
433 subtypes = {}
434
Rich Lane95f7fc92014-01-27 17:08:16 -0800435 type = 65535
436 experimenter = 8992
437
438 def __init__(self, subtype=None):
439 if subtype != None:
440 self.subtype = subtype
441 else:
442 self.subtype = 0
443 return
444
445 def pack(self):
446 packed = []
447 packed.append(struct.pack("!H", self.type))
448 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
449 packed.append(struct.pack("!L", self.experimenter))
450 packed.append(struct.pack("!H", self.subtype))
451 packed.append('\x00' * 2)
452 packed.append('\x00' * 4)
453 length = sum([len(x) for x in packed])
454 packed[1] = struct.pack("!H", length)
455 return ''.join(packed)
456
Rich Lane7dcdf022013-12-11 14:45:27 -0800457 @staticmethod
458 def unpack(reader):
459 subtype, = reader.peek('!H', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800460 subclass = nicira.subtypes.get(subtype)
461 if subclass:
462 return subclass.unpack(reader)
463
464 obj = nicira()
465 _type = reader.read("!H")[0]
466 assert(_type == 65535)
467 _len = reader.read("!H")[0]
468 orig_reader = reader
469 reader = orig_reader.slice(_len - (2 + 2))
470 _experimenter = reader.read("!L")[0]
471 assert(_experimenter == 8992)
472 obj.subtype = reader.read("!H")[0]
473 reader.skip(2)
474 reader.skip(4)
475 return obj
476
477 def __eq__(self, other):
478 if type(self) != type(other): return False
479 if self.subtype != other.subtype: return False
480 return True
481
482 def pretty_print(self, q):
483 q.text("nicira {")
484 with q.group():
485 with q.indent(2):
486 q.breakable()
487 q.breakable()
488 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800489
490experimenter.subtypes[8992] = nicira
491
492class nicira_dec_ttl(nicira):
Dan Talaycof6202252013-07-02 01:00:29 -0700493 type = 65535
494 experimenter = 8992
Rich Laneb658ddd2013-03-12 10:15:10 -0700495 subtype = 18
496
Rich Lanec2ee4b82013-04-24 17:12:38 -0700497 def __init__(self):
498 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700499
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(struct.pack("!L", self.experimenter))
505 packed.append(struct.pack("!H", self.subtype))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700506 packed.append('\x00' * 2)
507 packed.append('\x00' * 4)
Rich Laneb658ddd2013-03-12 10:15:10 -0700508 length = sum([len(x) for x in packed])
509 packed[1] = struct.pack("!H", length)
510 return ''.join(packed)
511
512 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800513 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700514 obj = nicira_dec_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700515 _type = reader.read("!H")[0]
516 assert(_type == 65535)
517 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800518 orig_reader = reader
519 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700520 _experimenter = reader.read("!L")[0]
521 assert(_experimenter == 8992)
522 _subtype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700523 assert(_subtype == 18)
524 reader.skip(2)
525 reader.skip(4)
Rich Laneb658ddd2013-03-12 10:15:10 -0700526 return obj
527
528 def __eq__(self, other):
529 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700530 return True
531
Rich Laneb658ddd2013-03-12 10:15:10 -0700532 def pretty_print(self, q):
533 q.text("nicira_dec_ttl {")
534 with q.group():
535 with q.indent(2):
536 q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -0700537 q.breakable()
538 q.text('}')
539
Rich Lane7dcdf022013-12-11 14:45:27 -0800540nicira.subtypes[18] = nicira_dec_ttl
541
542class output(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700543 type = 0
Rich Laneb658ddd2013-03-12 10:15:10 -0700544
545 def __init__(self, port=None, max_len=None):
546 if port != None:
547 self.port = port
548 else:
549 self.port = 0
550 if max_len != None:
551 self.max_len = max_len
552 else:
553 self.max_len = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700554 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700555
556 def pack(self):
557 packed = []
558 packed.append(struct.pack("!H", self.type))
559 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700560 packed.append(util.pack_port_no(self.port))
Rich Laneb658ddd2013-03-12 10:15:10 -0700561 packed.append(struct.pack("!H", self.max_len))
562 length = sum([len(x) for x in packed])
563 packed[1] = struct.pack("!H", length)
564 return ''.join(packed)
565
566 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800567 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700568 obj = output()
Dan Talaycof6202252013-07-02 01:00:29 -0700569 _type = reader.read("!H")[0]
570 assert(_type == 0)
571 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800572 orig_reader = reader
573 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700574 obj.port = util.unpack_port_no(reader)
575 obj.max_len = reader.read("!H")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -0700576 return obj
577
578 def __eq__(self, other):
579 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700580 if self.port != other.port: return False
581 if self.max_len != other.max_len: return False
582 return True
583
Rich Laneb658ddd2013-03-12 10:15:10 -0700584 def pretty_print(self, q):
585 q.text("output {")
586 with q.group():
587 with q.indent(2):
588 q.breakable()
589 q.text("port = ");
590 q.text(util.pretty_port(self.port))
591 q.text(","); q.breakable()
592 q.text("max_len = ");
593 q.text("%#x" % self.max_len)
594 q.breakable()
595 q.text('}')
596
Rich Lane7dcdf022013-12-11 14:45:27 -0800597action.subtypes[0] = output
598
599class set_dl_dst(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700600 type = 5
Rich Laneb658ddd2013-03-12 10:15:10 -0700601
Rich Lanec2ee4b82013-04-24 17:12:38 -0700602 def __init__(self, dl_addr=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700603 if dl_addr != None:
604 self.dl_addr = dl_addr
605 else:
606 self.dl_addr = [0,0,0,0,0,0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700607 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700608
609 def pack(self):
610 packed = []
611 packed.append(struct.pack("!H", self.type))
612 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
613 packed.append(struct.pack("!6B", *self.dl_addr))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700614 packed.append('\x00' * 6)
Rich Laneb658ddd2013-03-12 10:15:10 -0700615 length = sum([len(x) for x in packed])
616 packed[1] = struct.pack("!H", length)
617 return ''.join(packed)
618
619 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800620 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700621 obj = set_dl_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700622 _type = reader.read("!H")[0]
623 assert(_type == 5)
624 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800625 orig_reader = reader
626 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700627 obj.dl_addr = list(reader.read('!6B'))
628 reader.skip(6)
Rich Laneb658ddd2013-03-12 10:15:10 -0700629 return obj
630
631 def __eq__(self, other):
632 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700633 if self.dl_addr != other.dl_addr: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700634 return True
635
Rich Laneb658ddd2013-03-12 10:15:10 -0700636 def pretty_print(self, q):
637 q.text("set_dl_dst {")
638 with q.group():
639 with q.indent(2):
640 q.breakable()
641 q.text("dl_addr = ");
642 q.text(util.pretty_mac(self.dl_addr))
Rich Laneb658ddd2013-03-12 10:15:10 -0700643 q.breakable()
644 q.text('}')
645
Rich Lane7dcdf022013-12-11 14:45:27 -0800646action.subtypes[5] = set_dl_dst
647
648class set_dl_src(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700649 type = 4
Rich Laneb658ddd2013-03-12 10:15:10 -0700650
Rich Lanec2ee4b82013-04-24 17:12:38 -0700651 def __init__(self, dl_addr=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700652 if dl_addr != None:
653 self.dl_addr = dl_addr
654 else:
655 self.dl_addr = [0,0,0,0,0,0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700656 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700657
658 def pack(self):
659 packed = []
660 packed.append(struct.pack("!H", self.type))
661 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
662 packed.append(struct.pack("!6B", *self.dl_addr))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700663 packed.append('\x00' * 6)
Rich Laneb658ddd2013-03-12 10:15:10 -0700664 length = sum([len(x) for x in packed])
665 packed[1] = struct.pack("!H", length)
666 return ''.join(packed)
667
668 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800669 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700670 obj = set_dl_src()
Dan Talaycof6202252013-07-02 01:00:29 -0700671 _type = reader.read("!H")[0]
672 assert(_type == 4)
673 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800674 orig_reader = reader
675 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700676 obj.dl_addr = list(reader.read('!6B'))
677 reader.skip(6)
Rich Laneb658ddd2013-03-12 10:15:10 -0700678 return obj
679
680 def __eq__(self, other):
681 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700682 if self.dl_addr != other.dl_addr: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700683 return True
684
Rich Laneb658ddd2013-03-12 10:15:10 -0700685 def pretty_print(self, q):
686 q.text("set_dl_src {")
687 with q.group():
688 with q.indent(2):
689 q.breakable()
690 q.text("dl_addr = ");
691 q.text(util.pretty_mac(self.dl_addr))
Rich Laneb658ddd2013-03-12 10:15:10 -0700692 q.breakable()
693 q.text('}')
694
Rich Lane7dcdf022013-12-11 14:45:27 -0800695action.subtypes[4] = set_dl_src
696
697class set_nw_dst(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700698 type = 7
Rich Laneb658ddd2013-03-12 10:15:10 -0700699
700 def __init__(self, nw_addr=None):
701 if nw_addr != None:
702 self.nw_addr = nw_addr
703 else:
704 self.nw_addr = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700705 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700706
707 def pack(self):
708 packed = []
709 packed.append(struct.pack("!H", self.type))
710 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
711 packed.append(struct.pack("!L", self.nw_addr))
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 Laneb658ddd2013-03-12 10:15:10 -0700718 obj = set_nw_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700719 _type = reader.read("!H")[0]
720 assert(_type == 7)
721 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800722 orig_reader = reader
723 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700724 obj.nw_addr = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -0700725 return obj
726
727 def __eq__(self, other):
728 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700729 if self.nw_addr != other.nw_addr: return False
730 return True
731
Rich Laneb658ddd2013-03-12 10:15:10 -0700732 def pretty_print(self, q):
733 q.text("set_nw_dst {")
734 with q.group():
735 with q.indent(2):
736 q.breakable()
737 q.text("nw_addr = ");
738 q.text("%#x" % self.nw_addr)
739 q.breakable()
740 q.text('}')
741
Rich Lane7dcdf022013-12-11 14:45:27 -0800742action.subtypes[7] = set_nw_dst
743
744class set_nw_src(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700745 type = 6
Rich Laneb658ddd2013-03-12 10:15:10 -0700746
747 def __init__(self, nw_addr=None):
748 if nw_addr != None:
749 self.nw_addr = nw_addr
750 else:
751 self.nw_addr = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700752 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700753
754 def pack(self):
755 packed = []
756 packed.append(struct.pack("!H", self.type))
757 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
758 packed.append(struct.pack("!L", self.nw_addr))
759 length = sum([len(x) for x in packed])
760 packed[1] = struct.pack("!H", length)
761 return ''.join(packed)
762
763 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800764 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700765 obj = set_nw_src()
Dan Talaycof6202252013-07-02 01:00:29 -0700766 _type = reader.read("!H")[0]
767 assert(_type == 6)
768 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800769 orig_reader = reader
770 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700771 obj.nw_addr = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -0700772 return obj
773
774 def __eq__(self, other):
775 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700776 if self.nw_addr != other.nw_addr: return False
777 return True
778
Rich Laneb658ddd2013-03-12 10:15:10 -0700779 def pretty_print(self, q):
780 q.text("set_nw_src {")
781 with q.group():
782 with q.indent(2):
783 q.breakable()
784 q.text("nw_addr = ");
785 q.text("%#x" % self.nw_addr)
786 q.breakable()
787 q.text('}')
788
Rich Lane7dcdf022013-12-11 14:45:27 -0800789action.subtypes[6] = set_nw_src
790
791class set_nw_tos(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700792 type = 8
Rich Laneb658ddd2013-03-12 10:15:10 -0700793
Rich Lanec2ee4b82013-04-24 17:12:38 -0700794 def __init__(self, nw_tos=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700795 if nw_tos != None:
796 self.nw_tos = nw_tos
797 else:
798 self.nw_tos = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700799 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700800
801 def pack(self):
802 packed = []
803 packed.append(struct.pack("!H", self.type))
804 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
805 packed.append(struct.pack("!B", self.nw_tos))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700806 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700807 length = sum([len(x) for x in packed])
808 packed[1] = struct.pack("!H", length)
809 return ''.join(packed)
810
811 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800812 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700813 obj = set_nw_tos()
Dan Talaycof6202252013-07-02 01:00:29 -0700814 _type = reader.read("!H")[0]
815 assert(_type == 8)
816 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800817 orig_reader = reader
818 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700819 obj.nw_tos = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700820 reader.skip(3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700821 return obj
822
823 def __eq__(self, other):
824 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700825 if self.nw_tos != other.nw_tos: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700826 return True
827
Rich Laneb658ddd2013-03-12 10:15:10 -0700828 def pretty_print(self, q):
829 q.text("set_nw_tos {")
830 with q.group():
831 with q.indent(2):
832 q.breakable()
833 q.text("nw_tos = ");
834 q.text("%#x" % self.nw_tos)
Rich Laneb658ddd2013-03-12 10:15:10 -0700835 q.breakable()
836 q.text('}')
837
Rich Lane7dcdf022013-12-11 14:45:27 -0800838action.subtypes[8] = set_nw_tos
839
840class set_tp_dst(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700841 type = 10
Rich Laneb658ddd2013-03-12 10:15:10 -0700842
Rich Lanec2ee4b82013-04-24 17:12:38 -0700843 def __init__(self, tp_port=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700844 if tp_port != None:
845 self.tp_port = tp_port
846 else:
847 self.tp_port = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700848 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700849
850 def pack(self):
851 packed = []
852 packed.append(struct.pack("!H", self.type))
853 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
854 packed.append(struct.pack("!H", self.tp_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700855 packed.append('\x00' * 2)
Rich Laneb658ddd2013-03-12 10:15:10 -0700856 length = sum([len(x) for x in packed])
857 packed[1] = struct.pack("!H", length)
858 return ''.join(packed)
859
860 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800861 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700862 obj = set_tp_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700863 _type = reader.read("!H")[0]
864 assert(_type == 10)
865 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800866 orig_reader = reader
867 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700868 obj.tp_port = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700869 reader.skip(2)
Rich Laneb658ddd2013-03-12 10:15:10 -0700870 return obj
871
872 def __eq__(self, other):
873 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700874 if self.tp_port != other.tp_port: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700875 return True
876
Rich Laneb658ddd2013-03-12 10:15:10 -0700877 def pretty_print(self, q):
878 q.text("set_tp_dst {")
879 with q.group():
880 with q.indent(2):
881 q.breakable()
882 q.text("tp_port = ");
883 q.text("%#x" % self.tp_port)
Rich Laneb658ddd2013-03-12 10:15:10 -0700884 q.breakable()
885 q.text('}')
886
Rich Lane7dcdf022013-12-11 14:45:27 -0800887action.subtypes[10] = set_tp_dst
888
889class set_tp_src(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700890 type = 9
Rich Laneb658ddd2013-03-12 10:15:10 -0700891
Rich Lanec2ee4b82013-04-24 17:12:38 -0700892 def __init__(self, tp_port=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700893 if tp_port != None:
894 self.tp_port = tp_port
895 else:
896 self.tp_port = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700897 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700898
899 def pack(self):
900 packed = []
901 packed.append(struct.pack("!H", self.type))
902 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
903 packed.append(struct.pack("!H", self.tp_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700904 packed.append('\x00' * 2)
Rich Laneb658ddd2013-03-12 10:15:10 -0700905 length = sum([len(x) for x in packed])
906 packed[1] = struct.pack("!H", length)
907 return ''.join(packed)
908
909 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800910 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700911 obj = set_tp_src()
Dan Talaycof6202252013-07-02 01:00:29 -0700912 _type = reader.read("!H")[0]
913 assert(_type == 9)
914 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800915 orig_reader = reader
916 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700917 obj.tp_port = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700918 reader.skip(2)
Rich Laneb658ddd2013-03-12 10:15:10 -0700919 return obj
920
921 def __eq__(self, other):
922 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700923 if self.tp_port != other.tp_port: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700924 return True
925
Rich Laneb658ddd2013-03-12 10:15:10 -0700926 def pretty_print(self, q):
927 q.text("set_tp_src {")
928 with q.group():
929 with q.indent(2):
930 q.breakable()
931 q.text("tp_port = ");
932 q.text("%#x" % self.tp_port)
Rich Laneb658ddd2013-03-12 10:15:10 -0700933 q.breakable()
934 q.text('}')
935
Rich Lane7dcdf022013-12-11 14:45:27 -0800936action.subtypes[9] = set_tp_src
937
938class set_vlan_pcp(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700939 type = 2
Rich Laneb658ddd2013-03-12 10:15:10 -0700940
Rich Lanec2ee4b82013-04-24 17:12:38 -0700941 def __init__(self, vlan_pcp=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700942 if vlan_pcp != None:
943 self.vlan_pcp = vlan_pcp
944 else:
945 self.vlan_pcp = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700946 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700947
948 def pack(self):
949 packed = []
950 packed.append(struct.pack("!H", self.type))
951 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
952 packed.append(struct.pack("!B", self.vlan_pcp))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700953 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700954 length = sum([len(x) for x in packed])
955 packed[1] = struct.pack("!H", length)
956 return ''.join(packed)
957
958 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800959 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700960 obj = set_vlan_pcp()
Dan Talaycof6202252013-07-02 01:00:29 -0700961 _type = reader.read("!H")[0]
962 assert(_type == 2)
963 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800964 orig_reader = reader
965 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700966 obj.vlan_pcp = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700967 reader.skip(3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700968 return obj
969
970 def __eq__(self, other):
971 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700972 if self.vlan_pcp != other.vlan_pcp: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700973 return True
974
Rich Laneb658ddd2013-03-12 10:15:10 -0700975 def pretty_print(self, q):
976 q.text("set_vlan_pcp {")
977 with q.group():
978 with q.indent(2):
979 q.breakable()
980 q.text("vlan_pcp = ");
981 q.text("%#x" % self.vlan_pcp)
Rich Laneb658ddd2013-03-12 10:15:10 -0700982 q.breakable()
983 q.text('}')
984
Rich Lane7dcdf022013-12-11 14:45:27 -0800985action.subtypes[2] = set_vlan_pcp
986
987class set_vlan_vid(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700988 type = 1
Rich Laneb658ddd2013-03-12 10:15:10 -0700989
Rich Lanec2ee4b82013-04-24 17:12:38 -0700990 def __init__(self, vlan_vid=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700991 if vlan_vid != None:
992 self.vlan_vid = vlan_vid
993 else:
994 self.vlan_vid = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700995 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700996
997 def pack(self):
998 packed = []
999 packed.append(struct.pack("!H", self.type))
1000 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1001 packed.append(struct.pack("!H", self.vlan_vid))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001002 packed.append('\x00' * 2)
Rich Laneb658ddd2013-03-12 10:15:10 -07001003 length = sum([len(x) for x in packed])
1004 packed[1] = struct.pack("!H", length)
1005 return ''.join(packed)
1006
1007 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001008 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -07001009 obj = set_vlan_vid()
Dan Talaycof6202252013-07-02 01:00:29 -07001010 _type = reader.read("!H")[0]
1011 assert(_type == 1)
1012 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001013 orig_reader = reader
1014 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -07001015 obj.vlan_vid = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001016 reader.skip(2)
Rich Laneb658ddd2013-03-12 10:15:10 -07001017 return obj
1018
1019 def __eq__(self, other):
1020 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -07001021 if self.vlan_vid != other.vlan_vid: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07001022 return True
1023
Rich Laneb658ddd2013-03-12 10:15:10 -07001024 def pretty_print(self, q):
1025 q.text("set_vlan_vid {")
1026 with q.group():
1027 with q.indent(2):
1028 q.breakable()
1029 q.text("vlan_vid = ");
1030 q.text("%#x" % self.vlan_vid)
Rich Laneb658ddd2013-03-12 10:15:10 -07001031 q.breakable()
1032 q.text('}')
1033
Rich Lane7dcdf022013-12-11 14:45:27 -08001034action.subtypes[1] = set_vlan_vid
1035
1036class strip_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001037 type = 3
Rich Laneb658ddd2013-03-12 10:15:10 -07001038
Rich Lanec2ee4b82013-04-24 17:12:38 -07001039 def __init__(self):
1040 return
Rich Laneb658ddd2013-03-12 10:15:10 -07001041
1042 def pack(self):
1043 packed = []
1044 packed.append(struct.pack("!H", self.type))
1045 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07001046 packed.append('\x00' * 4)
Rich Laneb658ddd2013-03-12 10:15:10 -07001047 length = sum([len(x) for x in packed])
1048 packed[1] = struct.pack("!H", length)
1049 return ''.join(packed)
1050
1051 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001052 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -07001053 obj = strip_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -07001054 _type = reader.read("!H")[0]
1055 assert(_type == 3)
1056 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001057 orig_reader = reader
1058 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001059 reader.skip(4)
Rich Laneb658ddd2013-03-12 10:15:10 -07001060 return obj
1061
1062 def __eq__(self, other):
1063 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -07001064 return True
1065
Rich Laneb658ddd2013-03-12 10:15:10 -07001066 def pretty_print(self, q):
1067 q.text("strip_vlan {")
1068 with q.group():
1069 with q.indent(2):
1070 q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07001071 q.breakable()
1072 q.text('}')
1073
Rich Lane7dcdf022013-12-11 14:45:27 -08001074action.subtypes[3] = strip_vlan
Rich Laneb658ddd2013-03-12 10:15:10 -07001075
Rich Laneb658ddd2013-03-12 10:15:10 -07001076