blob: 5e902460ba697b5669552d717b7b5089e83a0594 [file] [log] [blame]
Rich Lane2e079da2014-10-29 15:30:24 -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.
4# See the file LICENSE.pyloxi which should have been included in the source distribution
5
6# Automatically generated by LOXI from template module.py
7# Do not modify
8
9import struct
10import loxi
11import const
12import port_desc_prop
Rich Laneccd32ed2014-11-10 17:48:24 -080013import bsn_tlv
Rich Lane2e079da2014-10-29 15:30:24 -070014import meter_band
15import table_mod_prop
16import instruction
17import queue_desc_prop
18import oxm
19import bundle_prop
20import common
21import instruction_id
22import action
23import role_prop
24import message
25import queue_stats_prop
26import port_stats_prop
27import port_mod_prop
28import async_config_prop
29import action_id
30import util
31import loxi.generic_util
32
33class queue_desc_prop(loxi.OFObject):
34 subtypes = {}
35
36
37 def __init__(self, type=None):
38 if type != None:
39 self.type = type
40 else:
41 self.type = 0
42 return
43
44 def pack(self):
45 packed = []
46 packed.append(struct.pack("!H", self.type))
47 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
48 length = sum([len(x) for x in packed])
49 packed[1] = struct.pack("!H", length)
50 return ''.join(packed)
51
52 @staticmethod
53 def unpack(reader):
54 subtype, = reader.peek('!H', 0)
55 subclass = queue_desc_prop.subtypes.get(subtype)
56 if subclass:
57 return subclass.unpack(reader)
58
59 obj = queue_desc_prop()
60 obj.type = reader.read("!H")[0]
61 _length = reader.read("!H")[0]
62 orig_reader = reader
63 reader = orig_reader.slice(_length - (2 + 2))
64 return obj
65
66 def __eq__(self, other):
67 if type(self) != type(other): return False
68 if self.type != other.type: return False
69 return True
70
71 def pretty_print(self, q):
72 q.text("queue_desc_prop {")
73 with q.group():
74 with q.indent(2):
75 q.breakable()
76 q.breakable()
77 q.text('}')
78
79
80class experimenter(queue_desc_prop):
81 subtypes = {}
82
83 type = 65535
84
85 def __init__(self, experimenter=None, exp_type=None):
86 if experimenter != None:
87 self.experimenter = experimenter
88 else:
89 self.experimenter = 0
90 if exp_type != None:
91 self.exp_type = exp_type
92 else:
93 self.exp_type = 0
94 return
95
96 def pack(self):
97 packed = []
98 packed.append(struct.pack("!H", self.type))
99 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
100 packed.append(struct.pack("!L", self.experimenter))
101 packed.append(struct.pack("!L", self.exp_type))
102 length = sum([len(x) for x in packed])
103 packed[1] = struct.pack("!H", length)
104 return ''.join(packed)
105
106 @staticmethod
107 def unpack(reader):
108 subtype, = reader.peek('!L', 4)
109 subclass = experimenter.subtypes.get(subtype)
110 if subclass:
111 return subclass.unpack(reader)
112
113 obj = experimenter()
114 _type = reader.read("!H")[0]
115 assert(_type == 65535)
116 _length = reader.read("!H")[0]
117 orig_reader = reader
118 reader = orig_reader.slice(_length - (2 + 2))
119 obj.experimenter = reader.read("!L")[0]
120 obj.exp_type = reader.read("!L")[0]
121 return obj
122
123 def __eq__(self, other):
124 if type(self) != type(other): return False
125 if self.experimenter != other.experimenter: return False
126 if self.exp_type != other.exp_type: return False
127 return True
128
129 def pretty_print(self, q):
130 q.text("experimenter {")
131 with q.group():
132 with q.indent(2):
133 q.breakable()
134 q.text("exp_type = ");
135 q.text("%#x" % self.exp_type)
136 q.breakable()
137 q.text('}')
138
139queue_desc_prop.subtypes[65535] = experimenter
140
141class max_rate(queue_desc_prop):
142 type = 2
143
144 def __init__(self, rate=None):
145 if rate != None:
146 self.rate = rate
147 else:
148 self.rate = 0
149 return
150
151 def pack(self):
152 packed = []
153 packed.append(struct.pack("!H", self.type))
154 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
155 packed.append(struct.pack("!H", self.rate))
156 packed.append('\x00' * 2)
157 length = sum([len(x) for x in packed])
158 packed[1] = struct.pack("!H", length)
159 return ''.join(packed)
160
161 @staticmethod
162 def unpack(reader):
163 obj = max_rate()
164 _type = reader.read("!H")[0]
165 assert(_type == 2)
166 _length = reader.read("!H")[0]
167 orig_reader = reader
168 reader = orig_reader.slice(_length - (2 + 2))
169 obj.rate = reader.read("!H")[0]
170 reader.skip(2)
171 return obj
172
173 def __eq__(self, other):
174 if type(self) != type(other): return False
175 if self.rate != other.rate: return False
176 return True
177
178 def pretty_print(self, q):
179 q.text("max_rate {")
180 with q.group():
181 with q.indent(2):
182 q.breakable()
183 q.text("rate = ");
184 q.text("%#x" % self.rate)
185 q.breakable()
186 q.text('}')
187
188queue_desc_prop.subtypes[2] = max_rate
189
190class min_rate(queue_desc_prop):
191 type = 1
192
193 def __init__(self, rate=None):
194 if rate != None:
195 self.rate = rate
196 else:
197 self.rate = 0
198 return
199
200 def pack(self):
201 packed = []
202 packed.append(struct.pack("!H", self.type))
203 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
204 packed.append(struct.pack("!H", self.rate))
205 packed.append('\x00' * 2)
206 length = sum([len(x) for x in packed])
207 packed[1] = struct.pack("!H", length)
208 return ''.join(packed)
209
210 @staticmethod
211 def unpack(reader):
212 obj = min_rate()
213 _type = reader.read("!H")[0]
214 assert(_type == 1)
215 _length = reader.read("!H")[0]
216 orig_reader = reader
217 reader = orig_reader.slice(_length - (2 + 2))
218 obj.rate = reader.read("!H")[0]
219 reader.skip(2)
220 return obj
221
222 def __eq__(self, other):
223 if type(self) != type(other): return False
224 if self.rate != other.rate: return False
225 return True
226
227 def pretty_print(self, q):
228 q.text("min_rate {")
229 with q.group():
230 with q.indent(2):
231 q.breakable()
232 q.text("rate = ");
233 q.text("%#x" % self.rate)
234 q.breakable()
235 q.text('}')
236
237queue_desc_prop.subtypes[1] = min_rate
238
239