public class OFMStaticFlowEntryPusher extends OFModule implements IStaticFlowEntryPusherService
This module is responsible for maintaining a set of static flows on switches. This is just a big dumb list of flows and something external is responsible for ensuring they make sense for the network.
This module implements the IStaticFlowEntryPusherService
.
Modifier and Type | Class and Description |
---|---|
(package private) class |
OFMStaticFlowEntryPusher.FlowModSorter
Class to sort FlowMod's by priority, from lowest to highest
|
Modifier and Type | Field and Description |
---|---|
protected StaticFlowEntryStorage |
staticFlowEntryStorage |
controller
Constructor and Description |
---|
OFMStaticFlowEntryPusher() |
Modifier and Type | Method and Description |
---|---|
void |
addedSwitch(IOFSwitch sw)
If this method is called, it sends entries to switch by calling
sendEntriesToSwitch(IOFSwitch) . |
void |
addFlow(java.lang.String name,
org.openflow.protocol.OFFlowMod fm,
java.lang.String swDpid)
Adds a static flow.
|
boolean |
addFlowEntry(java.util.Map<java.lang.String,java.lang.Object> entry)
add a flow mod record.
|
void |
deleteAllFlows()
Deletes all flows.
|
boolean |
deleteFlow(java.lang.String flowName)
delete flow by the given flowName
|
void |
deleteFlows(java.util.Set<java.lang.String> names)
delete a specific set of flow mod records
|
void |
deleteFlowsForSwitch(long dpid)
Deletes all static flows for a practicular switch
|
void |
entriesModified(java.util.Set<java.lang.String> entryNames)
This handles both rowInsert() and rowUpdate()
|
java.util.Map<java.lang.String,java.util.Map<java.lang.String,org.openflow.protocol.OFFlowMod>> |
getFlows()
Gets all list of all flows.
|
java.util.Map<java.lang.String,org.openflow.protocol.OFFlowMod> |
getFlows(java.lang.String dpid)
Gets a list of flows by switch.
|
OFModel[] |
getModels()
returns the array of all
OFModel objects associated with this module. |
StaticFlowEntryStorage |
getStaticFlowEntryStorage()
Return the
StaticFlowEntryStorage object. |
protected boolean |
handleDisconnect(Connection conn)
Process the disconnection event from a switch.
|
protected boolean |
handleHandshakedEvent(Connection conn,
MessageContext context)
This method only returns true, which means no module-specific operations are required.
|
protected boolean |
handleMessage(Connection conn,
MessageContext context,
org.openflow.protocol.OFMessage msg,
java.util.List<org.openflow.protocol.OFMessage> outgoing)
This method only returns true, which means no module-specific operations are required.
|
protected void |
initialize()
This method does initialization as follows:
register this module as an implementation of the
IStaticFlowEntryPusherService . |
void |
removedSwitch(IOFSwitch sw)
This does nothing currently, except for emitting some log messages.
|
protected void |
sendEntriesToSwitch(IOFSwitch sw)
Reads from our entriesFromStorage for the specified switch and sends the
FlowMods down to the controller in sorted order.
|
void |
switchPortChanged(java.lang.Long switchId)
This method currently does nothing.
|
private void |
writeFlowModToSwitch(IOFSwitch sw,
org.openflow.protocol.OFFlowMod flowMod)
Writes an OFFlowMod to a switch.
|
private void |
writeFlowModToSwitch(long dpid,
org.openflow.protocol.OFFlowMod flowMod)
Writes an OFFlowMod to a switch.
|
private void |
writeOFMessagesToSwitch(long dpid,
java.util.List<org.openflow.protocol.OFMessage> messages)
Writes a list of OFMessages to a switch.
|
getController, getModule, init, processDisconnect, processHandshakeFinished, processMessage, registerFilter, registerModule
protected StaticFlowEntryStorage staticFlowEntryStorage
protected void initialize()
IStaticFlowEntryPusherService
.
StaticFlowEntryStorage
object and starts it
initialize
in class OFModule
protected boolean handleHandshakedEvent(Connection conn, MessageContext context)
handleHandshakedEvent
in class OFModule
conn
- connection that the event has occurredcontext
- message context for the handshaking messagesprotected boolean handleMessage(Connection conn, MessageContext context, org.openflow.protocol.OFMessage msg, java.util.List<org.openflow.protocol.OFMessage> outgoing)
handleMessage
in class OFModule
conn
- connection that the message has arrivedcontext
- message context for the messagemsg
- the actual message objectoutgoing
- responses for the message arrived, which is filled by the handleMessage implementationpublic OFModel[] getModels()
OFModule
OFModel
objects associated with this module.
Normally the size of the array is one, but not limited to.protected void sendEntriesToSwitch(IOFSwitch sw)
Reads from our entriesFromStorage for the specified switch and sends the FlowMods down to the controller in sorted order.
Sorted is important to maintain correctness of the switch: if a packet would match both a lower and a higher priority rule, then we want it to match the higher priority or nothing, but never just the lower priority one. Inserting from high to low priority fixes this.
TODO consider adding a "block all" flow mod and then removing it while starting up.
sw
- The switch to send entries topublic void addedSwitch(IOFSwitch sw)
If this method is called, it sends entries to switch by calling
sendEntriesToSwitch(IOFSwitch)
.
WARNING: currently, this method is called by nowhere.
sw
- public void removedSwitch(IOFSwitch sw)
sw
- public void switchPortChanged(java.lang.Long switchId)
switchId
- public void entriesModified(java.util.Set<java.lang.String> entryNames)
private void writeOFMessagesToSwitch(long dpid, java.util.List<org.openflow.protocol.OFMessage> messages)
dpid
- The datapath ID of the switch to write tomessages
- The list of OFMessages to write.public void deleteFlows(java.util.Set<java.lang.String> names)
names
- names of the flod-mod recordspublic void deleteAllFlows()
IStaticFlowEntryPusherService
deleteAllFlows
in interface IStaticFlowEntryPusherService
public boolean deleteFlow(java.lang.String flowName)
deleteFlow
in interface IStaticFlowEntryPusherService
flowName
- the name of the flow mod record.private void writeFlowModToSwitch(long dpid, org.openflow.protocol.OFFlowMod flowMod)
dpid
- The data to write the flow mod toflowMod
- The OFFlowMod to writeprivate void writeFlowModToSwitch(IOFSwitch sw, org.openflow.protocol.OFFlowMod flowMod)
sw
- The IOFSwitch to write toflowMod
- The OFFlowMod to writepublic boolean addFlowEntry(java.util.Map<java.lang.String,java.lang.Object> entry)
entry
- flow mod record with map representation ('name' is included).public void addFlow(java.lang.String name, org.openflow.protocol.OFFlowMod fm, java.lang.String swDpid)
IStaticFlowEntryPusherService
addFlow
in interface IStaticFlowEntryPusherService
name
- Name of the flow mod. Must be unique.fm
- The flow to push.swDpid
- The switch DPID to push it to, in 00:00:00:00:00:00:00:01 notation.public void deleteFlowsForSwitch(long dpid)
IStaticFlowEntryPusherService
deleteFlowsForSwitch
in interface IStaticFlowEntryPusherService
dpid
- The DPID of the switch to delete flows for.public java.util.Map<java.lang.String,java.util.Map<java.lang.String,org.openflow.protocol.OFFlowMod>> getFlows()
IStaticFlowEntryPusherService
getFlows
in interface IStaticFlowEntryPusherService
public java.util.Map<java.lang.String,org.openflow.protocol.OFFlowMod> getFlows(java.lang.String dpid)
IStaticFlowEntryPusherService
getFlows
in interface IStaticFlowEntryPusherService
protected boolean handleDisconnect(Connection conn)
OFModule
OFModule.processDisconnect(Connection)
.
All subclasses of OFModule should implement this method.handleDisconnect
in class OFModule
conn
- connection that the event has occurredpublic StaticFlowEntryStorage getStaticFlowEntryStorage()
StaticFlowEntryStorage
object.StaticFlowEntryStorage
object.