blob: 0bceb50d6ad5de3ffaf665fb391cf2377772b3e4 [file] [log] [blame]
Stephane Barbarie6e1bd502018-11-05 22:44:45 -05001# Copyright 2017-present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14# Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
15# Copyright (c) 2011, 2012 Open Networking Foundation
16# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
17# See the file LICENSE.pyloxi which should have been included in the source distribution
18
19# Automatically generated by LOXI from template module.py
20# Do not modify
21
22import struct
23import loxi
24import util
25import loxi.generic_util
26
27import sys
28ofp = sys.modules['loxi.of14']
29
30class queue_desc_prop(loxi.OFObject):
31 subtypes = {}
32
33
34 def __init__(self, type=None):
35 if type != None:
36 self.type = type
37 else:
38 self.type = 0
39 return
40
41 def pack(self):
42 packed = []
43 packed.append(struct.pack("!H", self.type))
44 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
45 length = sum([len(x) for x in packed])
46 packed[1] = struct.pack("!H", length)
47 return ''.join(packed)
48
49 @staticmethod
50 def unpack(reader):
51 subtype, = reader.peek('!H', 0)
52 subclass = queue_desc_prop.subtypes.get(subtype)
53 if subclass:
54 return subclass.unpack(reader)
55
56 obj = queue_desc_prop()
57 obj.type = reader.read("!H")[0]
58 _length = reader.read("!H")[0]
59 orig_reader = reader
60 reader = orig_reader.slice(_length, 4)
61 return obj
62
63 def __eq__(self, other):
64 if type(self) != type(other): return False
65 if self.type != other.type: return False
66 return True
67
68 def pretty_print(self, q):
69 q.text("queue_desc_prop {")
70 with q.group():
71 with q.indent(2):
72 q.breakable()
73 q.breakable()
74 q.text('}')
75
76
77class experimenter(queue_desc_prop):
78 subtypes = {}
79
80 type = 65535
81
82 def __init__(self, experimenter=None, exp_type=None):
83 if experimenter != None:
84 self.experimenter = experimenter
85 else:
86 self.experimenter = 0
87 if exp_type != None:
88 self.exp_type = exp_type
89 else:
90 self.exp_type = 0
91 return
92
93 def pack(self):
94 packed = []
95 packed.append(struct.pack("!H", self.type))
96 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
97 packed.append(struct.pack("!L", self.experimenter))
98 packed.append(struct.pack("!L", self.exp_type))
99 length = sum([len(x) for x in packed])
100 packed[1] = struct.pack("!H", length)
101 return ''.join(packed)
102
103 @staticmethod
104 def unpack(reader):
105 subtype, = reader.peek('!L', 4)
106 subclass = experimenter.subtypes.get(subtype)
107 if subclass:
108 return subclass.unpack(reader)
109
110 obj = experimenter()
111 _type = reader.read("!H")[0]
112 assert(_type == 65535)
113 _length = reader.read("!H")[0]
114 orig_reader = reader
115 reader = orig_reader.slice(_length, 4)
116 obj.experimenter = reader.read("!L")[0]
117 obj.exp_type = reader.read("!L")[0]
118 return obj
119
120 def __eq__(self, other):
121 if type(self) != type(other): return False
122 if self.experimenter != other.experimenter: return False
123 if self.exp_type != other.exp_type: return False
124 return True
125
126 def pretty_print(self, q):
127 q.text("experimenter {")
128 with q.group():
129 with q.indent(2):
130 q.breakable()
131 q.text("exp_type = ");
132 q.text("%#x" % self.exp_type)
133 q.breakable()
134 q.text('}')
135
136queue_desc_prop.subtypes[65535] = experimenter
137
138class max_rate(queue_desc_prop):
139 type = 2
140
141 def __init__(self, rate=None):
142 if rate != None:
143 self.rate = rate
144 else:
145 self.rate = 0
146 return
147
148 def pack(self):
149 packed = []
150 packed.append(struct.pack("!H", self.type))
151 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
152 packed.append(struct.pack("!H", self.rate))
153 packed.append('\x00' * 2)
154 length = sum([len(x) for x in packed])
155 packed[1] = struct.pack("!H", length)
156 return ''.join(packed)
157
158 @staticmethod
159 def unpack(reader):
160 obj = max_rate()
161 _type = reader.read("!H")[0]
162 assert(_type == 2)
163 _length = reader.read("!H")[0]
164 orig_reader = reader
165 reader = orig_reader.slice(_length, 4)
166 obj.rate = reader.read("!H")[0]
167 reader.skip(2)
168 return obj
169
170 def __eq__(self, other):
171 if type(self) != type(other): return False
172 if self.rate != other.rate: return False
173 return True
174
175 def pretty_print(self, q):
176 q.text("max_rate {")
177 with q.group():
178 with q.indent(2):
179 q.breakable()
180 q.text("rate = ");
181 q.text("%#x" % self.rate)
182 q.breakable()
183 q.text('}')
184
185queue_desc_prop.subtypes[2] = max_rate
186
187class min_rate(queue_desc_prop):
188 type = 1
189
190 def __init__(self, rate=None):
191 if rate != None:
192 self.rate = rate
193 else:
194 self.rate = 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 length at index 1
201 packed.append(struct.pack("!H", self.rate))
202 packed.append('\x00' * 2)
203 length = sum([len(x) for x in packed])
204 packed[1] = struct.pack("!H", length)
205 return ''.join(packed)
206
207 @staticmethod
208 def unpack(reader):
209 obj = min_rate()
210 _type = reader.read("!H")[0]
211 assert(_type == 1)
212 _length = reader.read("!H")[0]
213 orig_reader = reader
214 reader = orig_reader.slice(_length, 4)
215 obj.rate = reader.read("!H")[0]
216 reader.skip(2)
217 return obj
218
219 def __eq__(self, other):
220 if type(self) != type(other): return False
221 if self.rate != other.rate: return False
222 return True
223
224 def pretty_print(self, q):
225 q.text("min_rate {")
226 with q.group():
227 with q.indent(2):
228 q.breakable()
229 q.text("rate = ");
230 q.text("%#x" % self.rate)
231 q.breakable()
232 q.text('}')
233
234queue_desc_prop.subtypes[1] = min_rate
235
236