org.openflow.protocol.factory
Class BasicFactory

java.lang.Object
  extended by org.openflow.protocol.factory.BasicFactory
All Implemented Interfaces:
OFActionFactory, OFHelloElementFactory, OFInstructionFactory, OFMessageFactory, OFMeterBandFactory, OFQueuePropertyFactory, OFStatisticsFactory, OFTableFeaturesPropertyFactory
Direct Known Subclasses:
FloodlightFactory

public class BasicFactory
extends java.lang.Object
implements OFMessageFactory, OFActionFactory, OFQueuePropertyFactory, OFStatisticsFactory, OFInstructionFactory, OFHelloElementFactory, OFMeterBandFactory, OFTableFeaturesPropertyFactory

A basic OpenFlow factory that supports naive creation of both Messages and Actions.

Author:
David Erickson (daviderickson@cs.stanford.edu), Rob Sherwood (rob.sherwood@stanford.edu), Srini Seetharaman (srini.seetharaman@gmail.com)

Constructor Summary
protected BasicFactory()
           
 
Method Summary
 OFAction getAction(OFActionType t)
          Retrieves an OFAction instance corresponding to the specified OFActionType
 OFActionFactory getActionFactory()
          Retrieves an OFActionFactory
 OFHelloElement getHelloElement(OFHelloElementType t)
          Retrieves an OFHelloElement instance corresponding to the specified OFHelloElementType
static BasicFactory getInstance()
           
 OFInstruction getInstruction(OFInstructionType t)
          Retrieves an OFInstruction instance corresponding to the specified OFInstructionType
 OFInstructionFactory getInstructionFactory()
          Retrieves an OFInstructionFactory
 OFMessage getMessage(OFType t)
          create and return a new instance of a message for OFType t.
 OFMeterBand getMeterBand(OFMeterBandType t)
          Retrieves an OFMeterBand instance corresponding to the specified OFMeterBandType
 OFQueueProperty getQueueProperty(OFQueuePropertyType t)
          Retrieves an OFQueueProperty instance corresponding to the specified OFQueuePropertyType
 OFStatistics getStatistics(OFType t, OFStatisticsType st)
          Retrieves an OFStatistics instance corresponding to the specified OFStatisticsType
 OFTableFeaturesProperty getTableFeaturesProperty(OFTableFeaturesPropertyType t)
          Retrieves an OFTableFeaturesProperty instance corresponding to the specified OFTableFeaturesPropertyType
protected  void injectFactories(OFMessage ofm)
           
 java.util.List<OFAction> parseActions(java.nio.ByteBuffer data, int length)
          Attempts to parse and return all OFActions contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at position+length.
 java.util.List<OFAction> parseActions(java.nio.ByteBuffer data, int length, int limit)
          Attempts to parse and return all OFActions contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at position+length.
 java.util.List<OFHelloElement> parseHelloElements(java.nio.ByteBuffer data, int length)
          Attempts to parse and return all OFHelloElement contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at position+length.
 java.util.List<OFHelloElement> parseHelloElements(java.nio.ByteBuffer data, int length, int limit)
          Attempts to parse and return all OFHelloElement contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at position+length.
 java.util.List<OFInstruction> parseInstructions(java.nio.ByteBuffer data, int length)
          Attempts to parse and return all OFInstruction contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at position+length.
 java.util.List<OFInstruction> parseInstructions(java.nio.ByteBuffer data, int length, int limit)
          Attempts to parse and return all OFInstruction contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at position+length.
 java.util.List<OFMessage> parseMessages(java.nio.ByteBuffer data)
          Attempts to parse and return all OFMessages contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at the ByteBuffer's limit.
 java.util.List<OFMessage> parseMessages(java.nio.ByteBuffer data, int limit)
          Attempts to parse and return all OFMessages contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at the ByteBuffer's limit.
 java.util.List<OFMeterBand> parseMeterBands(java.nio.ByteBuffer data, int length)
          Attempts to parse and return all OFMeterBands contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at position+length.
 java.util.List<OFMeterBand> parseMeterBands(java.nio.ByteBuffer data, int length, int limit)
          Attempts to parse and return all OFMeterBands contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at position+length.
 java.util.List<OFQueueProperty> parseQueueProperties(java.nio.ByteBuffer data, int length)
          Attempts to parse and return all OFQueueProperties contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at position+length.
 java.util.List<OFQueueProperty> parseQueueProperties(java.nio.ByteBuffer data, int length, int limit)
          Attempts to parse and return all OFQueueProperties contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at position+length.
 java.util.List<OFStatistics> parseStatistics(OFType t, OFStatisticsType st, java.nio.ByteBuffer data, int length)
          Attempts to parse and return all OFStatistics contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at position+length.
 java.util.List<OFStatistics> parseStatistics(OFType t, OFStatisticsType st, java.nio.ByteBuffer data, int length, int limit)
          Attempts to parse and return all OFStatistics contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at position+length.
 java.util.List<OFTableFeaturesProperty> parseTableFeaturesProperties(java.nio.ByteBuffer data, int length)
          Attempts to parse and return all OFTableFeaturesProperties contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at position+length.
 java.util.List<OFTableFeaturesProperty> parseTableFeaturesProperties(java.nio.ByteBuffer data, int length, int limit)
          Attempts to parse and return all OFTableFeaturesProperties contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at position+length.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicFactory

protected BasicFactory()
Method Detail

getInstance

public static BasicFactory getInstance()

getMessage

public OFMessage getMessage(OFType t)
create and return a new instance of a message for OFType t. Also injects factories for those message types that implement the *FactoryAware interfaces.

Specified by:
getMessage in interface OFMessageFactory
Parameters:
t - the type of the OFMessage to be retrieved
Returns:
a newly created instance that may be modified / used freely by the caller

parseMessages

public java.util.List<OFMessage> parseMessages(java.nio.ByteBuffer data)
Description copied from interface: OFMessageFactory
Attempts to parse and return all OFMessages contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at the ByteBuffer's limit.

Specified by:
parseMessages in interface OFMessageFactory
Parameters:
data - the ByteBuffer to parse for an OpenFlow message
Returns:
a list of OFMessage instances

parseMessages

public java.util.List<OFMessage> parseMessages(java.nio.ByteBuffer data,
                                               int limit)
Description copied from interface: OFMessageFactory
Attempts to parse and return all OFMessages contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at the ByteBuffer's limit.

Specified by:
parseMessages in interface OFMessageFactory
Parameters:
data - the ByteBuffer to parse for an OpenFlow message
limit - the maximum number of messages to return, 0 means no limit
Returns:
a list of OFMessage instances

injectFactories

protected void injectFactories(OFMessage ofm)

getAction

public OFAction getAction(OFActionType t)
Description copied from interface: OFActionFactory
Retrieves an OFAction instance corresponding to the specified OFActionType

Specified by:
getAction in interface OFActionFactory
Parameters:
t - the type of the OFAction to be retrieved
Returns:
an OFAction instance

parseActions

public java.util.List<OFAction> parseActions(java.nio.ByteBuffer data,
                                             int length)
Description copied from interface: OFActionFactory
Attempts to parse and return all OFActions contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at position+length.

Specified by:
parseActions in interface OFActionFactory
Parameters:
data - the ByteBuffer to parse for OpenFlow actions
length - the number of Bytes to examine for OpenFlow actions
Returns:
a list of OFAction instances

parseActions

public java.util.List<OFAction> parseActions(java.nio.ByteBuffer data,
                                             int length,
                                             int limit)
Description copied from interface: OFActionFactory
Attempts to parse and return all OFActions contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at position+length.

Specified by:
parseActions in interface OFActionFactory
Parameters:
data - the ByteBuffer to parse for OpenFlow actions
length - the number of Bytes to examine for OpenFlow actions
limit - the maximum number of messages to return, 0 means no limit
Returns:
a list of OFAction instances

getActionFactory

public OFActionFactory getActionFactory()
Description copied from interface: OFInstructionFactory
Retrieves an OFActionFactory

Specified by:
getActionFactory in interface OFInstructionFactory
Returns:
an OFActionFactory

getInstruction

public OFInstruction getInstruction(OFInstructionType t)
Description copied from interface: OFInstructionFactory
Retrieves an OFInstruction instance corresponding to the specified OFInstructionType

Specified by:
getInstruction in interface OFInstructionFactory
Parameters:
t - the type of the OFInstruction to be retrieved
Returns:
an OFInstruction instance

parseInstructions

public java.util.List<OFInstruction> parseInstructions(java.nio.ByteBuffer data,
                                                       int length)
Description copied from interface: OFInstructionFactory
Attempts to parse and return all OFInstruction contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at position+length.

Specified by:
parseInstructions in interface OFInstructionFactory
Parameters:
data - the ByteBuffer to parse for OpenFlow instructions
length - the number of Bytes to examine for OpenFlow instructions
Returns:
a list of OFInstruction instances

parseInstructions

public java.util.List<OFInstruction> parseInstructions(java.nio.ByteBuffer data,
                                                       int length,
                                                       int limit)
Description copied from interface: OFInstructionFactory
Attempts to parse and return all OFInstruction contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at position+length.

Specified by:
parseInstructions in interface OFInstructionFactory
Parameters:
data - the ByteBuffer to parse for OpenFlow instructions
length - the number of Bytes to examine for OpenFlow instructions
limit - the maximum number of messages to return, 0 means no limit
Returns:
a list of OFInstruction instances

getInstructionFactory

public OFInstructionFactory getInstructionFactory()
Description copied from interface: OFMessageFactory
Retrieves an OFInstructionFactory

Specified by:
getInstructionFactory in interface OFMessageFactory
Returns:
an OFInstructionFactory

getStatistics

public OFStatistics getStatistics(OFType t,
                                  OFStatisticsType st)
Description copied from interface: OFStatisticsFactory
Retrieves an OFStatistics instance corresponding to the specified OFStatisticsType

Specified by:
getStatistics in interface OFStatisticsFactory
Parameters:
t - the type of the containing OFMessage, only accepts statistics request or reply
st - the type of the OFStatistics to be retrieved
Returns:
an OFStatistics instance

parseStatistics

public java.util.List<OFStatistics> parseStatistics(OFType t,
                                                    OFStatisticsType st,
                                                    java.nio.ByteBuffer data,
                                                    int length)
Description copied from interface: OFStatisticsFactory
Attempts to parse and return all OFStatistics contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at position+length.

Specified by:
parseStatistics in interface OFStatisticsFactory
Parameters:
t - the type of the containing OFMessage, only accepts statistics request or reply
st - the type of the OFStatistics to be retrieved
data - the ByteBuffer to parse for OpenFlow Statistics
length - the number of Bytes to examine for OpenFlow Statistics
Returns:
a list of OFStatistics instances

parseStatistics

public java.util.List<OFStatistics> parseStatistics(OFType t,
                                                    OFStatisticsType st,
                                                    java.nio.ByteBuffer data,
                                                    int length,
                                                    int limit)
Description copied from interface: OFStatisticsFactory
Attempts to parse and return all OFStatistics contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at position+length.

Specified by:
parseStatistics in interface OFStatisticsFactory
Parameters:
t - OFMessage type: should be one of stats_request or stats_reply
st - type of this statistics message, e.g., DESC, TABLE
data - buffer to read from
length - length of records
limit - number of records to grab; 0 == all
Returns:
list of statistics records

getQueueProperty

public OFQueueProperty getQueueProperty(OFQueuePropertyType t)
Description copied from interface: OFQueuePropertyFactory
Retrieves an OFQueueProperty instance corresponding to the specified OFQueuePropertyType

Specified by:
getQueueProperty in interface OFQueuePropertyFactory
Parameters:
t - the type of the OFQueueProperty to be retrieved
Returns:
an OFQueueProperty instance

parseQueueProperties

public java.util.List<OFQueueProperty> parseQueueProperties(java.nio.ByteBuffer data,
                                                            int length)
Description copied from interface: OFQueuePropertyFactory
Attempts to parse and return all OFQueueProperties contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at position+length.

Specified by:
parseQueueProperties in interface OFQueuePropertyFactory
Parameters:
data - the ByteBuffer to parse for OpenFlow OFQueueProperties
length - the number of Bytes to examine for OpenFlow OFQueueProperties
Returns:
a list of OFQueueProperty instances

parseQueueProperties

public java.util.List<OFQueueProperty> parseQueueProperties(java.nio.ByteBuffer data,
                                                            int length,
                                                            int limit)
Description copied from interface: OFQueuePropertyFactory
Attempts to parse and return all OFQueueProperties contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at position+length.

Specified by:
parseQueueProperties in interface OFQueuePropertyFactory
Parameters:
data - the ByteBuffer to parse for OpenFlow OFQueueProperties
length - the number of Bytes to examine for OpenFlow OFQueueProperties
limit - the maximum number of OFQueueProperties to return, 0 means no limit
Returns:
a list of OFQueueProperty instances

getHelloElement

public OFHelloElement getHelloElement(OFHelloElementType t)
Description copied from interface: OFHelloElementFactory
Retrieves an OFHelloElement instance corresponding to the specified OFHelloElementType

Specified by:
getHelloElement in interface OFHelloElementFactory
Parameters:
t - the type of the OFHelloElement to be retrieved
Returns:
an OFHelloElement instance

parseHelloElements

public java.util.List<OFHelloElement> parseHelloElements(java.nio.ByteBuffer data,
                                                         int length)
Description copied from interface: OFHelloElementFactory
Attempts to parse and return all OFHelloElement contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at position+length.

Specified by:
parseHelloElements in interface OFHelloElementFactory
Parameters:
data - the ByteBuffer to parse for OpenFlow hellos
length - the number of Bytes to examine for OpenFlow hellos
Returns:
a list of OFHelloElement instances

parseHelloElements

public java.util.List<OFHelloElement> parseHelloElements(java.nio.ByteBuffer data,
                                                         int length,
                                                         int limit)
Description copied from interface: OFHelloElementFactory
Attempts to parse and return all OFHelloElement contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at position+length.

Specified by:
parseHelloElements in interface OFHelloElementFactory
Parameters:
data - the ByteBuffer to parse for OpenFlow hellos
length - the number of Bytes to examine for OpenFlow hellos
limit - the maximum number of messages to return, 0 means no limit
Returns:
a list of OFHelloElement instances

getMeterBand

public OFMeterBand getMeterBand(OFMeterBandType t)
Description copied from interface: OFMeterBandFactory
Retrieves an OFMeterBand instance corresponding to the specified OFMeterBandType

Specified by:
getMeterBand in interface OFMeterBandFactory
Parameters:
t - the type of the OFMeterBand to be retrieved
Returns:
an OFMeterBand instance

parseMeterBands

public java.util.List<OFMeterBand> parseMeterBands(java.nio.ByteBuffer data,
                                                   int length)
Description copied from interface: OFMeterBandFactory
Attempts to parse and return all OFMeterBands contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at position+length.

Specified by:
parseMeterBands in interface OFMeterBandFactory
Parameters:
data - the ByteBuffer to parse for OpenFlow OFMeterBands
length - the number of Bytes to examine for OpenFlow OFMeterBands
Returns:
a list of OFMeterBand instances

parseMeterBands

public java.util.List<OFMeterBand> parseMeterBands(java.nio.ByteBuffer data,
                                                   int length,
                                                   int limit)
Description copied from interface: OFMeterBandFactory
Attempts to parse and return all OFMeterBands contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at position+length.

Specified by:
parseMeterBands in interface OFMeterBandFactory
Parameters:
data - the ByteBuffer to parse for OpenFlow OFMeterBands
length - the number of Bytes to examine for OpenFlow OFMeterBands
limit - the maximum number of OFMeterBands to return, 0 means no limit
Returns:
a list of OFMeterBand instances

getTableFeaturesProperty

public OFTableFeaturesProperty getTableFeaturesProperty(OFTableFeaturesPropertyType t)
Description copied from interface: OFTableFeaturesPropertyFactory
Retrieves an OFTableFeaturesProperty instance corresponding to the specified OFTableFeaturesPropertyType

Specified by:
getTableFeaturesProperty in interface OFTableFeaturesPropertyFactory
Parameters:
t - the type of the OFTableFeaturesProperty to be retrieved
Returns:
an OFTableFeaturesProperty instance

parseTableFeaturesProperties

public java.util.List<OFTableFeaturesProperty> parseTableFeaturesProperties(java.nio.ByteBuffer data,
                                                                            int length)
Description copied from interface: OFTableFeaturesPropertyFactory
Attempts to parse and return all OFTableFeaturesProperties contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at position+length.

Specified by:
parseTableFeaturesProperties in interface OFTableFeaturesPropertyFactory
Parameters:
data - the ByteBuffer to parse for OpenFlow OFTableFeaturesProperties
length - the number of Bytes to examine for OpenFlow OFTableFeaturesProperties
Returns:
a list of OFTableFeaturesProperty instances

parseTableFeaturesProperties

public java.util.List<OFTableFeaturesProperty> parseTableFeaturesProperties(java.nio.ByteBuffer data,
                                                                            int length,
                                                                            int limit)
Description copied from interface: OFTableFeaturesPropertyFactory
Attempts to parse and return all OFTableFeaturesProperties contained in the given ByteBuffer, beginning at the ByteBuffer's position, and ending at position+length.

Specified by:
parseTableFeaturesProperties in interface OFTableFeaturesPropertyFactory
Parameters:
data - the ByteBuffer to parse for OpenFlow OFTableFeaturesProperties
length - the number of Bytes to examine for OpenFlow OFTableFeaturesProperties
limit - the maximum number of OFTableFeaturesProperties to return, 0 means no limit
Returns:
a list of OFTableFeaturesProperty instances