blob: d21b7d068c856d16fd210cf413e9b87b38503a0d [file] [log] [blame]
Rich Laneca3da272013-05-05 09:07:33 -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 Laneca3da272013-05-05 09:07:33 -07005
Rich Lane7dcdf022013-12-11 14:45:27 -08006# Automatically generated by LOXI from template module.py
Rich Laneca3da272013-05-05 09:07:33 -07007# Do not modify
8
9import struct
Rich Lane7dcdf022013-12-11 14:45:27 -080010import loxi
Rich Laneca3da272013-05-05 09:07:33 -070011import util
12import loxi.generic_util
Rich Laneca3da272013-05-05 09:07:33 -070013
Rich Lanee2567702015-01-26 15:04:35 -080014import sys
15ofp = sys.modules['loxi.of13']
16
Rich Lane7dcdf022013-12-11 14:45:27 -080017class meter_band(loxi.OFObject):
18 subtypes = {}
Rich Laneca3da272013-05-05 09:07:33 -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 length = sum([len(x) for x in packed])
33 packed[1] = struct.pack("!H", length)
34 return ''.join(packed)
35
Rich Lane7dcdf022013-12-11 14:45:27 -080036 @staticmethod
37 def unpack(reader):
38 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -080039 subclass = meter_band.subtypes.get(subtype)
40 if subclass:
41 return subclass.unpack(reader)
42
43 obj = meter_band()
44 obj.type = reader.read("!H")[0]
45 _len = reader.read("!H")[0]
46 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -080047 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -080048 return obj
49
50 def __eq__(self, other):
51 if type(self) != type(other): return False
52 if self.type != other.type: return False
53 return True
54
55 def pretty_print(self, q):
56 q.text("meter_band {")
57 with q.group():
58 with q.indent(2):
59 q.breakable()
60 q.breakable()
61 q.text('}')
Rich Laneca3da272013-05-05 09:07:33 -070062
Rich Lane7dcdf022013-12-11 14:45:27 -080063
64class drop(meter_band):
Dan Talaycof6202252013-07-02 01:00:29 -070065 type = 1
Rich Laneca3da272013-05-05 09:07:33 -070066
67 def __init__(self, rate=None, burst_size=None):
68 if rate != None:
69 self.rate = rate
70 else:
71 self.rate = 0
72 if burst_size != None:
73 self.burst_size = burst_size
74 else:
75 self.burst_size = 0
76 return
77
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.rate))
83 packed.append(struct.pack("!L", self.burst_size))
84 packed.append('\x00' * 4)
85 length = sum([len(x) for x in packed])
86 packed[1] = struct.pack("!H", length)
87 return ''.join(packed)
88
89 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -080090 def unpack(reader):
Rich Laneca3da272013-05-05 09:07:33 -070091 obj = drop()
Dan Talaycof6202252013-07-02 01:00:29 -070092 _type = reader.read("!H")[0]
93 assert(_type == 1)
94 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -080095 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -080096 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -070097 obj.rate = reader.read("!L")[0]
98 obj.burst_size = reader.read("!L")[0]
Rich Laneca3da272013-05-05 09:07:33 -070099 reader.skip(4)
100 return obj
101
102 def __eq__(self, other):
103 if type(self) != type(other): return False
104 if self.rate != other.rate: return False
105 if self.burst_size != other.burst_size: return False
106 return True
107
Rich Laneca3da272013-05-05 09:07:33 -0700108 def pretty_print(self, q):
109 q.text("drop {")
110 with q.group():
111 with q.indent(2):
112 q.breakable()
113 q.text("rate = ");
114 q.text("%#x" % self.rate)
115 q.text(","); q.breakable()
116 q.text("burst_size = ");
117 q.text("%#x" % self.burst_size)
118 q.breakable()
119 q.text('}')
120
Rich Lane7dcdf022013-12-11 14:45:27 -0800121meter_band.subtypes[1] = drop
122
123class dscp_remark(meter_band):
Dan Talaycof6202252013-07-02 01:00:29 -0700124 type = 2
Rich Laneca3da272013-05-05 09:07:33 -0700125
126 def __init__(self, rate=None, burst_size=None, prec_level=None):
127 if rate != None:
128 self.rate = rate
129 else:
130 self.rate = 0
131 if burst_size != None:
132 self.burst_size = burst_size
133 else:
134 self.burst_size = 0
135 if prec_level != None:
136 self.prec_level = prec_level
137 else:
138 self.prec_level = 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.rate))
146 packed.append(struct.pack("!L", self.burst_size))
147 packed.append(struct.pack("!B", self.prec_level))
148 packed.append('\x00' * 3)
149 length = sum([len(x) for x in packed])
150 packed[1] = struct.pack("!H", length)
151 return ''.join(packed)
152
153 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800154 def unpack(reader):
Rich Laneca3da272013-05-05 09:07:33 -0700155 obj = dscp_remark()
Dan Talaycof6202252013-07-02 01:00:29 -0700156 _type = reader.read("!H")[0]
157 assert(_type == 2)
158 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800159 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800160 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700161 obj.rate = reader.read("!L")[0]
162 obj.burst_size = reader.read("!L")[0]
163 obj.prec_level = reader.read("!B")[0]
Rich Laneca3da272013-05-05 09:07:33 -0700164 reader.skip(3)
165 return obj
166
167 def __eq__(self, other):
168 if type(self) != type(other): return False
169 if self.rate != other.rate: return False
170 if self.burst_size != other.burst_size: return False
171 if self.prec_level != other.prec_level: return False
172 return True
173
Rich Laneca3da272013-05-05 09:07:33 -0700174 def pretty_print(self, q):
175 q.text("dscp_remark {")
176 with q.group():
177 with q.indent(2):
178 q.breakable()
179 q.text("rate = ");
180 q.text("%#x" % self.rate)
181 q.text(","); q.breakable()
182 q.text("burst_size = ");
183 q.text("%#x" % self.burst_size)
184 q.text(","); q.breakable()
185 q.text("prec_level = ");
186 q.text("%#x" % self.prec_level)
187 q.breakable()
188 q.text('}')
189
Rich Lane7dcdf022013-12-11 14:45:27 -0800190meter_band.subtypes[2] = dscp_remark
191
192class experimenter(meter_band):
Dan Talaycof6202252013-07-02 01:00:29 -0700193 type = 65535
Rich Laneca3da272013-05-05 09:07:33 -0700194
195 def __init__(self, rate=None, burst_size=None, experimenter=None):
196 if rate != None:
197 self.rate = rate
198 else:
199 self.rate = 0
200 if burst_size != None:
201 self.burst_size = burst_size
202 else:
203 self.burst_size = 0
204 if experimenter != None:
205 self.experimenter = experimenter
206 else:
207 self.experimenter = 0
208 return
209
210 def pack(self):
211 packed = []
212 packed.append(struct.pack("!H", self.type))
213 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
214 packed.append(struct.pack("!L", self.rate))
215 packed.append(struct.pack("!L", self.burst_size))
216 packed.append(struct.pack("!L", self.experimenter))
217 length = sum([len(x) for x in packed])
218 packed[1] = struct.pack("!H", length)
219 return ''.join(packed)
220
221 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800222 def unpack(reader):
Rich Laneca3da272013-05-05 09:07:33 -0700223 obj = experimenter()
Dan Talaycof6202252013-07-02 01:00:29 -0700224 _type = reader.read("!H")[0]
225 assert(_type == 65535)
226 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800227 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800228 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700229 obj.rate = reader.read("!L")[0]
230 obj.burst_size = reader.read("!L")[0]
231 obj.experimenter = reader.read("!L")[0]
Rich Laneca3da272013-05-05 09:07:33 -0700232 return obj
233
234 def __eq__(self, other):
235 if type(self) != type(other): return False
236 if self.rate != other.rate: return False
237 if self.burst_size != other.burst_size: return False
238 if self.experimenter != other.experimenter: return False
239 return True
240
Rich Laneca3da272013-05-05 09:07:33 -0700241 def pretty_print(self, q):
242 q.text("experimenter {")
243 with q.group():
244 with q.indent(2):
245 q.breakable()
246 q.text("rate = ");
247 q.text("%#x" % self.rate)
248 q.text(","); q.breakable()
249 q.text("burst_size = ");
250 q.text("%#x" % self.burst_size)
251 q.text(","); q.breakable()
252 q.text("experimenter = ");
253 q.text("%#x" % self.experimenter)
254 q.breakable()
255 q.text('}')
256
Rich Lane7dcdf022013-12-11 14:45:27 -0800257meter_band.subtypes[65535] = experimenter
Rich Laneca3da272013-05-05 09:07:33 -0700258
Rich Lane7dcdf022013-12-11 14:45:27 -0800259