Andreas Wundsam | 951ada3 | 2013-08-01 22:05:38 -0700 | [diff] [blame^] | 1 | package org.openflow.protocol.ver13; |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 2 | |
| 3 | import java.util.List; |
| 4 | |
| 5 | import org.jboss.netty.buffer.ChannelBuffer; |
Andreas Wundsam | 951ada3 | 2013-08-01 22:05:38 -0700 | [diff] [blame^] | 6 | import org.openflow.exceptions.OFParseError; |
Andreas Wundsam | 2730346 | 2013-07-16 12:52:35 -0700 | [diff] [blame] | 7 | import org.openflow.protocol.OFBsnInterface; |
| 8 | import org.openflow.protocol.OFBsnVportQInQ; |
| 9 | import org.openflow.protocol.OFBsnVportQInQT; |
| 10 | import org.openflow.protocol.OFBucket; |
| 11 | import org.openflow.protocol.OFFlowStatsEntry; |
| 12 | import org.openflow.protocol.OFGroupDescStatsEntry; |
| 13 | import org.openflow.protocol.OFGroupStatsEntry; |
| 14 | import org.openflow.protocol.OFHelloElem; |
| 15 | import org.openflow.protocol.OFMeterFeatures; |
| 16 | import org.openflow.protocol.OFMeterStats; |
Andreas Wundsam | 951ada3 | 2013-08-01 22:05:38 -0700 | [diff] [blame^] | 17 | import org.openflow.protocol.OFObject; |
Andreas Wundsam | 2730346 | 2013-07-16 12:52:35 -0700 | [diff] [blame] | 18 | import org.openflow.protocol.OFPacketQueue; |
| 19 | import org.openflow.protocol.OFPortStatsEntry; |
| 20 | import org.openflow.protocol.OFQueueStatsEntry; |
| 21 | import org.openflow.protocol.OFTableFeature; |
| 22 | import org.openflow.protocol.OFTableFeatures; |
| 23 | import org.openflow.protocol.OFTableStatsEntry; |
| 24 | import org.openflow.protocol.action.OFAction; |
| 25 | import org.openflow.protocol.instruction.OFInstruction; |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 26 | import org.openflow.protocol.match.Match; |
Andreas Wundsam | 5408fb9 | 2013-07-30 12:26:04 -0700 | [diff] [blame] | 27 | import org.openflow.protocol.meterband.OFMeterBand; |
Andreas Wundsam | 951ada3 | 2013-08-01 22:05:38 -0700 | [diff] [blame^] | 28 | import org.openflow.protocol.oxm.OFOxm; |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 29 | import org.openflow.types.OFFlowModCmd; |
| 30 | import org.openflow.types.OFHelloElement; |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 31 | import org.openflow.types.OFPhysicalPort; |
| 32 | |
Andreas Wundsam | 2730346 | 2013-07-16 12:52:35 -0700 | [diff] [blame] | 33 | import com.google.common.base.Charsets; |
| 34 | |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 35 | /** |
| 36 | * Collection of helper functions for reading and writing into ChannelBuffers |
| 37 | * |
| 38 | * @author capveg |
| 39 | */ |
| 40 | |
Andreas Wundsam | 951ada3 | 2013-08-01 22:05:38 -0700 | [diff] [blame^] | 41 | public class ChannelUtilsVer13 { |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 42 | |
| 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 Wundsam | 5408fb9 | 2013-07-30 12:26:04 -0700 | [diff] [blame] | 49 | static public void writeBytes(final ChannelBuffer bb, |
| 50 | final byte byteArray[]) { |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 51 | bb.writeBytes(byteArray); |
| 52 | } |
| 53 | |
Andreas Wundsam | 5408fb9 | 2013-07-30 12:26:04 -0700 | [diff] [blame] | 54 | public static List<OFPhysicalPort> readPhysicalPortList( |
| 55 | final ChannelBuffer bb, final int i) { |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 56 | // TODO Auto-generated method stub |
| 57 | return null; |
| 58 | } |
| 59 | |
Andreas Wundsam | 5408fb9 | 2013-07-30 12:26:04 -0700 | [diff] [blame] | 60 | public static List<OFInstruction> readInstructionsList( |
| 61 | final ChannelBuffer bb, final int i) { |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 62 | // TODO Auto-generated method stub |
| 63 | return null; |
| 64 | } |
| 65 | |
Andreas Wundsam | 951ada3 | 2013-08-01 22:05:38 -0700 | [diff] [blame^] | 66 | public static Match readOFMatch(final ChannelBuffer bb) throws OFParseError { |
| 67 | return OFMatchV3Ver13.READER.readFrom(bb); |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | public static OFFlowModCmd readOFFlowModCmd(final ChannelBuffer bb) { |
| 71 | // TODO Auto-generated method stub |
| 72 | return null; |
| 73 | } |
| 74 | |
Andreas Wundsam | 5408fb9 | 2013-07-30 12:26:04 -0700 | [diff] [blame] | 75 | public static List<OFAction> readActionsList(final ChannelBuffer bb, |
| 76 | final int i) { |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 77 | // TODO Auto-generated method stub |
| 78 | return null; |
| 79 | } |
| 80 | |
Andreas Wundsam | 5408fb9 | 2013-07-30 12:26:04 -0700 | [diff] [blame] | 81 | public static List<OFBsnInterface> readBsnInterfaceList( |
Andreas Wundsam | 951ada3 | 2013-08-01 22:05:38 -0700 | [diff] [blame^] | 82 | final ChannelBuffer bb, int length) { |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 83 | // 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 Wundsam | 5408fb9 | 2013-07-30 12:26:04 -0700 | [diff] [blame] | 92 | 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 Wundsam | 951ada3 | 2013-08-01 22:05:38 -0700 | [diff] [blame^] | 105 | final int length) { |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 106 | // TODO Auto-generated method stub |
| 107 | return null; |
| 108 | } |
| 109 | |
Andreas Wundsam | 951ada3 | 2013-08-01 22:05:38 -0700 | [diff] [blame^] | 110 | public static List<OFMeterBand> readMeterBandList(final ChannelBuffer bb, int length) { |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 111 | // TODO Auto-generated method stub |
| 112 | return null; |
| 113 | } |
| 114 | |
Andreas Wundsam | 2730346 | 2013-07-16 12:52:35 -0700 | [diff] [blame] | 115 | public static void writeOFMatch(ChannelBuffer bb, Match match) { |
Andreas Wundsam | 951ada3 | 2013-08-01 22:05:38 -0700 | [diff] [blame^] | 116 | match.writeTo(bb); |
Andreas Wundsam | 2730346 | 2013-07-16 12:52:35 -0700 | [diff] [blame] | 117 | } |
| 118 | |
Andreas Wundsam | 951ada3 | 2013-08-01 22:05:38 -0700 | [diff] [blame^] | 119 | public static void writeList(ChannelBuffer bb, List<? extends OFObject> objects) { |
| 120 | for(OFObject o : objects) { |
| 121 | o.writeTo(bb); |
| 122 | } |
Andreas Wundsam | 2730346 | 2013-07-16 12:52:35 -0700 | [diff] [blame] | 123 | } |
| 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 Wundsam | 5408fb9 | 2013-07-30 12:26:04 -0700 | [diff] [blame] | 136 | public static void writeFixedLengthString(ChannelBuffer bb, String string, |
| 137 | int length) { |
Andreas Wundsam | 2730346 | 2013-07-16 12:52:35 -0700 | [diff] [blame] | 138 | int l = string.length(); |
Andreas Wundsam | 5408fb9 | 2013-07-30 12:26:04 -0700 | [diff] [blame] | 139 | if (l > length) { |
| 140 | throw new IllegalArgumentException("Error writing string: length=" |
| 141 | + l + " > max Length=" + length); |
Andreas Wundsam | 2730346 | 2013-07-16 12:52:35 -0700 | [diff] [blame] | 142 | } |
| 143 | bb.writeBytes(string.getBytes(Charsets.US_ASCII)); |
Andreas Wundsam | 5408fb9 | 2013-07-30 12:26:04 -0700 | [diff] [blame] | 144 | if (l < length) { |
Andreas Wundsam | 2730346 | 2013-07-16 12:52:35 -0700 | [diff] [blame] | 145 | bb.writeZero(length - l); |
| 146 | } |
| 147 | } |
| 148 | |
Andreas Wundsam | 5408fb9 | 2013-07-30 12:26:04 -0700 | [diff] [blame] | 149 | public static void writeBsnInterfaceList(ChannelBuffer bb, |
| 150 | List<OFBsnInterface> interfaces) { |
Andreas Wundsam | 2730346 | 2013-07-16 12:52:35 -0700 | [diff] [blame] | 151 | // 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 Wundsam | 951ada3 | 2013-08-01 22:05:38 -0700 | [diff] [blame^] | 185 | ChannelBuffer bb, int length) { |
Andreas Wundsam | 2730346 | 2013-07-16 12:52:35 -0700 | [diff] [blame] | 186 | // TODO Auto-generated method stub |
| 187 | return null; |
| 188 | } |
| 189 | |
Andreas Wundsam | 951ada3 | 2013-08-01 22:05:38 -0700 | [diff] [blame^] | 190 | public static List<OFFlowStatsEntry> readFlowStatsEntryList(ChannelBuffer bb, int length) { |
Andreas Wundsam | 2730346 | 2013-07-16 12:52:35 -0700 | [diff] [blame] | 191 | // 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 Wundsam | 951ada3 | 2013-08-01 22:05:38 -0700 | [diff] [blame^] | 208 | ChannelBuffer bb, int length) { |
Andreas Wundsam | 2730346 | 2013-07-16 12:52:35 -0700 | [diff] [blame] | 209 | // 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 Wundsam | 951ada3 | 2013-08-01 22:05:38 -0700 | [diff] [blame^] | 246 | public static List<OFPortStatsEntry> readPortStatsEntryList(ChannelBuffer bb, int length) { |
Andreas Wundsam | 2730346 | 2013-07-16 12:52:35 -0700 | [diff] [blame] | 247 | // 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 Wundsam | 951ada3 | 2013-08-01 22:05:38 -0700 | [diff] [blame^] | 257 | public static List<OFHelloElem> readHelloElemList(ChannelBuffer bb, int length) { |
Andreas Wundsam | 2730346 | 2013-07-16 12:52:35 -0700 | [diff] [blame] | 258 | // 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 Wundsam | 951ada3 | 2013-08-01 22:05:38 -0700 | [diff] [blame^] | 269 | ChannelBuffer bb, int length) { |
Andreas Wundsam | 2730346 | 2013-07-16 12:52:35 -0700 | [diff] [blame] | 270 | // 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 Wundsam | 951ada3 | 2013-08-01 22:05:38 -0700 | [diff] [blame^] | 281 | ChannelBuffer bb, int length) { |
Andreas Wundsam | 2730346 | 2013-07-16 12:52:35 -0700 | [diff] [blame] | 282 | // 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 Wundsam | 951ada3 | 2013-08-01 22:05:38 -0700 | [diff] [blame^] | 303 | public static List<OFMeterStats> readMeterStatsList(ChannelBuffer bb, int length) { |
Andreas Wundsam | 2730346 | 2013-07-16 12:52:35 -0700 | [diff] [blame] | 304 | // 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 Wundsam | 951ada3 | 2013-08-01 22:05:38 -0700 | [diff] [blame^] | 314 | public static List<OFTableFeatures> readTableFeaturesList(ChannelBuffer bb, int length) { |
Andreas Wundsam | 2730346 | 2013-07-16 12:52:35 -0700 | [diff] [blame] | 315 | // 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 Wundsam | 951ada3 | 2013-08-01 22:05:38 -0700 | [diff] [blame^] | 325 | 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 Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 351 | } |