org.openflow.protocol.vendor
Class OFBasicVendorId

java.lang.Object
  extended by org.openflow.protocol.vendor.OFVendorId
      extended by org.openflow.protocol.vendor.OFBasicVendorId

public class OFBasicVendorId
extends OFVendorId

Basic subclass of OFVendorId that works with any vendor data format where the data begins with an integral data type value.

Author:
Rob Vaterlaus (rob.vaterlaus@bigswitch.com)

Field Summary
protected  java.util.Map<java.lang.Long,OFBasicVendorDataType> dataTypeMap
          Map of the vendor data types that have been registered for this vendor id.
protected  int dataTypeSize
          The size of the data type value at the beginning of all vendor data associated with this vendor id.
 
Fields inherited from class org.openflow.protocol.vendor.OFVendorId
id
 
Constructor Summary
OFBasicVendorId(int id, int dataTypeSize)
          Construct an OFVendorId that where the vendor data begins with a data type value whose size is dataTypeSize.
 
Method Summary
 int getDataTypeSize()
          Get the size of the data type value at the beginning of the vendor data.
 OFVendorDataType lookupVendorDataType(int vendorDataType)
          Lookup the OFVendorDataType instance that has been registered with this vendor id.
 OFVendorDataType parseVendorDataType(java.nio.ByteBuffer data, int length)
          This function parses enough of the data from the buffer to be able to determine the appropriate OFVendorDataType for the data.
 void registerVendorDataType(OFBasicVendorDataType vendorDataType)
          Register a vendor data type with this vendor id.
 
Methods inherited from class org.openflow.protocol.vendor.OFVendorId
getId, lookupVendorId, registerVendorId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dataTypeSize

protected int dataTypeSize
The size of the data type value at the beginning of all vendor data associated with this vendor id. The data type size must be either 1, 2, 4 or 8.


dataTypeMap

protected java.util.Map<java.lang.Long,OFBasicVendorDataType> dataTypeMap
Map of the vendor data types that have been registered for this vendor id.

Constructor Detail

OFBasicVendorId

public OFBasicVendorId(int id,
                       int dataTypeSize)
Construct an OFVendorId that where the vendor data begins with a data type value whose size is dataTypeSize.

Parameters:
id - the id of the vendor, typically the OUI of a vendor prefixed with 0.
dataTypeSize - the size of the integral data type value at the beginning of the vendor data. The value must be the size of an integeral data type (i.e. either 1,2,4 or 8).
Method Detail

getDataTypeSize

public int getDataTypeSize()
Get the size of the data type value at the beginning of the vendor data. OFBasicVendorId assumes that this value is common across all of the vendor data formats associated with a given vendor id.

Returns:

registerVendorDataType

public void registerVendorDataType(OFBasicVendorDataType vendorDataType)
Register a vendor data type with this vendor id.

Parameters:
vendorDataType -

lookupVendorDataType

public OFVendorDataType lookupVendorDataType(int vendorDataType)
Lookup the OFVendorDataType instance that has been registered with this vendor id.

Parameters:
vendorDataType - the integer code that was parsed from the
Returns:

parseVendorDataType

public OFVendorDataType parseVendorDataType(java.nio.ByteBuffer data,
                                            int length)
This function parses enough of the data from the buffer to be able to determine the appropriate OFVendorDataType for the data. It is meant to be a reasonably generic implementation that will work for most formats of vendor extensions. If the vendor data doesn't fit the assumptions listed below, then this method will need to be overridden to implement custom parsing. This implementation assumes that the vendor data begins with a data type code that is used to distinguish different formats of vendor data associated with a particular vendor ID. The exact format of the data is vendor-defined, so we don't know how how big the code is (or really even if there is a code). This code assumes that the common case will be that the data does include an initial type code (i.e. so that the vendor can have multiple message/data types) and that the size is either 1, 2 or 4 bytes. The size of the initial type code is configured by the subclass of OFVendorId.

Specified by:
parseVendorDataType in class OFVendorId
Parameters:
data - the channel buffer containing the vendor data.
length - the length to the end of the enclosing message
Returns:
the OFVendorDataType that can be used to instantiate the appropriate subclass of OFVendorData.