blob: 67c914d0a9c07677303953f017dfdaf068c412f0 [file] [log] [blame]
Andreas Wundsam951ada32013-08-01 22:05:38 -07001package org.openflow.protocol.ver10;
Andreas Wundsam40e14f72013-05-06 14:49:08 -07002
3import java.util.List;
4
5import org.jboss.netty.buffer.ChannelBuffer;
Andreas Wundsam27303462013-07-16 12:52:35 -07006import org.openflow.protocol.OFBsnInterface;
7import org.openflow.protocol.OFBsnVportQInQ;
8import org.openflow.protocol.OFBsnVportQInQT;
9import org.openflow.protocol.OFBucket;
10import org.openflow.protocol.OFFlowStatsEntry;
11import org.openflow.protocol.OFGroupDescStatsEntry;
12import org.openflow.protocol.OFGroupStatsEntry;
13import org.openflow.protocol.OFHelloElem;
14import org.openflow.protocol.OFMeterFeatures;
15import org.openflow.protocol.OFMeterStats;
Andreas Wundsam951ada32013-08-01 22:05:38 -070016import org.openflow.protocol.OFObject;
Andreas Wundsam27303462013-07-16 12:52:35 -070017import org.openflow.protocol.OFPacketQueue;
18import org.openflow.protocol.OFPortStatsEntry;
19import org.openflow.protocol.OFQueueStatsEntry;
20import org.openflow.protocol.OFTableFeature;
21import org.openflow.protocol.OFTableFeatures;
22import org.openflow.protocol.OFTableStatsEntry;
Andreas Wundsam951ada32013-08-01 22:05:38 -070023import org.openflow.protocol.Wildcards;
Andreas Wundsam27303462013-07-16 12:52:35 -070024import org.openflow.protocol.action.OFAction;
25import org.openflow.protocol.instruction.OFInstruction;
Andreas Wundsam40e14f72013-05-06 14:49:08 -070026import org.openflow.protocol.match.Match;
Andreas Wundsam5408fb92013-07-30 12:26:04 -070027import org.openflow.protocol.meterband.OFMeterBand;
Andreas Wundsam951ada32013-08-01 22:05:38 -070028import org.openflow.protocol.oxm.OFOxm;
Andreas Wundsam40e14f72013-05-06 14:49:08 -070029import org.openflow.types.OFFlowModCmd;
30import org.openflow.types.OFHelloElement;
Andreas Wundsam40e14f72013-05-06 14:49:08 -070031import org.openflow.types.OFPhysicalPort;
32
Andreas Wundsam27303462013-07-16 12:52:35 -070033import com.google.common.base.Charsets;
34
Andreas Wundsam40e14f72013-05-06 14:49:08 -070035/**
36 * Collection of helper functions for reading and writing into ChannelBuffers
37 *
38 * @author capveg
39 */
40
Andreas Wundsam951ada32013-08-01 22:05:38 -070041public class ChannelUtilsVer10 {
Andreas Wundsam40e14f72013-05-06 14:49:08 -070042
43 static public byte[] readBytes(final ChannelBuffer bb, final int length) {
44 byte byteArray[] = new byte[length];
45 bb.readBytes(byteArray);
46 return byteArray;
47 }
48
Andreas Wundsam5408fb92013-07-30 12:26:04 -070049 static public void writeBytes(final ChannelBuffer bb,
50 final byte byteArray[]) {
Andreas Wundsam40e14f72013-05-06 14:49:08 -070051 bb.writeBytes(byteArray);
52 }
53
Andreas Wundsam5408fb92013-07-30 12:26:04 -070054 public static List<OFPhysicalPort> readPhysicalPortList(
55 final ChannelBuffer bb, final int i) {
Andreas Wundsam40e14f72013-05-06 14:49:08 -070056 // TODO Auto-generated method stub
57 return null;
58 }
59
Andreas Wundsam5408fb92013-07-30 12:26:04 -070060 public static List<OFInstruction> readInstructionsList(
61 final ChannelBuffer bb, final int i) {
Andreas Wundsam40e14f72013-05-06 14:49:08 -070062 // TODO Auto-generated method stub
63 return null;
64 }
65
66 public static Match readOFMatch(final ChannelBuffer bb) {
67 // TODO Auto-generated method stub
68 return null;
69 }
70
71 public static OFFlowModCmd readOFFlowModCmd(final ChannelBuffer bb) {
72 // TODO Auto-generated method stub
73 return null;
74 }
75
Andreas Wundsam5408fb92013-07-30 12:26:04 -070076 public static List<OFAction> readActionsList(final ChannelBuffer bb,
77 final int i) {
Andreas Wundsam40e14f72013-05-06 14:49:08 -070078 // TODO Auto-generated method stub
79 return null;
80 }
81
Andreas Wundsam5408fb92013-07-30 12:26:04 -070082 public static List<OFBsnInterface> readBsnInterfaceList(
Andreas Wundsam951ada32013-08-01 22:05:38 -070083 final ChannelBuffer bb, int length) {
Andreas Wundsam40e14f72013-05-06 14:49:08 -070084 // TODO Auto-generated method stub
85 return null;
86 }
87
88 public static OFPhysicalPort readPhysicalPort(final ChannelBuffer bb) {
89 // TODO Auto-generated method stub
90 return null;
91 }
92
Andreas Wundsam5408fb92013-07-30 12:26:04 -070093 public static List<OFPacketQueue> readPacketQueueList(
94 final ChannelBuffer bb, final int i) {
95 // TODO Auto-generated method stub
96 return null;
97 }
98
99 public static List<OFHelloElement> readHelloElementList(
100 final ChannelBuffer bb) {
101 // TODO Auto-generated method stub
102 return null;
103 }
104
105 public static List<OFBucket> readBucketList(final ChannelBuffer bb,
Andreas Wundsam951ada32013-08-01 22:05:38 -0700106 final int length) {
Andreas Wundsam40e14f72013-05-06 14:49:08 -0700107 // TODO Auto-generated method stub
108 return null;
109 }
110
Andreas Wundsam951ada32013-08-01 22:05:38 -0700111 public static List<OFMeterBand> readMeterBandList(final ChannelBuffer bb, int length) {
Andreas Wundsam40e14f72013-05-06 14:49:08 -0700112 // TODO Auto-generated method stub
113 return null;
114 }
115
Andreas Wundsam27303462013-07-16 12:52:35 -0700116 public static void writeOFMatch(ChannelBuffer bb, Match match) {
117 // TODO Auto-generated method stub
118
119 }
120
Andreas Wundsam951ada32013-08-01 22:05:38 -0700121 public static void writeList(ChannelBuffer bb, List<? extends OFObject> objects) {
122 for(OFObject o : objects) {
123 o.writeTo(bb);
124 }
Andreas Wundsam27303462013-07-16 12:52:35 -0700125 }
126
127 public static void writeOFFlowModCmd(ChannelBuffer bb, OFFlowModCmd command) {
128 // TODO Auto-generated method stub
129
130 }
131
132 public static String readFixedLengthString(ChannelBuffer bb, int length) {
133 byte[] dst = new byte[length];
134 bb.readBytes(dst, 0, length);
135 return new String(dst, Charsets.US_ASCII);
136 }
137
Andreas Wundsam5408fb92013-07-30 12:26:04 -0700138 public static void writeFixedLengthString(ChannelBuffer bb, String string,
139 int length) {
Andreas Wundsam27303462013-07-16 12:52:35 -0700140 int l = string.length();
Andreas Wundsam5408fb92013-07-30 12:26:04 -0700141 if (l > length) {
142 throw new IllegalArgumentException("Error writing string: length="
143 + l + " > max Length=" + length);
Andreas Wundsam27303462013-07-16 12:52:35 -0700144 }
145 bb.writeBytes(string.getBytes(Charsets.US_ASCII));
Andreas Wundsam5408fb92013-07-30 12:26:04 -0700146 if (l < length) {
Andreas Wundsam27303462013-07-16 12:52:35 -0700147 bb.writeZero(length - l);
148 }
149 }
150
Andreas Wundsam5408fb92013-07-30 12:26:04 -0700151 public static void writeBsnInterfaceList(ChannelBuffer bb,
152 List<OFBsnInterface> interfaces) {
Andreas Wundsam27303462013-07-16 12:52:35 -0700153 // TODO Auto-generated method stub
154
155 }
156
157 public static void writeTableFeatureList(ChannelBuffer bb,
158 List<OFTableFeature> entries) {
159 // TODO Auto-generated method stub
160
161 }
162
163 public static void writeBsnInterface(ChannelBuffer bb,
164 List<OFBsnInterface> interfaces) {
165 // TODO Auto-generated method stub
166
167 }
168
169 public static void writeFlowStatsEntry(ChannelBuffer bb,
170 List<OFFlowStatsEntry> entries) {
171 // TODO Auto-generated method stub
172
173 }
174
175 public static List<OFFlowStatsEntry> readFlowStatsEntry(ChannelBuffer bb) {
176 // TODO Auto-generated method stub
177 return null;
178 }
179
180 public static void writeTableStatsEntryList(ChannelBuffer bb,
181 List<OFTableStatsEntry> entries) {
182 // TODO Auto-generated method stub
183
184 }
185
186 public static List<OFTableStatsEntry> readTableStatsEntryList(
Andreas Wundsam951ada32013-08-01 22:05:38 -0700187 ChannelBuffer bb, int length) {
Andreas Wundsam27303462013-07-16 12:52:35 -0700188 // TODO Auto-generated method stub
189 return null;
190 }
191
Andreas Wundsam951ada32013-08-01 22:05:38 -0700192 public static List<OFFlowStatsEntry> readFlowStatsEntryList(ChannelBuffer bb, int length) {
Andreas Wundsam27303462013-07-16 12:52:35 -0700193 // TODO Auto-generated method stub
194 return null;
195 }
196
197 public static void writeFlowStatsEntryList(ChannelBuffer bb,
198 List<OFFlowStatsEntry> entries) {
199 // TODO Auto-generated method stub
200
201 }
202
203 public static void writeGroupDescStatsEntryList(ChannelBuffer bb,
204 List<OFGroupDescStatsEntry> entries) {
205 // TODO Auto-generated method stub
206
207 }
208
209 public static List<OFGroupDescStatsEntry> readGroupDescStatsEntryList(
Andreas Wundsam951ada32013-08-01 22:05:38 -0700210 ChannelBuffer bb, int length) {
Andreas Wundsam27303462013-07-16 12:52:35 -0700211 // TODO Auto-generated method stub
212 return null;
213 }
214
215 public static void writeOFBsnVportQInQT(ChannelBuffer bb,
216 OFBsnVportQInQT vport) {
217 // TODO Auto-generated method stub
218
219 }
220
221 public static void writeMeterBandList(ChannelBuffer bb,
222 List<OFMeterBand> entries) {
223 // TODO Auto-generated method stub
224
225 }
226
227 public static int writeActionsList(ChannelBuffer bb, List<OFAction> actions) {
228 // TODO Auto-generated method stub
229 return 0;
230 }
231
232 public static OFBsnVportQInQ readOFBsnVportQInQ(ChannelBuffer bb) {
233 // TODO Auto-generated method stub
234 return null;
235 }
236
237 public static void writePortStatsEntryList(ChannelBuffer bb,
238 List<OFPortStatsEntry> entries) {
239 // TODO Auto-generated method stub
240
241 }
242
243 public static void write(ChannelBuffer bb, OFPhysicalPort desc) {
244 // TODO Auto-generated method stub
245
246 }
247
Andreas Wundsam951ada32013-08-01 22:05:38 -0700248 public static List<OFPortStatsEntry> readPortStatsEntryList(ChannelBuffer bb, int length) {
Andreas Wundsam27303462013-07-16 12:52:35 -0700249 // TODO Auto-generated method stub
250 return null;
251 }
252
253 public static void writeOFBsnVportQInQ(ChannelBuffer bb,
254 OFBsnVportQInQ vport) {
255 // TODO Auto-generated method stub
256
257 }
258
Andreas Wundsam951ada32013-08-01 22:05:38 -0700259 public static List<OFHelloElem> readHelloElemList(ChannelBuffer bb, int length) {
Andreas Wundsam27303462013-07-16 12:52:35 -0700260 // TODO Auto-generated method stub
261 return null;
262 }
263
264 public static void writeHelloElemList(ChannelBuffer bb,
265 List<OFHelloElem> elements) {
266 // TODO Auto-generated method stub
267
268 }
269
270 public static List<OFGroupStatsEntry> readGroupStatsEntryList(
271 ChannelBuffer bb) {
272 // TODO Auto-generated method stub
273 return null;
274 }
275
276 public static void writeGroupStatsEntryList(ChannelBuffer bb,
277 List<OFGroupStatsEntry> entries) {
278 // TODO Auto-generated method stub
279
280 }
281
282 public static List<OFQueueStatsEntry> readQueueStatsEntryList(
Andreas Wundsam951ada32013-08-01 22:05:38 -0700283 ChannelBuffer bb, int length) {
Andreas Wundsam27303462013-07-16 12:52:35 -0700284 // TODO Auto-generated method stub
285 return null;
286 }
287
288 public static void writeQueueStatsEntryList(ChannelBuffer bb,
289 List<OFQueueStatsEntry> entries) {
290 // TODO Auto-generated method stub
291
292 }
293
294 public static OFMeterFeatures readOFMeterFeatures(ChannelBuffer bb) {
295 // TODO Auto-generated method stub
296 return null;
297 }
298
299 public static void writeOFMeterFeatures(ChannelBuffer bb,
300 OFMeterFeatures features) {
301 // TODO Auto-generated method stub
302
303 }
304
Andreas Wundsam951ada32013-08-01 22:05:38 -0700305 public static List<OFMeterStats> readMeterStatsList(ChannelBuffer bb, int length) {
Andreas Wundsam27303462013-07-16 12:52:35 -0700306 // TODO Auto-generated method stub
307 return null;
308 }
309
310 public static void writeMeterStatsList(ChannelBuffer bb,
311 List<OFMeterStats> entries) {
312 // TODO Auto-generated method stub
313
314 }
315
Andreas Wundsam951ada32013-08-01 22:05:38 -0700316 public static List<OFTableFeatures> readTableFeaturesList(ChannelBuffer bb, int length) {
Andreas Wundsam27303462013-07-16 12:52:35 -0700317 // TODO Auto-generated method stub
318 return null;
319 }
320
321 public static void writeTableFeaturesList(ChannelBuffer bb,
322 List<OFTableFeatures> entries) {
323 // TODO Auto-generated method stub
324
325 }
326
Andreas Wundsam951ada32013-08-01 22:05:38 -0700327 public static OFOxm readOFOxm(ChannelBuffer bb) {
328 // TODO Auto-generated method stub
329 return null;
330 }
331
332 public static void writeOFOxm(ChannelBuffer bb, OFOxm field) {
333 // TODO Auto-generated method stub
334
335 }
336
337 public static void writeOxmList(ChannelBuffer bb, List<OFOxm> oxmList) {
338 for(OFOxm o: oxmList) {
339 o.writeTo(bb);
340 }
341 }
342
343 public static List<OFOxm> readOxmList(ChannelBuffer bb, int length) {
344 return null;
345 }
346
347 public static Wildcards readWildcards(ChannelBuffer bb) {
348 return Wildcards.of(bb.readInt());
349 }
350
351 public static void writeWildcards(ChannelBuffer bb, Wildcards wildcards) {
352 // TODO Auto-generated method stub
353
354 }
355
356 public static void writePhysicalPortList(ChannelBuffer bb,
357 List<OFPhysicalPort> ports) {
358 // TODO Auto-generated method stub
359
360 }
361
Andreas Wundsam40e14f72013-05-06 14:49:08 -0700362}