Class AbstractOpenFlowSwitch
- java.lang.Object
-
- org.onosproject.net.driver.AbstractBehaviour
-
- org.onosproject.net.driver.AbstractHandlerBehaviour
-
- org.onosproject.openflow.controller.driver.AbstractOpenFlowSwitch
-
- All Implemented Interfaces:
org.onosproject.net.driver.Behaviour,org.onosproject.net.driver.HandlerBehaviour,OpenFlowSwitchDriver,OpenFlowSwitch
public abstract class AbstractOpenFlowSwitch extends org.onosproject.net.driver.AbstractHandlerBehaviour implements OpenFlowSwitchDriver
An abstract representation of an OpenFlow switch. Can be extended by others to serve as a base for their vendor specific representation of a switch.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringchannelIdprotected OpenFlowClassifierListenerclassifierListenerprotected org.slf4j.Loggerlogprotected RoleStateroleprotected booleanstartDriverHandshakeCalled
-
Constructor Summary
Constructors Constructor Description AbstractOpenFlowSwitch()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanactivateEqualSwitch()Activate this EQUAL switch-controller relationship in the OF agent.booleanactivateMasterSwitch()Activate this MASTER switch-controller relationship in the OF agent.java.lang.StringchannelId()Identifies the channel used to communicate with the switch.booleanconnectSwitch()Announce to the OpenFlow agent that this switch has connected.java.lang.StringdatapathDescription()fetch the datapath description.org.onosproject.net.Device.TypedeviceType()Returns the switch device type.voiddisconnectSwitch()Disconnects the switch by closing the TCP connection.org.projectfloodlight.openflow.protocol.OFFactoryfactory()Provides the factory for this OF version.org.projectfloodlight.openflow.protocol.OFFeaturesReplyfeatures()Fetches the features of this switch.DpidgetDpid()Gets the datapathId of the switch.longgetId()Gets the datapathId of the switch.org.projectfloodlight.openflow.protocol.OFMeterFeaturesgetMeterFeatures()Fetches the meter features of this switch.intgetNextTransactionId()Gets the next transaction id to use.java.util.List<org.projectfloodlight.openflow.protocol.OFPortDesc>getPorts()Fetches the ports of this switch.RoleStategetRole()Fetch the role for this switch.java.lang.StringgetStringId()Gets a string version of the ID for this switch.voidhandleMessage(org.projectfloodlight.openflow.protocol.OFMessage m)Handle the message coming from the dataplane.voidhandleNiciraRole(org.projectfloodlight.openflow.protocol.OFMessage m)If this driver know of Nicira style role messages, these should be handled here.voidhandleRole(org.projectfloodlight.openflow.protocol.OFMessage m)Handle OF 1.x (where x > 0) role messages.booleanhandleRoleError(org.projectfloodlight.openflow.protocol.OFErrorMsg error)Handle the situation where the role request triggers an error.java.lang.StringhardwareDescription()fetch the hardware description.voidinit(Dpid dpid, org.projectfloodlight.openflow.protocol.OFDescStatsReply desc, org.projectfloodlight.openflow.protocol.OFVersion ofv)Initialises the behaviour.booleanisConnected()Checks if the switch is still connected.abstract booleanisDriverHandshakeComplete()Checks whether the driver specific handshake is complete.java.lang.StringmanufacturerDescription()fetch the manufacturer description.protected java.util.Map<org.projectfloodlight.openflow.types.OFPort,org.projectfloodlight.openflow.protocol.OFPortDesc>portDescs()abstract voidprocessDriverHandshakeMessage(org.projectfloodlight.openflow.protocol.OFMessage m)Process a message during the driver specific handshake.voidreassertRole()Reasserts this controllers role to the switch.voidremoveConnectedSwitch()Remove this switch from the openflow agent.protected voidreplacePortDescsWith(java.util.Collection<org.projectfloodlight.openflow.protocol.OFPortDesc> allPorts)voidreturnRoleReply(RoleState requested, RoleState response)Notifies the controller that the device has responded to a set-role request.voidsendHandshakeMessage(org.projectfloodlight.openflow.protocol.OFMessage message)Allows the handshaker behaviour to send messages during the handshake phase only.voidsendMsg(java.util.List<org.projectfloodlight.openflow.protocol.OFMessage> msgs)Writes the OFMessage list to the driver.voidsendMsg(org.projectfloodlight.openflow.protocol.OFMessage msg)Writes the message to the driver.voidsendRoleRequest(org.projectfloodlight.openflow.protocol.OFMessage msg)Sends only role request messages.java.lang.StringserialNumber()fetch the serial number.voidsetAgent(OpenFlowAgent ag)Sets the OpenFlow agent to be used.voidsetChannel(OpenFlowSession channel)Sets the associated OpenFlow session for this switch.voidsetConnected(boolean connected)Sets whether the switch is connected.voidsetFeaturesReply(org.projectfloodlight.openflow.protocol.OFFeaturesReply featuresReply)Sets the features reply for this switch.voidsetMeterFeaturesReply(org.projectfloodlight.openflow.protocol.OFMeterFeaturesStatsReply meterFeaturesReply)Sets the meter features reply for this switch.voidsetOFVersion(org.projectfloodlight.openflow.protocol.OFVersion ofV)Sets the OF version for this switch.voidsetPortDescReplies(java.util.List<org.projectfloodlight.openflow.protocol.OFPortDescStatsReply> portDescReplies)Sets the ports on this switch.voidsetPortDescReply(org.projectfloodlight.openflow.protocol.OFPortDescStatsReply portDescReply)Sets the ports on this switch.voidsetRole(RoleState role)Sets the role for this switch.voidsetRoleHandler(RoleHandler roleHandler)Sets the Role handler object.voidsetSwitchDescription(org.projectfloodlight.openflow.protocol.OFDescStatsReply d)Sets the switch description.voidsetTableFull(boolean full)Sets this switch has having a full flowtable.java.lang.StringsoftwareDescription()fetch the software description.abstract voidstartDriverHandshake()Starts the driver specific handshake process.abstract java.lang.BooleansupportNxRole()Does this switch support Nicira Role messages.java.lang.StringtoString()voidtransitionToEqualSwitch()Transition this switch-controller relationship to an EQUAL state.voidtransitionToMasterSwitch()Transition this switch-controller relationship to an Master state.-
Methods inherited from class org.onosproject.net.driver.AbstractHandlerBehaviour
handler, setHandler
-
-
-
-
Field Detail
-
log
protected final org.slf4j.Logger log
-
channelId
protected java.lang.String channelId
-
startDriverHandshakeCalled
protected boolean startDriverHandshakeCalled
-
role
protected volatile RoleState role
-
classifierListener
protected OpenFlowClassifierListener classifierListener
-
-
Method Detail
-
init
public void init(Dpid dpid, org.projectfloodlight.openflow.protocol.OFDescStatsReply desc, org.projectfloodlight.openflow.protocol.OFVersion ofv)
Description copied from interface:OpenFlowSwitchDriverInitialises the behaviour.- Specified by:
initin interfaceOpenFlowSwitchDriver- Parameters:
dpid- a dpiddesc- a switch descriptionofv- OpenFlow version
-
disconnectSwitch
public final void disconnectSwitch()
Description copied from interface:OpenFlowSwitchDisconnects the switch by closing the TCP connection. Results in a call to the channel handler's channelDisconnected method for cleanup- Specified by:
disconnectSwitchin interfaceOpenFlowSwitch
-
sendMsg
public void sendMsg(org.projectfloodlight.openflow.protocol.OFMessage msg)
Description copied from interface:OpenFlowSwitchWrites the message to the driver.Note: Messages may be silently dropped/lost due to IOExceptions or role. If this is a concern, then a caller should use barriers.
- Specified by:
sendMsgin interfaceOpenFlowSwitch- Parameters:
msg- the message to write
-
sendMsg
public final void sendMsg(java.util.List<org.projectfloodlight.openflow.protocol.OFMessage> msgs)
Description copied from interface:OpenFlowSwitchWrites the OFMessage list to the driver.Note: Messages may be silently dropped/lost due to IOExceptions or role. If this is a concern, then a caller should use barriers.
- Specified by:
sendMsgin interfaceOpenFlowSwitch- Parameters:
msgs- the messages to be written
-
sendRoleRequest
public final void sendRoleRequest(org.projectfloodlight.openflow.protocol.OFMessage msg)
Description copied from interface:OpenFlowSwitchDriverSends only role request messages.- Specified by:
sendRoleRequestin interfaceOpenFlowSwitchDriver- Parameters:
msg- a role request message.
-
sendHandshakeMessage
public final void sendHandshakeMessage(org.projectfloodlight.openflow.protocol.OFMessage message)
Description copied from interface:OpenFlowSwitchDriverAllows the handshaker behaviour to send messages during the handshake phase only.- Specified by:
sendHandshakeMessagein interfaceOpenFlowSwitchDriver- Parameters:
message- an OpenFlow message
-
isConnected
public final boolean isConnected()
Description copied from interface:OpenFlowSwitchChecks if the switch is still connected.- Specified by:
isConnectedin interfaceOpenFlowSwitch- Returns:
- whether the switch is still connected
-
setConnected
public final void setConnected(boolean connected)
Description copied from interface:OpenFlowSwitchDriverSets whether the switch is connected.- Specified by:
setConnectedin interfaceOpenFlowSwitchDriver- Parameters:
connected- whether the switch is connected
-
setChannel
public final void setChannel(OpenFlowSession channel)
Description copied from interface:OpenFlowSwitchDriverSets the associated OpenFlow session for this switch.- Specified by:
setChannelin interfaceOpenFlowSwitchDriver- Parameters:
channel- the OpenFlow session
-
channelId
public java.lang.String channelId()
Description copied from interface:OpenFlowSwitchIdentifies the channel used to communicate with the switch.- Specified by:
channelIdin interfaceOpenFlowSwitch- Returns:
- string representation of the connection to the device
-
getId
public final long getId()
Description copied from interface:OpenFlowSwitchGets the datapathId of the switch.- Specified by:
getIdin interfaceOpenFlowSwitch- Returns:
- the switch dpid in long format
-
getDpid
public Dpid getDpid()
Description copied from interface:OpenFlowSwitchGets the datapathId of the switch.- Specified by:
getDpidin interfaceOpenFlowSwitch- Returns:
- the switch dpid
-
getStringId
public final java.lang.String getStringId()
Description copied from interface:OpenFlowSwitchGets a string version of the ID for this switch.- Specified by:
getStringIdin interfaceOpenFlowSwitch- Returns:
- string version of the ID
-
setOFVersion
public final void setOFVersion(org.projectfloodlight.openflow.protocol.OFVersion ofV)
Description copied from interface:OpenFlowSwitchDriverSets the OF version for this switch.- Specified by:
setOFVersionin interfaceOpenFlowSwitchDriver- Parameters:
ofV- the version to set.
-
setTableFull
public void setTableFull(boolean full)
Description copied from interface:OpenFlowSwitchDriverSets this switch has having a full flowtable.- Specified by:
setTableFullin interfaceOpenFlowSwitchDriver- Parameters:
full- true if full, false otherswise.
-
setFeaturesReply
public void setFeaturesReply(org.projectfloodlight.openflow.protocol.OFFeaturesReply featuresReply)
Description copied from interface:OpenFlowSwitchDriverSets the features reply for this switch.- Specified by:
setFeaturesReplyin interfaceOpenFlowSwitchDriver- Parameters:
featuresReply- the features to set.
-
setMeterFeaturesReply
public void setMeterFeaturesReply(org.projectfloodlight.openflow.protocol.OFMeterFeaturesStatsReply meterFeaturesReply)
Description copied from interface:OpenFlowSwitchDriverSets the meter features reply for this switch.- Specified by:
setMeterFeaturesReplyin interfaceOpenFlowSwitchDriver- Parameters:
meterFeaturesReply- the meter features to set.
-
supportNxRole
public abstract java.lang.Boolean supportNxRole()
Description copied from interface:OpenFlowSwitchDriverDoes this switch support Nicira Role messages.Only relevant if this Device is OpenFlow 1.0.
- Specified by:
supportNxRolein interfaceOpenFlowSwitchDriver- Returns:
- true if supports, false otherwise.
-
handleMessage
public final void handleMessage(org.projectfloodlight.openflow.protocol.OFMessage m)
Handle the message coming from the dataplane.- Specified by:
handleMessagein interfaceOpenFlowSwitch- Parameters:
m- the actual message
-
getRole
public RoleState getRole()
Description copied from interface:OpenFlowSwitchFetch the role for this switch.- Specified by:
getRolein interfaceOpenFlowSwitch- Returns:
- the role.
-
connectSwitch
public final boolean connectSwitch()
Description copied from interface:OpenFlowSwitchDriverAnnounce to the OpenFlow agent that this switch has connected.- Specified by:
connectSwitchin interfaceOpenFlowSwitchDriver- Returns:
- true if successful, false if duplicate switch.
-
activateMasterSwitch
public final boolean activateMasterSwitch()
Description copied from interface:OpenFlowSwitchDriverActivate this MASTER switch-controller relationship in the OF agent.- Specified by:
activateMasterSwitchin interfaceOpenFlowSwitchDriver- Returns:
- true is successful, false is switch has not connected or is unknown to the system.
-
activateEqualSwitch
public final boolean activateEqualSwitch()
Description copied from interface:OpenFlowSwitchDriverActivate this EQUAL switch-controller relationship in the OF agent.- Specified by:
activateEqualSwitchin interfaceOpenFlowSwitchDriver- Returns:
- true is successful, false is switch has not connected or is unknown to the system.
-
transitionToEqualSwitch
public final void transitionToEqualSwitch()
Description copied from interface:OpenFlowSwitchDriverTransition this switch-controller relationship to an EQUAL state.- Specified by:
transitionToEqualSwitchin interfaceOpenFlowSwitchDriver
-
transitionToMasterSwitch
public final void transitionToMasterSwitch()
Description copied from interface:OpenFlowSwitchDriverTransition this switch-controller relationship to an Master state.- Specified by:
transitionToMasterSwitchin interfaceOpenFlowSwitchDriver
-
removeConnectedSwitch
public final void removeConnectedSwitch()
Description copied from interface:OpenFlowSwitchDriverRemove this switch from the openflow agent.- Specified by:
removeConnectedSwitchin interfaceOpenFlowSwitchDriver
-
factory
public org.projectfloodlight.openflow.protocol.OFFactory factory()
Description copied from interface:OpenFlowSwitchProvides the factory for this OF version.- Specified by:
factoryin interfaceOpenFlowSwitch- Returns:
- OF version specific factory.
-
setPortDescReply
public void setPortDescReply(org.projectfloodlight.openflow.protocol.OFPortDescStatsReply portDescReply)
Description copied from interface:OpenFlowSwitchDriverSets the ports on this switch.- Specified by:
setPortDescReplyin interfaceOpenFlowSwitchDriver- Parameters:
portDescReply- the port set and descriptions
-
replacePortDescsWith
protected void replacePortDescsWith(java.util.Collection<org.projectfloodlight.openflow.protocol.OFPortDesc> allPorts)
-
portDescs
protected java.util.Map<org.projectfloodlight.openflow.types.OFPort,org.projectfloodlight.openflow.protocol.OFPortDesc> portDescs()
-
setPortDescReplies
public void setPortDescReplies(java.util.List<org.projectfloodlight.openflow.protocol.OFPortDescStatsReply> portDescReplies)
Description copied from interface:OpenFlowSwitchDriverSets the ports on this switch.- Specified by:
setPortDescRepliesin interfaceOpenFlowSwitchDriver- Parameters:
portDescReplies- list of port set and descriptions
-
returnRoleReply
public void returnRoleReply(RoleState requested, RoleState response)
Description copied from interface:OpenFlowSwitchNotifies the controller that the device has responded to a set-role request.- Specified by:
returnRoleReplyin interfaceOpenFlowSwitch- Parameters:
requested- the role requested by the controllerresponse- the role set at the device
-
startDriverHandshake
public abstract void startDriverHandshake()
Description copied from interface:OpenFlowSwitchDriverStarts the driver specific handshake process.- Specified by:
startDriverHandshakein interfaceOpenFlowSwitchDriver
-
isDriverHandshakeComplete
public abstract boolean isDriverHandshakeComplete()
Description copied from interface:OpenFlowSwitchDriverChecks whether the driver specific handshake is complete.- Specified by:
isDriverHandshakeCompletein interfaceOpenFlowSwitchDriver- Returns:
- true is finished, false if not.
-
processDriverHandshakeMessage
public abstract void processDriverHandshakeMessage(org.projectfloodlight.openflow.protocol.OFMessage m)
Description copied from interface:OpenFlowSwitchDriverProcess a message during the driver specific handshake.- Specified by:
processDriverHandshakeMessagein interfaceOpenFlowSwitchDriver- Parameters:
m- the message to process.
-
setRole
public void setRole(RoleState role)
Description copied from interface:OpenFlowSwitchSets the role for this switch.- Specified by:
setRolein interfaceOpenFlowSwitch- Parameters:
role- the role to set.
-
reassertRole
public void reassertRole()
Description copied from interface:OpenFlowSwitchDriverReasserts this controllers role to the switch. Useful in cases where the switch no longer agrees that this controller has the role it claims.- Specified by:
reassertRolein interfaceOpenFlowSwitchDriver
-
handleRole
public void handleRole(org.projectfloodlight.openflow.protocol.OFMessage m) throws SwitchStateExceptionDescription copied from interface:OpenFlowSwitchDriverHandle OF 1.x (where x > 0) role messages.- Specified by:
handleRolein interfaceOpenFlowSwitchDriver- Parameters:
m- the role message to handle- Throws:
SwitchStateException- if the message received was not a nicira role or was malformed.
-
handleNiciraRole
public void handleNiciraRole(org.projectfloodlight.openflow.protocol.OFMessage m) throws SwitchStateExceptionDescription copied from interface:OpenFlowSwitchDriverIf this driver know of Nicira style role messages, these should be handled here.- Specified by:
handleNiciraRolein interfaceOpenFlowSwitchDriver- Parameters:
m- the role message to handle.- Throws:
SwitchStateException- if the message received was not a nicira role or was malformed.
-
handleRoleError
public boolean handleRoleError(org.projectfloodlight.openflow.protocol.OFErrorMsg error)
Description copied from interface:OpenFlowSwitchDriverHandle the situation where the role request triggers an error.- Specified by:
handleRoleErrorin interfaceOpenFlowSwitchDriver- Parameters:
error- the error to handle.- Returns:
- true if handled, false if not.
-
setAgent
public final void setAgent(OpenFlowAgent ag)
Description copied from interface:OpenFlowSwitchDriverSets the OpenFlow agent to be used. This method can only be called once.- Specified by:
setAgentin interfaceOpenFlowSwitchDriver- Parameters:
ag- the agent to set.
-
setRoleHandler
public final void setRoleHandler(RoleHandler roleHandler)
Description copied from interface:OpenFlowSwitchDriverSets the Role handler object. This method can only be called once.- Specified by:
setRoleHandlerin interfaceOpenFlowSwitchDriver- Parameters:
roleHandler- the roleHandler class
-
setSwitchDescription
public void setSwitchDescription(org.projectfloodlight.openflow.protocol.OFDescStatsReply d)
Description copied from interface:OpenFlowSwitchDriverSets the switch description.- Specified by:
setSwitchDescriptionin interfaceOpenFlowSwitchDriver- Parameters:
d- the descriptions
-
getNextTransactionId
public int getNextTransactionId()
Description copied from interface:OpenFlowSwitchDriverGets the next transaction id to use.- Specified by:
getNextTransactionIdin interfaceOpenFlowSwitchDriver- Returns:
- the xid
-
getPorts
public java.util.List<org.projectfloodlight.openflow.protocol.OFPortDesc> getPorts()
Description copied from interface:OpenFlowSwitchFetches the ports of this switch.- Specified by:
getPortsin interfaceOpenFlowSwitch- Returns:
- unmodifiable list of the ports.
-
getMeterFeatures
public org.projectfloodlight.openflow.protocol.OFMeterFeatures getMeterFeatures()
Description copied from interface:OpenFlowSwitchFetches the meter features of this switch.- Specified by:
getMeterFeaturesin interfaceOpenFlowSwitch- Returns:
- unmodifiable meter features
-
features
public org.projectfloodlight.openflow.protocol.OFFeaturesReply features()
Description copied from interface:OpenFlowSwitchFetches the features of this switch.- Specified by:
featuresin interfaceOpenFlowSwitch- Returns:
- unmodifiable features
-
manufacturerDescription
public java.lang.String manufacturerDescription()
Description copied from interface:OpenFlowSwitchfetch the manufacturer description.- Specified by:
manufacturerDescriptionin interfaceOpenFlowSwitch- Returns:
- the description
-
datapathDescription
public java.lang.String datapathDescription()
Description copied from interface:OpenFlowSwitchfetch the datapath description.- Specified by:
datapathDescriptionin interfaceOpenFlowSwitch- Returns:
- the description
-
hardwareDescription
public java.lang.String hardwareDescription()
Description copied from interface:OpenFlowSwitchfetch the hardware description.- Specified by:
hardwareDescriptionin interfaceOpenFlowSwitch- Returns:
- the description
-
softwareDescription
public java.lang.String softwareDescription()
Description copied from interface:OpenFlowSwitchfetch the software description.- Specified by:
softwareDescriptionin interfaceOpenFlowSwitch- Returns:
- the description
-
serialNumber
public java.lang.String serialNumber()
Description copied from interface:OpenFlowSwitchfetch the serial number.- Specified by:
serialNumberin interfaceOpenFlowSwitch- Returns:
- the serial
-
deviceType
public org.onosproject.net.Device.Type deviceType()
Description copied from interface:OpenFlowSwitchReturns the switch device type.- Specified by:
deviceTypein interfaceOpenFlowSwitch- Returns:
- device type
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-