Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 1 | /** |
| 2 | * Copyright 2011, Big Switch Networks, Inc. |
| 3 | * Originally created by David Erickson & Rob Sherwood, Stanford University |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 6 | * not use this file except in compliance with the License. You may obtain |
| 7 | * a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 | * License for the specific language governing permissions and limitations |
| 15 | * under the License. |
| 16 | **/ |
| 17 | |
| 18 | package org.openflow.protocol.factory; |
| 19 | |
| 20 | import org.jboss.netty.buffer.ChannelBuffer; |
| 21 | import org.openflow.protocol.vendor.OFVendorData; |
| 22 | import org.openflow.protocol.vendor.OFVendorDataType; |
| 23 | import org.openflow.protocol.vendor.OFVendorId; |
| 24 | |
| 25 | /** |
| 26 | * The interface to factories used for parsing/creating OFVendorData instances. |
| 27 | * All methods are expected to be thread-safe. |
| 28 | * |
| 29 | * @author Rob Vaterlaus (rob.vaterlaus@bigswitch.com) |
| 30 | */ |
| 31 | public interface OFVendorDataFactory { |
| 32 | /** |
| 33 | * Retrieves an OFVendorData instance corresponding to the specified |
| 34 | * OFVendorId and OFVendorDataType. There are 3 possible cases for |
| 35 | * how this will be called: |
| 36 | * |
| 37 | * 1) If the vendor id in the OFVendor message is an unknown value, |
| 38 | * then this method is called with both vendorId and vendorDataType |
| 39 | * set to null. In this case typically the factory method should |
| 40 | * return an instance of OFGenericVendorData that just contains |
| 41 | * the raw byte array of the vendor data. |
| 42 | * |
| 43 | * 2) If the vendor id is known but no vendor data type has been |
| 44 | * registered for the data in the message, then vendorId is set to |
| 45 | * the appropriate OFVendorId instance and OFVendorDataType is set |
| 46 | * to null. This would typically be handled the same way as #1 |
| 47 | * |
| 48 | * 3) If both the vendor id and and vendor data type are known, then |
| 49 | * typically you'd just call the method in OFVendorDataType to |
| 50 | * instantiate the appropriate subclass of OFVendorData. |
| 51 | * |
| 52 | * @param vendorId the vendorId of the containing OFVendor message |
| 53 | * @param vendorDataType the type of the OFVendorData to be retrieved |
| 54 | * @return an OFVendorData instance |
| 55 | */ |
| 56 | public OFVendorData getVendorData(OFVendorId vendorId, |
| 57 | OFVendorDataType vendorDataType); |
| 58 | |
| 59 | /** |
| 60 | * Attempts to parse and return the OFVendorData contained in the given |
| 61 | * ChannelBuffer, beginning right after the vendor id. |
| 62 | * @param vendorId the vendor id that was parsed from the OFVendor message. |
| 63 | * @param data the ChannelBuffer from which to parse the vendor data |
| 64 | * @param length the length to the end of the enclosing message. |
| 65 | * @return an OFVendorData instance |
| 66 | */ |
| 67 | public OFVendorData parseVendorData(int vendorId, ChannelBuffer data, |
| 68 | int length); |
| 69 | } |