blob: 38b674ccd5af039acd4d0bb376e39f8248089c59 [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 common
13import action
Rich Laneb658ddd2013-03-12 10:15:10 -070014import util
Rich Lanec2ee4b82013-04-24 17:12:38 -070015import loxi.generic_util
Rich Laneb658ddd2013-03-12 10:15:10 -070016
Rich Lane7dcdf022013-12-11 14:45:27 -080017class action(loxi.OFObject):
18 subtypes = {}
Rich Laneb658ddd2013-03-12 10:15:10 -070019
Rich Lane7dcdf022013-12-11 14:45:27 -080020 @staticmethod
21 def unpack(reader):
22 subtype, = reader.peek('!H', 0)
23 try:
24 subclass = action.subtypes[subtype]
25 except KeyError:
26 raise loxi.ProtocolError("unknown action subtype %#x" % subtype)
27 return subclass.unpack(reader)
Rich Laneb658ddd2013-03-12 10:15:10 -070028
Rich Lane7dcdf022013-12-11 14:45:27 -080029
30class experimenter(action):
31 subtypes = {}
32
33 @staticmethod
34 def unpack(reader):
35 subtype, = reader.peek('!L', 4)
36 try:
37 subclass = experimenter.subtypes[subtype]
38 except KeyError:
39 raise loxi.ProtocolError("unknown experimenter action subtype %#x" % subtype)
40 return subclass.unpack(reader)
41
42action.subtypes[65535] = experimenter
43
44class bsn(experimenter):
45 subtypes = {}
46
47 @staticmethod
48 def unpack(reader):
49 subtype, = reader.peek('!L', 8)
50 try:
51 subclass = bsn.subtypes[subtype]
52 except KeyError:
53 raise loxi.ProtocolError("unknown bsn experimenter action subtype %#x" % subtype)
54 return subclass.unpack(reader)
55
56experimenter.subtypes[6035143] = bsn
57
58class bsn_mirror(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -070059 type = 65535
60 experimenter = 6035143
Rich Laneb658ddd2013-03-12 10:15:10 -070061 subtype = 1
62
Rich Lanec2ee4b82013-04-24 17:12:38 -070063 def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None):
Rich Laneb658ddd2013-03-12 10:15:10 -070064 if dest_port != None:
65 self.dest_port = dest_port
66 else:
67 self.dest_port = 0
68 if vlan_tag != None:
69 self.vlan_tag = vlan_tag
70 else:
71 self.vlan_tag = 0
72 if copy_stage != None:
73 self.copy_stage = copy_stage
74 else:
75 self.copy_stage = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -070076 return
Rich Laneb658ddd2013-03-12 10:15:10 -070077
78 def pack(self):
79 packed = []
80 packed.append(struct.pack("!H", self.type))
81 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
82 packed.append(struct.pack("!L", self.experimenter))
83 packed.append(struct.pack("!L", self.subtype))
84 packed.append(struct.pack("!L", self.dest_port))
85 packed.append(struct.pack("!L", self.vlan_tag))
86 packed.append(struct.pack("!B", self.copy_stage))
Rich Lanec2ee4b82013-04-24 17:12:38 -070087 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -070088 length = sum([len(x) for x in packed])
89 packed[1] = struct.pack("!H", length)
90 return ''.join(packed)
91
92 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -080093 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -070094 obj = bsn_mirror()
Dan Talaycof6202252013-07-02 01:00:29 -070095 _type = reader.read("!H")[0]
96 assert(_type == 65535)
97 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -080098 orig_reader = reader
99 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700100 _experimenter = reader.read("!L")[0]
101 assert(_experimenter == 6035143)
102 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700103 assert(_subtype == 1)
Dan Talaycof6202252013-07-02 01:00:29 -0700104 obj.dest_port = reader.read("!L")[0]
105 obj.vlan_tag = reader.read("!L")[0]
106 obj.copy_stage = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700107 reader.skip(3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700108 return obj
109
110 def __eq__(self, other):
111 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700112 if self.dest_port != other.dest_port: return False
113 if self.vlan_tag != other.vlan_tag: return False
114 if self.copy_stage != other.copy_stage: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700115 return True
116
Rich Laneb658ddd2013-03-12 10:15:10 -0700117 def pretty_print(self, q):
118 q.text("bsn_mirror {")
119 with q.group():
120 with q.indent(2):
121 q.breakable()
122 q.text("dest_port = ");
123 q.text("%#x" % self.dest_port)
124 q.text(","); q.breakable()
125 q.text("vlan_tag = ");
126 q.text("%#x" % self.vlan_tag)
127 q.text(","); q.breakable()
128 q.text("copy_stage = ");
129 q.text("%#x" % self.copy_stage)
Rich Laneb658ddd2013-03-12 10:15:10 -0700130 q.breakable()
131 q.text('}')
132
Rich Lane7dcdf022013-12-11 14:45:27 -0800133bsn.subtypes[1] = bsn_mirror
134
135class bsn_set_tunnel_dst(bsn):
Dan Talaycof6202252013-07-02 01:00:29 -0700136 type = 65535
137 experimenter = 6035143
Rich Laneb658ddd2013-03-12 10:15:10 -0700138 subtype = 2
139
140 def __init__(self, dst=None):
141 if dst != None:
142 self.dst = dst
143 else:
144 self.dst = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700145 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700146
147 def pack(self):
148 packed = []
149 packed.append(struct.pack("!H", self.type))
150 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
151 packed.append(struct.pack("!L", self.experimenter))
152 packed.append(struct.pack("!L", self.subtype))
153 packed.append(struct.pack("!L", self.dst))
154 length = sum([len(x) for x in packed])
155 packed[1] = struct.pack("!H", length)
156 return ''.join(packed)
157
158 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800159 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700160 obj = bsn_set_tunnel_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700161 _type = reader.read("!H")[0]
162 assert(_type == 65535)
163 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800164 orig_reader = reader
165 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700166 _experimenter = reader.read("!L")[0]
167 assert(_experimenter == 6035143)
168 _subtype = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700169 assert(_subtype == 2)
Dan Talaycof6202252013-07-02 01:00:29 -0700170 obj.dst = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -0700171 return obj
172
173 def __eq__(self, other):
174 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700175 if self.dst != other.dst: return False
176 return True
177
Rich Laneb658ddd2013-03-12 10:15:10 -0700178 def pretty_print(self, q):
179 q.text("bsn_set_tunnel_dst {")
180 with q.group():
181 with q.indent(2):
182 q.breakable()
183 q.text("dst = ");
184 q.text("%#x" % self.dst)
185 q.breakable()
186 q.text('}')
187
Rich Lane7dcdf022013-12-11 14:45:27 -0800188bsn.subtypes[2] = bsn_set_tunnel_dst
189
190class enqueue(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700191 type = 11
Rich Laneb658ddd2013-03-12 10:15:10 -0700192
Rich Lanec2ee4b82013-04-24 17:12:38 -0700193 def __init__(self, port=None, queue_id=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700194 if port != None:
195 self.port = port
196 else:
197 self.port = 0
Rich Laneb658ddd2013-03-12 10:15:10 -0700198 if queue_id != None:
199 self.queue_id = queue_id
200 else:
201 self.queue_id = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700202 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700203
204 def pack(self):
205 packed = []
206 packed.append(struct.pack("!H", self.type))
207 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700208 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700209 packed.append('\x00' * 6)
Rich Laneb658ddd2013-03-12 10:15:10 -0700210 packed.append(struct.pack("!L", self.queue_id))
211 length = sum([len(x) for x in packed])
212 packed[1] = struct.pack("!H", length)
213 return ''.join(packed)
214
215 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800216 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700217 obj = enqueue()
Dan Talaycof6202252013-07-02 01:00:29 -0700218 _type = reader.read("!H")[0]
219 assert(_type == 11)
220 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800221 orig_reader = reader
222 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700223 obj.port = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700224 reader.skip(6)
Dan Talaycof6202252013-07-02 01:00:29 -0700225 obj.queue_id = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -0700226 return obj
227
228 def __eq__(self, other):
229 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700230 if self.port != other.port: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700231 if self.queue_id != other.queue_id: return False
232 return True
233
Rich Laneb658ddd2013-03-12 10:15:10 -0700234 def pretty_print(self, q):
235 q.text("enqueue {")
236 with q.group():
237 with q.indent(2):
238 q.breakable()
239 q.text("port = ");
240 q.text(util.pretty_port(self.port))
241 q.text(","); q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -0700242 q.text("queue_id = ");
243 q.text("%#x" % self.queue_id)
244 q.breakable()
245 q.text('}')
246
Rich Lane7dcdf022013-12-11 14:45:27 -0800247action.subtypes[11] = enqueue
248
249class nicira(experimenter):
250 subtypes = {}
251
252 @staticmethod
253 def unpack(reader):
254 subtype, = reader.peek('!H', 8)
255 try:
256 subclass = nicira.subtypes[subtype]
257 except KeyError:
258 raise loxi.ProtocolError("unknown nicira experimenter action subtype %#x" % subtype)
259 return subclass.unpack(reader)
260
261experimenter.subtypes[8992] = nicira
262
263class nicira_dec_ttl(nicira):
Dan Talaycof6202252013-07-02 01:00:29 -0700264 type = 65535
265 experimenter = 8992
Rich Laneb658ddd2013-03-12 10:15:10 -0700266 subtype = 18
267
Rich Lanec2ee4b82013-04-24 17:12:38 -0700268 def __init__(self):
269 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700270
271 def pack(self):
272 packed = []
273 packed.append(struct.pack("!H", self.type))
274 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
275 packed.append(struct.pack("!L", self.experimenter))
276 packed.append(struct.pack("!H", self.subtype))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700277 packed.append('\x00' * 2)
278 packed.append('\x00' * 4)
Rich Laneb658ddd2013-03-12 10:15:10 -0700279 length = sum([len(x) for x in packed])
280 packed[1] = struct.pack("!H", length)
281 return ''.join(packed)
282
283 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800284 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700285 obj = nicira_dec_ttl()
Dan Talaycof6202252013-07-02 01:00:29 -0700286 _type = reader.read("!H")[0]
287 assert(_type == 65535)
288 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800289 orig_reader = reader
290 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700291 _experimenter = reader.read("!L")[0]
292 assert(_experimenter == 8992)
293 _subtype = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700294 assert(_subtype == 18)
295 reader.skip(2)
296 reader.skip(4)
Rich Laneb658ddd2013-03-12 10:15:10 -0700297 return obj
298
299 def __eq__(self, other):
300 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700301 return True
302
Rich Laneb658ddd2013-03-12 10:15:10 -0700303 def pretty_print(self, q):
304 q.text("nicira_dec_ttl {")
305 with q.group():
306 with q.indent(2):
307 q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -0700308 q.breakable()
309 q.text('}')
310
Rich Lane7dcdf022013-12-11 14:45:27 -0800311nicira.subtypes[18] = nicira_dec_ttl
312
313class output(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700314 type = 0
Rich Laneb658ddd2013-03-12 10:15:10 -0700315
316 def __init__(self, port=None, max_len=None):
317 if port != None:
318 self.port = port
319 else:
320 self.port = 0
321 if max_len != None:
322 self.max_len = max_len
323 else:
324 self.max_len = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700325 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700326
327 def pack(self):
328 packed = []
329 packed.append(struct.pack("!H", self.type))
330 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700331 packed.append(util.pack_port_no(self.port))
Rich Laneb658ddd2013-03-12 10:15:10 -0700332 packed.append(struct.pack("!H", self.max_len))
333 length = sum([len(x) for x in packed])
334 packed[1] = struct.pack("!H", length)
335 return ''.join(packed)
336
337 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800338 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700339 obj = output()
Dan Talaycof6202252013-07-02 01:00:29 -0700340 _type = reader.read("!H")[0]
341 assert(_type == 0)
342 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800343 orig_reader = reader
344 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700345 obj.port = util.unpack_port_no(reader)
346 obj.max_len = reader.read("!H")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -0700347 return obj
348
349 def __eq__(self, other):
350 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700351 if self.port != other.port: return False
352 if self.max_len != other.max_len: return False
353 return True
354
Rich Laneb658ddd2013-03-12 10:15:10 -0700355 def pretty_print(self, q):
356 q.text("output {")
357 with q.group():
358 with q.indent(2):
359 q.breakable()
360 q.text("port = ");
361 q.text(util.pretty_port(self.port))
362 q.text(","); q.breakable()
363 q.text("max_len = ");
364 q.text("%#x" % self.max_len)
365 q.breakable()
366 q.text('}')
367
Rich Lane7dcdf022013-12-11 14:45:27 -0800368action.subtypes[0] = output
369
370class set_dl_dst(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700371 type = 5
Rich Laneb658ddd2013-03-12 10:15:10 -0700372
Rich Lanec2ee4b82013-04-24 17:12:38 -0700373 def __init__(self, dl_addr=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700374 if dl_addr != None:
375 self.dl_addr = dl_addr
376 else:
377 self.dl_addr = [0,0,0,0,0,0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700378 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700379
380 def pack(self):
381 packed = []
382 packed.append(struct.pack("!H", self.type))
383 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
384 packed.append(struct.pack("!6B", *self.dl_addr))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700385 packed.append('\x00' * 6)
Rich Laneb658ddd2013-03-12 10:15:10 -0700386 length = sum([len(x) for x in packed])
387 packed[1] = struct.pack("!H", length)
388 return ''.join(packed)
389
390 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800391 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700392 obj = set_dl_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700393 _type = reader.read("!H")[0]
394 assert(_type == 5)
395 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800396 orig_reader = reader
397 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700398 obj.dl_addr = list(reader.read('!6B'))
399 reader.skip(6)
Rich Laneb658ddd2013-03-12 10:15:10 -0700400 return obj
401
402 def __eq__(self, other):
403 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700404 if self.dl_addr != other.dl_addr: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700405 return True
406
Rich Laneb658ddd2013-03-12 10:15:10 -0700407 def pretty_print(self, q):
408 q.text("set_dl_dst {")
409 with q.group():
410 with q.indent(2):
411 q.breakable()
412 q.text("dl_addr = ");
413 q.text(util.pretty_mac(self.dl_addr))
Rich Laneb658ddd2013-03-12 10:15:10 -0700414 q.breakable()
415 q.text('}')
416
Rich Lane7dcdf022013-12-11 14:45:27 -0800417action.subtypes[5] = set_dl_dst
418
419class set_dl_src(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700420 type = 4
Rich Laneb658ddd2013-03-12 10:15:10 -0700421
Rich Lanec2ee4b82013-04-24 17:12:38 -0700422 def __init__(self, dl_addr=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700423 if dl_addr != None:
424 self.dl_addr = dl_addr
425 else:
426 self.dl_addr = [0,0,0,0,0,0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700427 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700428
429 def pack(self):
430 packed = []
431 packed.append(struct.pack("!H", self.type))
432 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
433 packed.append(struct.pack("!6B", *self.dl_addr))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700434 packed.append('\x00' * 6)
Rich Laneb658ddd2013-03-12 10:15:10 -0700435 length = sum([len(x) for x in packed])
436 packed[1] = struct.pack("!H", length)
437 return ''.join(packed)
438
439 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800440 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700441 obj = set_dl_src()
Dan Talaycof6202252013-07-02 01:00:29 -0700442 _type = reader.read("!H")[0]
443 assert(_type == 4)
444 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800445 orig_reader = reader
446 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700447 obj.dl_addr = list(reader.read('!6B'))
448 reader.skip(6)
Rich Laneb658ddd2013-03-12 10:15:10 -0700449 return obj
450
451 def __eq__(self, other):
452 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700453 if self.dl_addr != other.dl_addr: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700454 return True
455
Rich Laneb658ddd2013-03-12 10:15:10 -0700456 def pretty_print(self, q):
457 q.text("set_dl_src {")
458 with q.group():
459 with q.indent(2):
460 q.breakable()
461 q.text("dl_addr = ");
462 q.text(util.pretty_mac(self.dl_addr))
Rich Laneb658ddd2013-03-12 10:15:10 -0700463 q.breakable()
464 q.text('}')
465
Rich Lane7dcdf022013-12-11 14:45:27 -0800466action.subtypes[4] = set_dl_src
467
468class set_nw_dst(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700469 type = 7
Rich Laneb658ddd2013-03-12 10:15:10 -0700470
471 def __init__(self, nw_addr=None):
472 if nw_addr != None:
473 self.nw_addr = nw_addr
474 else:
475 self.nw_addr = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700476 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700477
478 def pack(self):
479 packed = []
480 packed.append(struct.pack("!H", self.type))
481 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
482 packed.append(struct.pack("!L", self.nw_addr))
483 length = sum([len(x) for x in packed])
484 packed[1] = struct.pack("!H", length)
485 return ''.join(packed)
486
487 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800488 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700489 obj = set_nw_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700490 _type = reader.read("!H")[0]
491 assert(_type == 7)
492 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800493 orig_reader = reader
494 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700495 obj.nw_addr = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -0700496 return obj
497
498 def __eq__(self, other):
499 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700500 if self.nw_addr != other.nw_addr: return False
501 return True
502
Rich Laneb658ddd2013-03-12 10:15:10 -0700503 def pretty_print(self, q):
504 q.text("set_nw_dst {")
505 with q.group():
506 with q.indent(2):
507 q.breakable()
508 q.text("nw_addr = ");
509 q.text("%#x" % self.nw_addr)
510 q.breakable()
511 q.text('}')
512
Rich Lane7dcdf022013-12-11 14:45:27 -0800513action.subtypes[7] = set_nw_dst
514
515class set_nw_src(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700516 type = 6
Rich Laneb658ddd2013-03-12 10:15:10 -0700517
518 def __init__(self, nw_addr=None):
519 if nw_addr != None:
520 self.nw_addr = nw_addr
521 else:
522 self.nw_addr = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700523 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700524
525 def pack(self):
526 packed = []
527 packed.append(struct.pack("!H", self.type))
528 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
529 packed.append(struct.pack("!L", self.nw_addr))
530 length = sum([len(x) for x in packed])
531 packed[1] = struct.pack("!H", length)
532 return ''.join(packed)
533
534 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800535 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700536 obj = set_nw_src()
Dan Talaycof6202252013-07-02 01:00:29 -0700537 _type = reader.read("!H")[0]
538 assert(_type == 6)
539 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800540 orig_reader = reader
541 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700542 obj.nw_addr = reader.read("!L")[0]
Rich Laneb658ddd2013-03-12 10:15:10 -0700543 return obj
544
545 def __eq__(self, other):
546 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700547 if self.nw_addr != other.nw_addr: return False
548 return True
549
Rich Laneb658ddd2013-03-12 10:15:10 -0700550 def pretty_print(self, q):
551 q.text("set_nw_src {")
552 with q.group():
553 with q.indent(2):
554 q.breakable()
555 q.text("nw_addr = ");
556 q.text("%#x" % self.nw_addr)
557 q.breakable()
558 q.text('}')
559
Rich Lane7dcdf022013-12-11 14:45:27 -0800560action.subtypes[6] = set_nw_src
561
562class set_nw_tos(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700563 type = 8
Rich Laneb658ddd2013-03-12 10:15:10 -0700564
Rich Lanec2ee4b82013-04-24 17:12:38 -0700565 def __init__(self, nw_tos=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700566 if nw_tos != None:
567 self.nw_tos = nw_tos
568 else:
569 self.nw_tos = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700570 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700571
572 def pack(self):
573 packed = []
574 packed.append(struct.pack("!H", self.type))
575 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
576 packed.append(struct.pack("!B", self.nw_tos))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700577 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700578 length = sum([len(x) for x in packed])
579 packed[1] = struct.pack("!H", length)
580 return ''.join(packed)
581
582 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800583 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700584 obj = set_nw_tos()
Dan Talaycof6202252013-07-02 01:00:29 -0700585 _type = reader.read("!H")[0]
586 assert(_type == 8)
587 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800588 orig_reader = reader
589 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700590 obj.nw_tos = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700591 reader.skip(3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700592 return obj
593
594 def __eq__(self, other):
595 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700596 if self.nw_tos != other.nw_tos: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700597 return True
598
Rich Laneb658ddd2013-03-12 10:15:10 -0700599 def pretty_print(self, q):
600 q.text("set_nw_tos {")
601 with q.group():
602 with q.indent(2):
603 q.breakable()
604 q.text("nw_tos = ");
605 q.text("%#x" % self.nw_tos)
Rich Laneb658ddd2013-03-12 10:15:10 -0700606 q.breakable()
607 q.text('}')
608
Rich Lane7dcdf022013-12-11 14:45:27 -0800609action.subtypes[8] = set_nw_tos
610
611class set_tp_dst(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700612 type = 10
Rich Laneb658ddd2013-03-12 10:15:10 -0700613
Rich Lanec2ee4b82013-04-24 17:12:38 -0700614 def __init__(self, tp_port=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700615 if tp_port != None:
616 self.tp_port = tp_port
617 else:
618 self.tp_port = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700619 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700620
621 def pack(self):
622 packed = []
623 packed.append(struct.pack("!H", self.type))
624 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
625 packed.append(struct.pack("!H", self.tp_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700626 packed.append('\x00' * 2)
Rich Laneb658ddd2013-03-12 10:15:10 -0700627 length = sum([len(x) for x in packed])
628 packed[1] = struct.pack("!H", length)
629 return ''.join(packed)
630
631 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800632 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700633 obj = set_tp_dst()
Dan Talaycof6202252013-07-02 01:00:29 -0700634 _type = reader.read("!H")[0]
635 assert(_type == 10)
636 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800637 orig_reader = reader
638 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700639 obj.tp_port = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700640 reader.skip(2)
Rich Laneb658ddd2013-03-12 10:15:10 -0700641 return obj
642
643 def __eq__(self, other):
644 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700645 if self.tp_port != other.tp_port: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700646 return True
647
Rich Laneb658ddd2013-03-12 10:15:10 -0700648 def pretty_print(self, q):
649 q.text("set_tp_dst {")
650 with q.group():
651 with q.indent(2):
652 q.breakable()
653 q.text("tp_port = ");
654 q.text("%#x" % self.tp_port)
Rich Laneb658ddd2013-03-12 10:15:10 -0700655 q.breakable()
656 q.text('}')
657
Rich Lane7dcdf022013-12-11 14:45:27 -0800658action.subtypes[10] = set_tp_dst
659
660class set_tp_src(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700661 type = 9
Rich Laneb658ddd2013-03-12 10:15:10 -0700662
Rich Lanec2ee4b82013-04-24 17:12:38 -0700663 def __init__(self, tp_port=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700664 if tp_port != None:
665 self.tp_port = tp_port
666 else:
667 self.tp_port = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700668 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700669
670 def pack(self):
671 packed = []
672 packed.append(struct.pack("!H", self.type))
673 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
674 packed.append(struct.pack("!H", self.tp_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700675 packed.append('\x00' * 2)
Rich Laneb658ddd2013-03-12 10:15:10 -0700676 length = sum([len(x) for x in packed])
677 packed[1] = struct.pack("!H", length)
678 return ''.join(packed)
679
680 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800681 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700682 obj = set_tp_src()
Dan Talaycof6202252013-07-02 01:00:29 -0700683 _type = reader.read("!H")[0]
684 assert(_type == 9)
685 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800686 orig_reader = reader
687 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700688 obj.tp_port = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700689 reader.skip(2)
Rich Laneb658ddd2013-03-12 10:15:10 -0700690 return obj
691
692 def __eq__(self, other):
693 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700694 if self.tp_port != other.tp_port: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700695 return True
696
Rich Laneb658ddd2013-03-12 10:15:10 -0700697 def pretty_print(self, q):
698 q.text("set_tp_src {")
699 with q.group():
700 with q.indent(2):
701 q.breakable()
702 q.text("tp_port = ");
703 q.text("%#x" % self.tp_port)
Rich Laneb658ddd2013-03-12 10:15:10 -0700704 q.breakable()
705 q.text('}')
706
Rich Lane7dcdf022013-12-11 14:45:27 -0800707action.subtypes[9] = set_tp_src
708
709class set_vlan_pcp(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700710 type = 2
Rich Laneb658ddd2013-03-12 10:15:10 -0700711
Rich Lanec2ee4b82013-04-24 17:12:38 -0700712 def __init__(self, vlan_pcp=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700713 if vlan_pcp != None:
714 self.vlan_pcp = vlan_pcp
715 else:
716 self.vlan_pcp = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700717 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700718
719 def pack(self):
720 packed = []
721 packed.append(struct.pack("!H", self.type))
722 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
723 packed.append(struct.pack("!B", self.vlan_pcp))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700724 packed.append('\x00' * 3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700725 length = sum([len(x) for x in packed])
726 packed[1] = struct.pack("!H", length)
727 return ''.join(packed)
728
729 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800730 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700731 obj = set_vlan_pcp()
Dan Talaycof6202252013-07-02 01:00:29 -0700732 _type = reader.read("!H")[0]
733 assert(_type == 2)
734 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800735 orig_reader = reader
736 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700737 obj.vlan_pcp = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700738 reader.skip(3)
Rich Laneb658ddd2013-03-12 10:15:10 -0700739 return obj
740
741 def __eq__(self, other):
742 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700743 if self.vlan_pcp != other.vlan_pcp: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700744 return True
745
Rich Laneb658ddd2013-03-12 10:15:10 -0700746 def pretty_print(self, q):
747 q.text("set_vlan_pcp {")
748 with q.group():
749 with q.indent(2):
750 q.breakable()
751 q.text("vlan_pcp = ");
752 q.text("%#x" % self.vlan_pcp)
Rich Laneb658ddd2013-03-12 10:15:10 -0700753 q.breakable()
754 q.text('}')
755
Rich Lane7dcdf022013-12-11 14:45:27 -0800756action.subtypes[2] = set_vlan_pcp
757
758class set_vlan_vid(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700759 type = 1
Rich Laneb658ddd2013-03-12 10:15:10 -0700760
Rich Lanec2ee4b82013-04-24 17:12:38 -0700761 def __init__(self, vlan_vid=None):
Rich Laneb658ddd2013-03-12 10:15:10 -0700762 if vlan_vid != None:
763 self.vlan_vid = vlan_vid
764 else:
765 self.vlan_vid = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700766 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700767
768 def pack(self):
769 packed = []
770 packed.append(struct.pack("!H", self.type))
771 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
772 packed.append(struct.pack("!H", self.vlan_vid))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700773 packed.append('\x00' * 2)
Rich Laneb658ddd2013-03-12 10:15:10 -0700774 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_vlan_vid()
Dan Talaycof6202252013-07-02 01:00:29 -0700781 _type = reader.read("!H")[0]
782 assert(_type == 1)
783 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800784 orig_reader = reader
785 reader = orig_reader.slice(_len - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700786 obj.vlan_vid = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700787 reader.skip(2)
Rich Laneb658ddd2013-03-12 10:15:10 -0700788 return obj
789
790 def __eq__(self, other):
791 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700792 if self.vlan_vid != other.vlan_vid: return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700793 return True
794
Rich Laneb658ddd2013-03-12 10:15:10 -0700795 def pretty_print(self, q):
796 q.text("set_vlan_vid {")
797 with q.group():
798 with q.indent(2):
799 q.breakable()
800 q.text("vlan_vid = ");
801 q.text("%#x" % self.vlan_vid)
Rich Laneb658ddd2013-03-12 10:15:10 -0700802 q.breakable()
803 q.text('}')
804
Rich Lane7dcdf022013-12-11 14:45:27 -0800805action.subtypes[1] = set_vlan_vid
806
807class strip_vlan(action):
Dan Talaycof6202252013-07-02 01:00:29 -0700808 type = 3
Rich Laneb658ddd2013-03-12 10:15:10 -0700809
Rich Lanec2ee4b82013-04-24 17:12:38 -0700810 def __init__(self):
811 return
Rich Laneb658ddd2013-03-12 10:15:10 -0700812
813 def pack(self):
814 packed = []
815 packed.append(struct.pack("!H", self.type))
816 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
Rich Lanec2ee4b82013-04-24 17:12:38 -0700817 packed.append('\x00' * 4)
Rich Laneb658ddd2013-03-12 10:15:10 -0700818 length = sum([len(x) for x in packed])
819 packed[1] = struct.pack("!H", length)
820 return ''.join(packed)
821
822 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800823 def unpack(reader):
Rich Laneb658ddd2013-03-12 10:15:10 -0700824 obj = strip_vlan()
Dan Talaycof6202252013-07-02 01:00:29 -0700825 _type = reader.read("!H")[0]
826 assert(_type == 3)
827 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800828 orig_reader = reader
829 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700830 reader.skip(4)
Rich Laneb658ddd2013-03-12 10:15:10 -0700831 return obj
832
833 def __eq__(self, other):
834 if type(self) != type(other): return False
Rich Laneb658ddd2013-03-12 10:15:10 -0700835 return True
836
Rich Laneb658ddd2013-03-12 10:15:10 -0700837 def pretty_print(self, q):
838 q.text("strip_vlan {")
839 with q.group():
840 with q.indent(2):
841 q.breakable()
Rich Laneb658ddd2013-03-12 10:15:10 -0700842 q.breakable()
843 q.text('}')
844
Rich Lane7dcdf022013-12-11 14:45:27 -0800845action.subtypes[3] = strip_vlan
Rich Laneb658ddd2013-03-12 10:15:10 -0700846
Rich Laneb658ddd2013-03-12 10:15:10 -0700847