blob: 73b240e055d17814f3a6b0dce9cd0d5612a8dce1 [file] [log] [blame]
Andreas Wundsam951ada32013-08-01 22:05:38 -07001package org.openflow.protocol.ver13;
Andreas Wundsam40e14f72013-05-06 14:49:08 -07002
3import java.util.List;
4
5import org.jboss.netty.buffer.ChannelBuffer;
Andreas Wundsam951ada32013-08-01 22:05:38 -07006import org.openflow.exceptions.OFParseError;
Andreas Wundsam27303462013-07-16 12:52:35 -07007import org.openflow.protocol.OFBsnInterface;
8import org.openflow.protocol.OFBsnVportQInQ;
9import org.openflow.protocol.OFBsnVportQInQT;
10import org.openflow.protocol.OFBucket;
11import org.openflow.protocol.OFFlowStatsEntry;
12import org.openflow.protocol.OFGroupDescStatsEntry;
13import org.openflow.protocol.OFGroupStatsEntry;
14import org.openflow.protocol.OFHelloElem;
15import org.openflow.protocol.OFMeterFeatures;
16import org.openflow.protocol.OFMeterStats;
Andreas Wundsam951ada32013-08-01 22:05:38 -070017import org.openflow.protocol.OFObject;
Andreas Wundsam27303462013-07-16 12:52:35 -070018import org.openflow.protocol.OFPacketQueue;
19import org.openflow.protocol.OFPortStatsEntry;
20import org.openflow.protocol.OFQueueStatsEntry;
21import org.openflow.protocol.OFTableFeature;
22import org.openflow.protocol.OFTableFeatures;
23import org.openflow.protocol.OFTableStatsEntry;
24import 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 ChannelUtilsVer13 {
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
Andreas Wundsam951ada32013-08-01 22:05:38 -070066 public static Match readOFMatch(final ChannelBuffer bb) throws OFParseError {
67 return OFMatchV3Ver13.READER.readFrom(bb);
Andreas Wundsam40e14f72013-05-06 14:49:08 -070068 }
69
70 public static OFFlowModCmd readOFFlowModCmd(final ChannelBuffer bb) {
71 // TODO Auto-generated method stub
72 return null;
73 }
74
Andreas Wundsam5408fb92013-07-30 12:26:04 -070075 public static List<OFAction> readActionsList(final ChannelBuffer bb,
76 final int i) {
Andreas Wundsam40e14f72013-05-06 14:49:08 -070077 // TODO Auto-generated method stub
78 return null;
79 }
80
Andreas Wundsam5408fb92013-07-30 12:26:04 -070081 public static List<OFBsnInterface> readBsnInterfaceList(
Andreas Wundsam951ada32013-08-01 22:05:38 -070082 final ChannelBuffer bb, int length) {
Andreas Wundsam40e14f72013-05-06 14:49:08 -070083 // TODO Auto-generated method stub
84 return null;
85 }
86
87 public static OFPhysicalPort readPhysicalPort(final ChannelBuffer bb) {
88 // TODO Auto-generated method stub
89 return null;
90 }
91
Andreas Wundsam5408fb92013-07-30 12:26:04 -070092 public static List<OFPacketQueue> readPacketQueueList(
93 final ChannelBuffer bb, final int i) {
94 // TODO Auto-generated method stub
95 return null;
96 }
97
98 public static List<OFHelloElement> readHelloElementList(
99 final ChannelBuffer bb) {
100 // TODO Auto-generated method stub
101 return null;
102 }
103
104 public static List<OFBucket> readBucketList(final ChannelBuffer bb,
Andreas Wundsam951ada32013-08-01 22:05:38 -0700105 final int length) {
Andreas Wundsam40e14f72013-05-06 14:49:08 -0700106 // TODO Auto-generated method stub
107 return null;
108 }
109
Andreas Wundsam951ada32013-08-01 22:05:38 -0700110 public static List<OFMeterBand> readMeterBandList(final ChannelBuffer bb, int length) {
Andreas Wundsam40e14f72013-05-06 14:49:08 -0700111 // TODO Auto-generated method stub
112 return null;
113 }
114
Andreas Wundsam27303462013-07-16 12:52:35 -0700115 public static void writeOFMatch(ChannelBuffer bb, Match match) {
Andreas Wundsam951ada32013-08-01 22:05:38 -0700116 match.writeTo(bb);
Andreas Wundsam27303462013-07-16 12:52:35 -0700117 }
118
Andreas Wundsam951ada32013-08-01 22:05:38 -0700119 public static void writeList(ChannelBuffer bb, List<? extends OFObject> objects) {
120 for(OFObject o : objects) {
121 o.writeTo(bb);
122 }
Andreas Wundsam27303462013-07-16 12:52:35 -0700123 }
124
125 public static void writeOFFlowModCmd(ChannelBuffer bb, OFFlowModCmd command) {
126 // TODO Auto-generated method stub
127
128 }
129
130 public static String readFixedLengthString(ChannelBuffer bb, int length) {
131 byte[] dst = new byte[length];
132 bb.readBytes(dst, 0, length);
133 return new String(dst, Charsets.US_ASCII);
134 }
135
Andreas Wundsam5408fb92013-07-30 12:26:04 -0700136 public static void writeFixedLengthString(ChannelBuffer bb, String string,
137 int length) {
Andreas Wundsam27303462013-07-16 12:52:35 -0700138 int l = string.length();
Andreas Wundsam5408fb92013-07-30 12:26:04 -0700139 if (l > length) {
140 throw new IllegalArgumentException("Error writing string: length="
141 + l + " > max Length=" + length);
Andreas Wundsam27303462013-07-16 12:52:35 -0700142 }
143 bb.writeBytes(string.getBytes(Charsets.US_ASCII));
Andreas Wundsam5408fb92013-07-30 12:26:04 -0700144 if (l < length) {
Andreas Wundsam27303462013-07-16 12:52:35 -0700145 bb.writeZero(length - l);
146 }
147 }
148
Andreas Wundsam5408fb92013-07-30 12:26:04 -0700149 public static void writeBsnInterfaceList(ChannelBuffer bb,
150 List<OFBsnInterface> interfaces) {
Andreas Wundsam27303462013-07-16 12:52:35 -0700151 // TODO Auto-generated method stub
152
153 }
154
155 public static void writeTableFeatureList(ChannelBuffer bb,
156 List<OFTableFeature> entries) {
157 // TODO Auto-generated method stub
158
159 }
160
161 public static void writeBsnInterface(ChannelBuffer bb,
162 List<OFBsnInterface> interfaces) {
163 // TODO Auto-generated method stub
164
165 }
166
167 public static void writeFlowStatsEntry(ChannelBuffer bb,
168 List<OFFlowStatsEntry> entries) {
169 // TODO Auto-generated method stub
170
171 }
172
173 public static List<OFFlowStatsEntry> readFlowStatsEntry(ChannelBuffer bb) {
174 // TODO Auto-generated method stub
175 return null;
176 }
177
178 public static void writeTableStatsEntryList(ChannelBuffer bb,
179 List<OFTableStatsEntry> entries) {
180 // TODO Auto-generated method stub
181
182 }
183
184 public static List<OFTableStatsEntry> readTableStatsEntryList(
Andreas Wundsam951ada32013-08-01 22:05:38 -0700185 ChannelBuffer bb, int length) {
Andreas Wundsam27303462013-07-16 12:52:35 -0700186 // TODO Auto-generated method stub
187 return null;
188 }
189
Andreas Wundsam951ada32013-08-01 22:05:38 -0700190 public static List<OFFlowStatsEntry> readFlowStatsEntryList(ChannelBuffer bb, int length) {
Andreas Wundsam27303462013-07-16 12:52:35 -0700191 // TODO Auto-generated method stub
192 return null;
193 }
194
195 public static void writeFlowStatsEntryList(ChannelBuffer bb,
196 List<OFFlowStatsEntry> entries) {
197 // TODO Auto-generated method stub
198
199 }
200
201 public static void writeGroupDescStatsEntryList(ChannelBuffer bb,
202 List<OFGroupDescStatsEntry> entries) {
203 // TODO Auto-generated method stub
204
205 }
206
207 public static List<OFGroupDescStatsEntry> readGroupDescStatsEntryList(
Andreas Wundsam951ada32013-08-01 22:05:38 -0700208 ChannelBuffer bb, int length) {
Andreas Wundsam27303462013-07-16 12:52:35 -0700209 // TODO Auto-generated method stub
210 return null;
211 }
212
213 public static void writeOFBsnVportQInQT(ChannelBuffer bb,
214 OFBsnVportQInQT vport) {
215 // TODO Auto-generated method stub
216
217 }
218
219 public static void writeMeterBandList(ChannelBuffer bb,
220 List<OFMeterBand> entries) {
221 // TODO Auto-generated method stub
222
223 }
224
225 public static int writeActionsList(ChannelBuffer bb, List<OFAction> actions) {
226 // TODO Auto-generated method stub
227 return 0;
228 }
229
230 public static OFBsnVportQInQ readOFBsnVportQInQ(ChannelBuffer bb) {
231 // TODO Auto-generated method stub
232 return null;
233 }
234
235 public static void writePortStatsEntryList(ChannelBuffer bb,
236 List<OFPortStatsEntry> entries) {
237 // TODO Auto-generated method stub
238
239 }
240
241 public static void write(ChannelBuffer bb, OFPhysicalPort desc) {
242 // TODO Auto-generated method stub
243
244 }
245
Andreas Wundsam951ada32013-08-01 22:05:38 -0700246 public static List<OFPortStatsEntry> readPortStatsEntryList(ChannelBuffer bb, int length) {
Andreas Wundsam27303462013-07-16 12:52:35 -0700247 // TODO Auto-generated method stub
248 return null;
249 }
250
251 public static void writeOFBsnVportQInQ(ChannelBuffer bb,
252 OFBsnVportQInQ vport) {
253 // TODO Auto-generated method stub
254
255 }
256
Andreas Wundsam951ada32013-08-01 22:05:38 -0700257 public static List<OFHelloElem> readHelloElemList(ChannelBuffer bb, int length) {
Andreas Wundsam27303462013-07-16 12:52:35 -0700258 // TODO Auto-generated method stub
259 return null;
260 }
261
262 public static void writeHelloElemList(ChannelBuffer bb,
263 List<OFHelloElem> elements) {
264 // TODO Auto-generated method stub
265
266 }
267
268 public static List<OFGroupStatsEntry> readGroupStatsEntryList(
Andreas Wundsam951ada32013-08-01 22:05:38 -0700269 ChannelBuffer bb, int length) {
Andreas Wundsam27303462013-07-16 12:52:35 -0700270 // TODO Auto-generated method stub
271 return null;
272 }
273
274 public static void writeGroupStatsEntryList(ChannelBuffer bb,
275 List<OFGroupStatsEntry> entries) {
276 // TODO Auto-generated method stub
277
278 }
279
280 public static List<OFQueueStatsEntry> readQueueStatsEntryList(
Andreas Wundsam951ada32013-08-01 22:05:38 -0700281 ChannelBuffer bb, int length) {
Andreas Wundsam27303462013-07-16 12:52:35 -0700282 // TODO Auto-generated method stub
283 return null;
284 }
285
286 public static void writeQueueStatsEntryList(ChannelBuffer bb,
287 List<OFQueueStatsEntry> entries) {
288 // TODO Auto-generated method stub
289
290 }
291
292 public static OFMeterFeatures readOFMeterFeatures(ChannelBuffer bb) {
293 // TODO Auto-generated method stub
294 return null;
295 }
296
297 public static void writeOFMeterFeatures(ChannelBuffer bb,
298 OFMeterFeatures features) {
299 // TODO Auto-generated method stub
300
301 }
302
Andreas Wundsam951ada32013-08-01 22:05:38 -0700303 public static List<OFMeterStats> readMeterStatsList(ChannelBuffer bb, int length) {
Andreas Wundsam27303462013-07-16 12:52:35 -0700304 // TODO Auto-generated method stub
305 return null;
306 }
307
308 public static void writeMeterStatsList(ChannelBuffer bb,
309 List<OFMeterStats> entries) {
310 // TODO Auto-generated method stub
311
312 }
313
Andreas Wundsam951ada32013-08-01 22:05:38 -0700314 public static List<OFTableFeatures> readTableFeaturesList(ChannelBuffer bb, int length) {
Andreas Wundsam27303462013-07-16 12:52:35 -0700315 // TODO Auto-generated method stub
316 return null;
317 }
318
319 public static void writeTableFeaturesList(ChannelBuffer bb,
320 List<OFTableFeatures> entries) {
321 // TODO Auto-generated method stub
322
323 }
324
Andreas Wundsam951ada32013-08-01 22:05:38 -0700325 public static OFOxm readOFOxm(ChannelBuffer bb) {
326 // TODO Auto-generated method stub
327 return null;
328 }
329
330 public static void writeOFOxm(ChannelBuffer bb, OFOxm field) {
331 // TODO Auto-generated method stub
332
333 }
334
335 public static void writeOxmList(ChannelBuffer bb, List<OFOxm> oxmList) {
336 for(OFOxm o: oxmList) {
337 o.writeTo(bb);
338 }
339 }
340
341 public static List<OFOxm> readOxmList(ChannelBuffer bb, int length) {
342 return null;
343 }
344
345 public static void writePhysicalPortList(ChannelBuffer bb,
346 List<OFPhysicalPort> entries) {
347 // TODO Auto-generated method stub
348
349 }
350
Andreas Wundsam40e14f72013-05-06 14:49:08 -0700351}