blob: d8ac86f5ec33caadc957e205b28096de70092255 [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 util
Rich Lanec2ee4b82013-04-24 17:12:38 -070012import loxi.generic_util
Rich Laneb658ddd2013-03-12 10:15:10 -070013
Rich Lanee2567702015-01-26 15:04:35 -080014import sys
15ofp = sys.modules['loxi.of10']
16
Rich Lane7dcdf022013-12-11 14:45:27 -080017class action(loxi.OFObject):
18 subtypes = {}
Rich Laneb658ddd2013-03-12 10:15:10 -070019
Rich Lane95f7fc92014-01-27 17:08:16 -080020
21 def __init__(self, type=None):
22 if type != None:
23 self.type = type
24 else:
25 self.type = 0
26 return
27
28 def pack(self):
29 packed = []
30 packed.append(struct.pack("!H", self.type))
31 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
32 packed.append('\x00' * 4)
33 length = sum([len(x) for x in packed])
34 packed[1] = struct.pack("!H", length)
35 return ''.join(packed)
36
Rich Lane7dcdf022013-12-11 14:45:27 -080037 @staticmethod
38 def unpack(reader):
39 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -080040 subclass = action.subtypes.get(subtype)
41 if subclass:
42 return subclass.unpack(reader)
43
44 obj = action()
45 obj.type = reader.read("!H")[0]
46 _len = reader.read("!H")[0]
47 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -080048 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -080049 reader.skip(4)
50 return obj
51
52 def __eq__(self, other):
53 if type(self) != type(other): return False
54 if self.type != other.type: return False
55 return True
56
57 def pretty_print(self, q):
58 q.text("action {")
59 with q.group():
60 with q.indent(2):
61 q.breakable()
62 q.breakable()
63 q.text('}')
Rich Laneb658ddd2013-03-12 10:15:10 -070064
Rich Lane7dcdf022013-12-11 14:45:27 -080065
66class experimenter(action):
67 subtypes = {}
68
Rich Lane95f7fc92014-01-27 17:08:16 -080069 type = 65535
70
71 def __init__(self, experimenter=None, data=None):
72 if experimenter != None:
73 self.experimenter = experimenter
74 else:
75 self.experimenter = 0
76 if data != None:
77 self.data = data
78 else:
79 self.data = ''
80 return
81
82 def pack(self):
83 packed = []
84 packed.append(struct.pack("!H", self.type))
85 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
86 packed.append(struct.pack("!L", self.experimenter))
87 packed.append(self.data)
88 length = sum([len(x) for x in packed])
89 packed[1] = struct.pack("!H", length)
90 return ''.join(packed)
91
Rich Lane7dcdf022013-12-11 14:45:27 -080092 @staticmethod
93 def unpack(reader):
94 subtype, = reader.peek('!L', 4)
Rich Lane95f7fc92014-01-27 17:08:16 -080095 subclass = experimenter.subtypes.get(subtype)
96 if subclass:
97 return subclass.unpack(reader)
98
99 obj = experimenter()
100 _type = reader.read("!H")[0]
101 assert(_type == 65535)
102 _len = reader.read("!H")[0]
103 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800104 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800105 obj.experimenter = reader.read("!L")[0]
106 obj.data = str(reader.read_all())
107 return obj
108
109 def __eq__(self, other):
110 if type(self) != type(other): return False
111 if self.experimenter != other.experimenter: return False
112 if self.data != other.data: return False
113 return True
114
115 def pretty_print(self, q):
116 q.text("experimenter {")
117 with q.group():
118 with q.indent(2):
119 q.breakable()
120 q.text("data = ");
121 q.pp(self.data)
122 q.breakable()
123 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800124
125action.subtypes[65535] = experimenter
126
127class bsn(experimenter):
128 subtypes = {}
129
Rich Lane95f7fc92014-01-27 17:08:16 -0800130 type = 65535
131 experimenter = 6035143
132
133 def __init__(self, subtype=None):
134 if subtype != None:
135 self.subtype = subtype
136 else:
137 self.subtype = 0
138 return
139
140 def pack(self):
141 packed = []
142 packed.append(struct.pack("!H", self.type))
143 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
144 packed.append(struct.pack("!L", self.experimenter))
145 packed.append(struct.pack("!L", self.subtype))
146 packed.append('\x00' * 4)
147 length = sum([len(x) for x in packed])
148 packed[1] = struct.pack("!H", length)
149 return ''.join(packed)
150
Rich Lane7dcdf022013-12-11 14:45:27 -0800151 @staticmethod
152 def unpack(reader):
153 subtype, = reader.peek('!L', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800154 subclass = bsn.subtypes.get(subtype)
155 if subclass:
156 return subclass.unpack(reader)
157
158 obj = bsn()
159 _type = reader.read("!H")[0]
160 assert(_type == 65535)
161 _len = reader.read("!H")[0]
162 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800163 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800164 _experimenter = reader.read("!L")[0]
165 assert(_experimenter == 6035143)
166 obj.subtype = reader.read("!L")[0]
167 reader.skip(4)
168 return obj
169
170 def __eq__(self, other):
171 if type(self) != type(other): return False
172 if self.subtype != other.subtype: return False
173 return True
174
175 def pretty_print(self, q):
176 q.text("bsn {")
177 with q.group():
178 with q.indent(2):
179 q.breakable()
180 q.breakable()
181 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800182
183experimenter.subtypes[6035143] = bsn
184
Rich Lane5587ab12014-06-30 11:19:09 -0700185class bsn_checksum(bsn):
186 type = 65535
187 experimenter = 6035143
188 subtype = 4
189
190 def __init__(self, checksum=None):
191 if checksum != None:
192 self.checksum = checksum
193 else:
194 self.checksum = 0
195 return
196
197 def pack(self):
198 packed = []
199 packed.append(struct.pack("!H", self.type))
200 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
201 packed.append(struct.pack("!L", self.experimenter))
202 packed.append(struct.pack("!L", self.subtype))
203 packed.append(util.pack_checksum_128(self.checksum))
204 length = sum([len(x) for x in packed])
205 packed[1] = struct.pack("!H", length)
206 return ''.join(packed)
207
208 @staticmethod
209 def unpack(reader):
210 obj = bsn_checksum()
211 _type = reader.read("!H")[0]
212 assert(_type == 65535)
213 _len = reader.read("!H")[0]
214 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800215 reader = orig_reader.slice(_len, 4)
Rich Lane5587ab12014-06-30 11:19:09 -0700216 _experimenter = reader.read("!L")[0]
217 assert(_experimenter == 6035143)
218 _subtype = reader.read("!L")[0]
219 assert(_subtype == 4)
220 obj.checksum = util.unpack_checksum_128(reader)
221 return obj
222
223 def __eq__(self, other):
224 if type(self) != type(other): return False
225 if self.checksum != other.checksum: return False
226 return True
227
228 def pretty_print(self, q):
229 q.text("bsn_checksum {")
230 with q.group():
231 with q.indent(2):
232 q.breakable()
233 q.text("checksum = ");
234 q.pp(self.checksum)
235 q.breakable()
236 q.text('}')
237
238bsn.subtypes[4] = bsn_checksum
239
Rich Lane7dcdf022013-12-11 14:45:27 -0800240class bsn_mirror(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700241 type = 65535
242 experimenter = 6035143
Rich Laneb658ddd2013-03-12 10:15:10 -0700243 subtype = 1
244
Rich Lanec2ee4b82013-04-24 17:12:38 -0700245 def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700246 if dest_port != None:
247 self.dest_port = dest_port
248 else:
249 self.dest_port = 0
250 if vlan_tag != None:
251 self.vlan_tag = vlan_tag
252 else:
253 self.vlan_tag = 0
254 if copy_stage != None:
255 self.copy_stage = copy_stage
256 else:
257 self.copy_stage = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700258 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700259
260 def pack(self):
261 packed = []
262 packed.append(struct.pack("!H", self.type))
263 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
264 packed.append(struct.pack("!L", self.experimenter))
265 packed.append(struct.pack("!L", self.subtype))
266 packed.append(struct.pack("!L", self.dest_port))
267 packed.append(struct.pack("!L", self.vlan_tag))
268 packed.append(struct.pack("!B", self.copy_stage))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700269 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700270 length = sum([len(x) for x in packed])
271 packed[1] = struct.pack("!H", length)
272 return ''.join(packed)
273
274 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800275 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700276 obj = bsn_mirror()
Dan Talaycof6202252013-07-02 01:00:29 -0700277 _type = reader.read("!H")[0]
278 assert(_type == 65535)
279 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800280 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800281 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700282 _experimenter = reader.read("!L")[0]
283 assert(_experimenter == 6035143)
284 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700285 assert(_subtype == 1)
Dan Talaycof6202252013-07-02 01:00:29 -0700286 obj.dest_port = reader.read("!L")[0]
287 obj.vlan_tag = reader.read("!L")[0]
288 obj.copy_stage = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700289 reader.skip(3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700290 return obj
291
292 def __eq__(self, other):
293 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700294 if self.dest_port != other.dest_port: return False
295 if self.vlan_tag != other.vlan_tag: return False
296 if self.copy_stage != other.copy_stage: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700297 return True
298
Rich Laneb658ddd2013-03-12 10:15:10 -0700299 def pretty_print(self, q):
300 q.text("bsn_mirror {")
301 with q.group():
302 with q.indent(2):
303 q.breakable()
304 q.text("dest_port = ");
305 q.text("%#x" % self.dest_port)
306 q.text(","); q.breakable()
307 q.text("vlan_tag = ");
308 q.text("%#x" % self.vlan_tag)
309 q.text(","); q.breakable()
310 q.text("copy_stage = ");
311 q.text("%#x" % self.copy_stage)
Rich Laneb658ddd2013-03-12 10:15:10 -0700312 q.breakable()
313 q.text('}')
314
Rich Lane7dcdf022013-12-11 14:45:27 -0800315bsn.subtypes[1] = bsn_mirror
316
317class bsn_set_tunnel_dst(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700318 type = 65535
319 experimenter = 6035143
Rich Laneb658ddd2013-03-12 10:15:10 -0700320 subtype = 2
321
322 def __init__(self, dst=None):
323 if dst != None:
324 self.dst = dst
325 else:
326 self.dst = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700327 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700328
329 def pack(self):
330 packed = []
331 packed.append(struct.pack("!H", self.type))
332 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
333 packed.append(struct.pack("!L", self.experimenter))
334 packed.append(struct.pack("!L", self.subtype))
335 packed.append(struct.pack("!L", self.dst))
336 length = sum([len(x) for x in packed])
337 packed[1] = struct.pack("!H", length)
338 return ''.join(packed)
339
340 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800341 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700342 obj = bsn_set_tunnel_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700343 _type = reader.read("!H")[0]
344 assert(_type == 65535)
345 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800346 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800347 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700348 _experimenter = reader.read("!L")[0]
349 assert(_experimenter == 6035143)
350 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700351 assert(_subtype == 2)
Dan Talaycof6202252013-07-02 01:00:29 -0700352 obj.dst = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -0700353 return obj
354
355 def __eq__(self, other):
356 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700357 if self.dst != other.dst: return False
358 return True
359
Rich Laneb658ddd2013-03-12 10:15:10 -0700360 def pretty_print(self, q):
361 q.text("bsn_set_tunnel_dst {")
362 with q.group():
363 with q.indent(2):
364 q.breakable()
365 q.text("dst = ");
366 q.text("%#x" % self.dst)
367 q.breakable()
368 q.text('}')
369
Rich Lane7dcdf022013-12-11 14:45:27 -0800370bsn.subtypes[2] = bsn_set_tunnel_dst
371
372class enqueue(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700373 type = 11
Rich Laneb658ddd2013-03-12 10:15:10 -0700374
Rich Lanec2ee4b82013-04-24 17:12:38 -0700375 def __init__(self, port=None, queue_id=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700376 if port != None:
377 self.port = port
378 else:
379 self.port = 0
Rich Laneb658ddd2013-03-12 10:15:10 -0700380 if queue_id != None:
381 self.queue_id = queue_id
382 else:
383 self.queue_id = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700384 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700385
386 def pack(self):
387 packed = []
388 packed.append(struct.pack("!H", self.type))
389 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700390 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700391 packed.append('\x00' * 6)
Rich Laneb658ddd2013-03-12 10:15:10 -0700392 packed.append(struct.pack("!L", self.queue_id))
393 length = sum([len(x) for x in packed])
394 packed[1] = struct.pack("!H", length)
395 return ''.join(packed)
396
397 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800398 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700399 obj = enqueue()
Dan Talaycof6202252013-07-02 01:00:29 -0700400 _type = reader.read("!H")[0]
401 assert(_type == 11)
402 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800403 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800404 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700405 obj.port = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700406 reader.skip(6)
Dan Talaycof6202252013-07-02 01:00:29 -0700407 obj.queue_id = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -0700408 return obj
409
410 def __eq__(self, other):
411 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700412 if self.port != other.port: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700413 if self.queue_id != other.queue_id: return False
414 return True
415
Rich Laneb658ddd2013-03-12 10:15:10 -0700416 def pretty_print(self, q):
417 q.text("enqueue {")
418 with q.group():
419 with q.indent(2):
420 q.breakable()
421 q.text("port = ");
422 q.text(util.pretty_port(self.port))
423 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -0700424 q.text("queue_id = ");
425 q.text("%#x" % self.queue_id)
426 q.breakable()
427 q.text('}')
428
Rich Lane7dcdf022013-12-11 14:45:27 -0800429action.subtypes[11] = enqueue
430
431class nicira(experimenter):
432 subtypes = {}
433
Rich Lane95f7fc92014-01-27 17:08:16 -0800434 type = 65535
435 experimenter = 8992
436
437 def __init__(self, subtype=None):
438 if subtype != None:
439 self.subtype = subtype
440 else:
441 self.subtype = 0
442 return
443
444 def pack(self):
445 packed = []
446 packed.append(struct.pack("!H", self.type))
447 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
448 packed.append(struct.pack("!L", self.experimenter))
449 packed.append(struct.pack("!H", self.subtype))
450 packed.append('\x00' * 2)
451 packed.append('\x00' * 4)
452 length = sum([len(x) for x in packed])
453 packed[1] = struct.pack("!H", length)
454 return ''.join(packed)
455
Rich Lane7dcdf022013-12-11 14:45:27 -0800456 @staticmethod
457 def unpack(reader):
458 subtype, = reader.peek('!H', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800459 subclass = nicira.subtypes.get(subtype)
460 if subclass:
461 return subclass.unpack(reader)
462
463 obj = nicira()
464 _type = reader.read("!H")[0]
465 assert(_type == 65535)
466 _len = reader.read("!H")[0]
467 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800468 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800469 _experimenter = reader.read("!L")[0]
470 assert(_experimenter == 8992)
471 obj.subtype = reader.read("!H")[0]
472 reader.skip(2)
473 reader.skip(4)
474 return obj
475
476 def __eq__(self, other):
477 if type(self) != type(other): return False
478 if self.subtype != other.subtype: return False
479 return True
480
481 def pretty_print(self, q):
482 q.text("nicira {")
483 with q.group():
484 with q.indent(2):
485 q.breakable()
486 q.breakable()
487 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800488
489experimenter.subtypes[8992] = nicira
490
491class nicira_dec_ttl(nicira):
Dan Talaycof6202252013-07-02 01:00:29 -0700492 type = 65535
493 experimenter = 8992
Rich Laneb658ddd2013-03-12 10:15:10 -0700494 subtype = 18
495
Rich Lanec2ee4b82013-04-24 17:12:38 -0700496 def __init__(self):
497 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700498
499 def pack(self):
500 packed = []
501 packed.append(struct.pack("!H", self.type))
502 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
503 packed.append(struct.pack("!L", self.experimenter))
504 packed.append(struct.pack("!H", self.subtype))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700505 packed.append('\x00' * 2)
506 packed.append('\x00' * 4)
Rich Laneb658ddd2013-03-12 10:15:10 -0700507 length = sum([len(x) for x in packed])
508 packed[1] = struct.pack("!H", length)
509 return ''.join(packed)
510
511 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800512 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700513 obj = nicira_dec_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700514 _type = reader.read("!H")[0]
515 assert(_type == 65535)
516 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800517 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800518 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700519 _experimenter = reader.read("!L")[0]
520 assert(_experimenter == 8992)
521 _subtype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700522 assert(_subtype == 18)
523 reader.skip(2)
524 reader.skip(4)
Rich Laneb658ddd2013-03-12 10:15:10 -0700525 return obj
526
527 def __eq__(self, other):
528 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700529 return True
530
Rich Laneb658ddd2013-03-12 10:15:10 -0700531 def pretty_print(self, q):
532 q.text("nicira_dec_ttl {")
533 with q.group():
534 with q.indent(2):
535 q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -0700536 q.breakable()
537 q.text('}')
538
Rich Lane7dcdf022013-12-11 14:45:27 -0800539nicira.subtypes[18] = nicira_dec_ttl
540
541class output(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700542 type = 0
Rich Laneb658ddd2013-03-12 10:15:10 -0700543
544 def __init__(self, port=None, max_len=None):
545 if port != None:
546 self.port = port
547 else:
548 self.port = 0
549 if max_len != None:
550 self.max_len = max_len
551 else:
552 self.max_len = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700553 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700554
555 def pack(self):
556 packed = []
557 packed.append(struct.pack("!H", self.type))
558 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700559 packed.append(util.pack_port_no(self.port))
Rich Laneb658ddd2013-03-12 10:15:10 -0700560 packed.append(struct.pack("!H", self.max_len))
561 length = sum([len(x) for x in packed])
562 packed[1] = struct.pack("!H", length)
563 return ''.join(packed)
564
565 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800566 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700567 obj = output()
Dan Talaycof6202252013-07-02 01:00:29 -0700568 _type = reader.read("!H")[0]
569 assert(_type == 0)
570 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800571 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800572 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700573 obj.port = util.unpack_port_no(reader)
574 obj.max_len = reader.read("!H")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -0700575 return obj
576
577 def __eq__(self, other):
578 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700579 if self.port != other.port: return False
580 if self.max_len != other.max_len: return False
581 return True
582
Rich Laneb658ddd2013-03-12 10:15:10 -0700583 def pretty_print(self, q):
584 q.text("output {")
585 with q.group():
586 with q.indent(2):
587 q.breakable()
588 q.text("port = ");
589 q.text(util.pretty_port(self.port))
590 q.text(","); q.breakable()
591 q.text("max_len = ");
592 q.text("%#x" % self.max_len)
593 q.breakable()
594 q.text('}')
595
Rich Lane7dcdf022013-12-11 14:45:27 -0800596action.subtypes[0] = output
597
598class set_dl_dst(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700599 type = 5
Rich Laneb658ddd2013-03-12 10:15:10 -0700600
Rich Lanec2ee4b82013-04-24 17:12:38 -0700601 def __init__(self, dl_addr=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700602 if dl_addr != None:
603 self.dl_addr = dl_addr
604 else:
605 self.dl_addr = [0,0,0,0,0,0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700606 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700607
608 def pack(self):
609 packed = []
610 packed.append(struct.pack("!H", self.type))
611 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
612 packed.append(struct.pack("!6B", *self.dl_addr))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700613 packed.append('\x00' * 6)
Rich Laneb658ddd2013-03-12 10:15:10 -0700614 length = sum([len(x) for x in packed])
615 packed[1] = struct.pack("!H", length)
616 return ''.join(packed)
617
618 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800619 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700620 obj = set_dl_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700621 _type = reader.read("!H")[0]
622 assert(_type == 5)
623 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800624 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800625 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700626 obj.dl_addr = list(reader.read('!6B'))
627 reader.skip(6)
Rich Laneb658ddd2013-03-12 10:15:10 -0700628 return obj
629
630 def __eq__(self, other):
631 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700632 if self.dl_addr != other.dl_addr: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700633 return True
634
Rich Laneb658ddd2013-03-12 10:15:10 -0700635 def pretty_print(self, q):
636 q.text("set_dl_dst {")
637 with q.group():
638 with q.indent(2):
639 q.breakable()
640 q.text("dl_addr = ");
641 q.text(util.pretty_mac(self.dl_addr))
Rich Laneb658ddd2013-03-12 10:15:10 -0700642 q.breakable()
643 q.text('}')
644
Rich Lane7dcdf022013-12-11 14:45:27 -0800645action.subtypes[5] = set_dl_dst
646
647class set_dl_src(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700648 type = 4
Rich Laneb658ddd2013-03-12 10:15:10 -0700649
Rich Lanec2ee4b82013-04-24 17:12:38 -0700650 def __init__(self, dl_addr=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700651 if dl_addr != None:
652 self.dl_addr = dl_addr
653 else:
654 self.dl_addr = [0,0,0,0,0,0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700655 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700656
657 def pack(self):
658 packed = []
659 packed.append(struct.pack("!H", self.type))
660 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
661 packed.append(struct.pack("!6B", *self.dl_addr))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700662 packed.append('\x00' * 6)
Rich Laneb658ddd2013-03-12 10:15:10 -0700663 length = sum([len(x) for x in packed])
664 packed[1] = struct.pack("!H", length)
665 return ''.join(packed)
666
667 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800668 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700669 obj = set_dl_src()
Dan Talaycof6202252013-07-02 01:00:29 -0700670 _type = reader.read("!H")[0]
671 assert(_type == 4)
672 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800673 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800674 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700675 obj.dl_addr = list(reader.read('!6B'))
676 reader.skip(6)
Rich Laneb658ddd2013-03-12 10:15:10 -0700677 return obj
678
679 def __eq__(self, other):
680 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700681 if self.dl_addr != other.dl_addr: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700682 return True
683
Rich Laneb658ddd2013-03-12 10:15:10 -0700684 def pretty_print(self, q):
685 q.text("set_dl_src {")
686 with q.group():
687 with q.indent(2):
688 q.breakable()
689 q.text("dl_addr = ");
690 q.text(util.pretty_mac(self.dl_addr))
Rich Laneb658ddd2013-03-12 10:15:10 -0700691 q.breakable()
692 q.text('}')
693
Rich Lane7dcdf022013-12-11 14:45:27 -0800694action.subtypes[4] = set_dl_src
695
696class set_nw_dst(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700697 type = 7
Rich Laneb658ddd2013-03-12 10:15:10 -0700698
699 def __init__(self, nw_addr=None):
700 if nw_addr != None:
701 self.nw_addr = nw_addr
702 else:
703 self.nw_addr = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700704 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700705
706 def pack(self):
707 packed = []
708 packed.append(struct.pack("!H", self.type))
709 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
710 packed.append(struct.pack("!L", self.nw_addr))
711 length = sum([len(x) for x in packed])
712 packed[1] = struct.pack("!H", length)
713 return ''.join(packed)
714
715 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800716 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700717 obj = set_nw_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700718 _type = reader.read("!H")[0]
719 assert(_type == 7)
720 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800721 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800722 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700723 obj.nw_addr = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -0700724 return obj
725
726 def __eq__(self, other):
727 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700728 if self.nw_addr != other.nw_addr: return False
729 return True
730
Rich Laneb658ddd2013-03-12 10:15:10 -0700731 def pretty_print(self, q):
732 q.text("set_nw_dst {")
733 with q.group():
734 with q.indent(2):
735 q.breakable()
736 q.text("nw_addr = ");
737 q.text("%#x" % self.nw_addr)
738 q.breakable()
739 q.text('}')
740
Rich Lane7dcdf022013-12-11 14:45:27 -0800741action.subtypes[7] = set_nw_dst
742
743class set_nw_src(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700744 type = 6
Rich Laneb658ddd2013-03-12 10:15:10 -0700745
746 def __init__(self, nw_addr=None):
747 if nw_addr != None:
748 self.nw_addr = nw_addr
749 else:
750 self.nw_addr = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700751 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700752
753 def pack(self):
754 packed = []
755 packed.append(struct.pack("!H", self.type))
756 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
757 packed.append(struct.pack("!L", self.nw_addr))
758 length = sum([len(x) for x in packed])
759 packed[1] = struct.pack("!H", length)
760 return ''.join(packed)
761
762 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800763 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700764 obj = set_nw_src()
Dan Talaycof6202252013-07-02 01:00:29 -0700765 _type = reader.read("!H")[0]
766 assert(_type == 6)
767 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800768 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800769 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700770 obj.nw_addr = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -0700771 return obj
772
773 def __eq__(self, other):
774 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700775 if self.nw_addr != other.nw_addr: return False
776 return True
777
Rich Laneb658ddd2013-03-12 10:15:10 -0700778 def pretty_print(self, q):
779 q.text("set_nw_src {")
780 with q.group():
781 with q.indent(2):
782 q.breakable()
783 q.text("nw_addr = ");
784 q.text("%#x" % self.nw_addr)
785 q.breakable()
786 q.text('}')
787
Rich Lane7dcdf022013-12-11 14:45:27 -0800788action.subtypes[6] = set_nw_src
789
790class set_nw_tos(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700791 type = 8
Rich Laneb658ddd2013-03-12 10:15:10 -0700792
Rich Lanec2ee4b82013-04-24 17:12:38 -0700793 def __init__(self, nw_tos=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700794 if nw_tos != None:
795 self.nw_tos = nw_tos
796 else:
797 self.nw_tos = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700798 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700799
800 def pack(self):
801 packed = []
802 packed.append(struct.pack("!H", self.type))
803 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
804 packed.append(struct.pack("!B", self.nw_tos))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700805 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700806 length = sum([len(x) for x in packed])
807 packed[1] = struct.pack("!H", length)
808 return ''.join(packed)
809
810 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800811 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700812 obj = set_nw_tos()
Dan Talaycof6202252013-07-02 01:00:29 -0700813 _type = reader.read("!H")[0]
814 assert(_type == 8)
815 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800816 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800817 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700818 obj.nw_tos = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700819 reader.skip(3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700820 return obj
821
822 def __eq__(self, other):
823 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700824 if self.nw_tos != other.nw_tos: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700825 return True
826
Rich Laneb658ddd2013-03-12 10:15:10 -0700827 def pretty_print(self, q):
828 q.text("set_nw_tos {")
829 with q.group():
830 with q.indent(2):
831 q.breakable()
832 q.text("nw_tos = ");
833 q.text("%#x" % self.nw_tos)
Rich Laneb658ddd2013-03-12 10:15:10 -0700834 q.breakable()
835 q.text('}')
836
Rich Lane7dcdf022013-12-11 14:45:27 -0800837action.subtypes[8] = set_nw_tos
838
839class set_tp_dst(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700840 type = 10
Rich Laneb658ddd2013-03-12 10:15:10 -0700841
Rich Lanec2ee4b82013-04-24 17:12:38 -0700842 def __init__(self, tp_port=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700843 if tp_port != None:
844 self.tp_port = tp_port
845 else:
846 self.tp_port = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700847 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700848
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.tp_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700854 packed.append('\x00' * 2)
Rich Laneb658ddd2013-03-12 10:15:10 -0700855 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 Laneb658ddd2013-03-12 10:15:10 -0700861 obj = set_tp_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700862 _type = reader.read("!H")[0]
863 assert(_type == 10)
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.tp_port = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700868 reader.skip(2)
Rich Laneb658ddd2013-03-12 10:15:10 -0700869 return obj
870
871 def __eq__(self, other):
872 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700873 if self.tp_port != other.tp_port: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700874 return True
875
Rich Laneb658ddd2013-03-12 10:15:10 -0700876 def pretty_print(self, q):
877 q.text("set_tp_dst {")
878 with q.group():
879 with q.indent(2):
880 q.breakable()
881 q.text("tp_port = ");
882 q.text("%#x" % self.tp_port)
Rich Laneb658ddd2013-03-12 10:15:10 -0700883 q.breakable()
884 q.text('}')
885
Rich Lane7dcdf022013-12-11 14:45:27 -0800886action.subtypes[10] = set_tp_dst
887
888class set_tp_src(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700889 type = 9
Rich Laneb658ddd2013-03-12 10:15:10 -0700890
Rich Lanec2ee4b82013-04-24 17:12:38 -0700891 def __init__(self, tp_port=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700892 if tp_port != None:
893 self.tp_port = tp_port
894 else:
895 self.tp_port = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700896 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700897
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.tp_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700903 packed.append('\x00' * 2)
Rich Laneb658ddd2013-03-12 10:15:10 -0700904 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 Laneb658ddd2013-03-12 10:15:10 -0700910 obj = set_tp_src()
Dan Talaycof6202252013-07-02 01:00:29 -0700911 _type = reader.read("!H")[0]
912 assert(_type == 9)
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.tp_port = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700917 reader.skip(2)
Rich Laneb658ddd2013-03-12 10:15:10 -0700918 return obj
919
920 def __eq__(self, other):
921 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700922 if self.tp_port != other.tp_port: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700923 return True
924
Rich Laneb658ddd2013-03-12 10:15:10 -0700925 def pretty_print(self, q):
926 q.text("set_tp_src {")
927 with q.group():
928 with q.indent(2):
929 q.breakable()
930 q.text("tp_port = ");
931 q.text("%#x" % self.tp_port)
Rich Laneb658ddd2013-03-12 10:15:10 -0700932 q.breakable()
933 q.text('}')
934
Rich Lane7dcdf022013-12-11 14:45:27 -0800935action.subtypes[9] = set_tp_src
936
937class set_vlan_pcp(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700938 type = 2
Rich Laneb658ddd2013-03-12 10:15:10 -0700939
Rich Lanec2ee4b82013-04-24 17:12:38 -0700940 def __init__(self, vlan_pcp=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700941 if vlan_pcp != None:
942 self.vlan_pcp = vlan_pcp
943 else:
944 self.vlan_pcp = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700945 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700946
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("!B", self.vlan_pcp))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700952 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700953 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 Laneb658ddd2013-03-12 10:15:10 -0700959 obj = set_vlan_pcp()
Dan Talaycof6202252013-07-02 01:00:29 -0700960 _type = reader.read("!H")[0]
961 assert(_type == 2)
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)
Dan Talaycof6202252013-07-02 01:00:29 -0700965 obj.vlan_pcp = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700966 reader.skip(3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700967 return obj
968
969 def __eq__(self, other):
970 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700971 if self.vlan_pcp != other.vlan_pcp: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700972 return True
973
Rich Laneb658ddd2013-03-12 10:15:10 -0700974 def pretty_print(self, q):
975 q.text("set_vlan_pcp {")
976 with q.group():
977 with q.indent(2):
978 q.breakable()
979 q.text("vlan_pcp = ");
980 q.text("%#x" % self.vlan_pcp)
Rich Laneb658ddd2013-03-12 10:15:10 -0700981 q.breakable()
982 q.text('}')
983
Rich Lane7dcdf022013-12-11 14:45:27 -0800984action.subtypes[2] = set_vlan_pcp
985
986class set_vlan_vid(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700987 type = 1
Rich Laneb658ddd2013-03-12 10:15:10 -0700988
Rich Lanec2ee4b82013-04-24 17:12:38 -0700989 def __init__(self, vlan_vid=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700990 if vlan_vid != None:
991 self.vlan_vid = vlan_vid
992 else:
993 self.vlan_vid = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700994 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700995
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("!H", self.vlan_vid))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001001 packed.append('\x00' * 2)
Rich Laneb658ddd2013-03-12 10:15:10 -07001002 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 Laneb658ddd2013-03-12 10:15:10 -07001008 obj = set_vlan_vid()
Dan Talaycof6202252013-07-02 01:00:29 -07001009 _type = reader.read("!H")[0]
1010 assert(_type == 1)
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)
Dan Talaycof6202252013-07-02 01:00:29 -07001014 obj.vlan_vid = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001015 reader.skip(2)
Rich Laneb658ddd2013-03-12 10:15:10 -07001016 return obj
1017
1018 def __eq__(self, other):
1019 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -07001020 if self.vlan_vid != other.vlan_vid: return False
Rich Laneb658ddd2013-03-12 10:15:10 -07001021 return True
1022
Rich Laneb658ddd2013-03-12 10:15:10 -07001023 def pretty_print(self, q):
1024 q.text("set_vlan_vid {")
1025 with q.group():
1026 with q.indent(2):
1027 q.breakable()
1028 q.text("vlan_vid = ");
1029 q.text("%#x" % self.vlan_vid)
Rich Laneb658ddd2013-03-12 10:15:10 -07001030 q.breakable()
1031 q.text('}')
1032
Rich Lane7dcdf022013-12-11 14:45:27 -08001033action.subtypes[1] = set_vlan_vid
1034
1035class strip_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -07001036 type = 3
Rich Laneb658ddd2013-03-12 10:15:10 -07001037
Rich Lanec2ee4b82013-04-24 17:12:38 -07001038 def __init__(self):
1039 return
Rich Laneb658ddd2013-03-12 10:15:10 -07001040
1041 def pack(self):
1042 packed = []
1043 packed.append(struct.pack("!H", self.type))
1044 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07001045 packed.append('\x00' * 4)
Rich Laneb658ddd2013-03-12 10:15:10 -07001046 length = sum([len(x) for x in packed])
1047 packed[1] = struct.pack("!H", length)
1048 return ''.join(packed)
1049
1050 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001051 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -07001052 obj = strip_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -07001053 _type = reader.read("!H")[0]
1054 assert(_type == 3)
1055 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001056 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001057 reader = orig_reader.slice(_len, 4)
Rich Lanec2ee4b82013-04-24 17:12:38 -07001058 reader.skip(4)
Rich Laneb658ddd2013-03-12 10:15:10 -07001059 return obj
1060
1061 def __eq__(self, other):
1062 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -07001063 return True
1064
Rich Laneb658ddd2013-03-12 10:15:10 -07001065 def pretty_print(self, q):
1066 q.text("strip_vlan {")
1067 with q.group():
1068 with q.indent(2):
1069 q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -07001070 q.breakable()
1071 q.text('}')
1072
Rich Lane7dcdf022013-12-11 14:45:27 -08001073action.subtypes[3] = strip_vlan
Rich Laneb658ddd2013-03-12 10:15:10 -07001074
Rich Laneb658ddd2013-03-12 10:15:10 -07001075