public class OFMDeviceManager extends OFModule implements IDeviceService, ITopologyListener, IEntityClassListener, IInfoProvider, IFlowReconcileListener
Modified the original DeviceManagerImpl class of Floodlight.
IDeviceService.DeviceFieldIListener.Command| Modifier and Type | Field and Description |
|---|---|
private Devices |
devices
All the devices that you want.
|
private static int |
ENTITY_CLEANUP_INTERVAL
Time in seconds between cleaning up old entities/devices
|
private static int |
ENTITY_TIMEOUT
Time in milliseconds before entities will expire
|
private IEntityClassifierService |
entityClassifier |
private static IEntityClassifierService |
entityClassifierServiceCache |
private static OFMDeviceManager |
ofmDeviceManagerCache |
private ITopologyService |
topology |
private static ITopologyService |
topologyServiceCache |
controller| Constructor and Description |
|---|
OFMDeviceManager() |
| Modifier and Type | Method and Description |
|---|---|
void |
addIndex(boolean perClass,
java.util.EnumSet<IDeviceService.DeviceField> keyFields)
Creates an index over a set of fields.
|
void |
addListener(IDeviceListener listener)
Adds a listener to listen for IDeviceManagerServices notifications.
|
void |
addSuppressAPs(long swId,
short port)
Specifies points in the network where attachment points are not to
be learned.
|
private void |
cleanupEntities()
Cleans up expired entities/devices.
|
void |
entityClassChanged(java.util.Set<java.lang.String> entityClassNames)
Processes entity classes change event.
|
IDevice |
findDestDevice(IDevice source,
long macAddress,
java.lang.Short vlan,
java.lang.Integer ipv4Address)
Gets a destination device using entity fields that corresponds with
the given source device.
|
IDevice |
findDevice(long macAddress,
java.lang.Short vlan,
java.lang.Integer ipv4Address,
java.lang.Long switchDPID,
java.lang.Integer switchPort)
Searches for a device exactly matching the provided device fields.
|
java.util.Collection<? extends IDevice> |
getAllDevices()
Gets an unmodifiable collection view over all devices currently known.
|
private Entity |
getDestEntityFromPacket(Ethernet eth)
Gets a (partial) entity for the destination from the packet.
|
IDevice |
getDevice(java.lang.Long deviceKey)
Gets the device with the given device key.
|
static IEntityClassifierService |
getEntityClassifierServiceRef() |
java.util.Map<java.lang.String,java.lang.Object> |
getInfo(java.lang.String type)
Called when rest API requests information of a particular type
|
OFModel[] |
getModels()
returns the array of all
OFModel objects associated with this module. |
java.lang.String |
getName()
The name assigned to this listener
|
static OFMDeviceManager |
getRef() |
private Entity |
getSourceEntityFromPacket(Ethernet eth,
long swdpid,
int port)
Parses an entity from an
Ethernet packet. |
private int |
getSrcNwAddr(Ethernet eth,
long dlAddr)
Gets IP address from packet if the packet is either an ARP a DHCP packet.
|
ITopologyService |
getTopologyService()
Returns the reference of the topology service.
|
static ITopologyService |
getTopologyServiceRef() |
protected boolean |
handleDisconnect(Connection conn)
Process the disconnection event from a switch.
|
protected boolean |
handleHandshakedEvent(Connection conn,
MessageContext context)
An abstract method that all subclasses should implement.
|
protected boolean |
handleMessage(Connection conn,
MessageContext context,
org.openflow.protocol.OFMessage msg,
java.util.List<org.openflow.protocol.OFMessage> outgoing)
Handle incoming messages that pass the test of filters.
|
protected void |
initialize()
Initializes this module.
|
boolean |
isCallbackOrderingPostreq(org.openflow.protocol.OFType type,
java.lang.String name)
Check if the module called name is a callback ordering post-requisite
for this module.
|
boolean |
isCallbackOrderingPrereq(org.openflow.protocol.OFType type,
java.lang.String name)
Check if the module called name is a callback ordering prerequisite
for this module.
|
private boolean |
processPacketInMessage(IOFSwitch sw,
org.openflow.protocol.OFPacketIn pi,
MessageContext cntx) |
java.util.Iterator<Device> |
queryClassByEntity(IEntityClass clazz,
java.util.EnumSet<IDeviceService.DeviceField> keyFields,
Entity entity) |
java.util.Iterator<? extends IDevice> |
queryClassDevices(IDevice reference,
java.lang.Long macAddress,
java.lang.Short vlan,
java.lang.Integer ipv4Address,
java.lang.Long switchDPID,
java.lang.Integer switchPort)
Finds devices that match the provided query.
|
java.util.Iterator<? extends IDevice> |
queryDevices(java.lang.Long macAddress,
java.lang.Short vlan,
java.lang.Integer ipv4Address,
java.lang.Long switchDPID,
java.lang.Integer switchPort)
Finds devices that match the provided query.
|
IListener.Command |
reconcileFlows(java.util.ArrayList<OFMatchReconcile> ofmRcList)
Given an input OFMatch, this method applies the policy of the reconciler
and returns a the same input OFMatch structure modified.
|
void |
removeSuppressAPs(long swId,
short port)
Removes setting of points in the network where attachment points
are not to be learned.
|
void |
topologyChanged()
Happens when the switch clusters are recomputed
|
getController, getModule, init, processDisconnect, processHandshakeFinished, processMessage, registerFilter, registerModuleprivate static final int ENTITY_TIMEOUT
private static final int ENTITY_CLEANUP_INTERVAL
private ITopologyService topology
private IEntityClassifierService entityClassifier
private static ITopologyService topologyServiceCache
private static IEntityClassifierService entityClassifierServiceCache
private static OFMDeviceManager ofmDeviceManagerCache
public static ITopologyService getTopologyServiceRef()
public static IEntityClassifierService getEntityClassifierServiceRef()
public static OFMDeviceManager getRef()
protected void initialize()
initialize in class OFModuleprivate void cleanupEntities()
protected boolean handleHandshakedEvent(Connection conn, MessageContext context)
OFModuleOFModule.processHandshakeFinished(Connection, MessageContext).
Normally, most of modules have very simple implementation for this method,
only returning true.handleHandshakedEvent in class OFModuleconn - 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)
OFModuleOFModule.processMessage(Connection, MessageContext, OFMessage, List).handleMessage in class OFModuleconn - 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 implementationprivate boolean processPacketInMessage(IOFSwitch sw, org.openflow.protocol.OFPacketIn pi, MessageContext cntx)
protected boolean handleDisconnect(Connection conn)
OFModuleOFModule.processDisconnect(Connection).
All subclasses of OFModule should implement this method.handleDisconnect in class OFModuleconn - connection that the event has occurredprivate Entity getSourceEntityFromPacket(Ethernet eth, long swdpid, int port)
Ethernet packet.eth - the packet to parseswdpid - the switch on which the packet arrivedport - the original packetinprivate int getSrcNwAddr(Ethernet eth, long dlAddr)
eth - the Ethernet packetdlAddr - the Ethernet addressprivate Entity getDestEntityFromPacket(Ethernet eth)
eth - the Ethernet packetpublic ITopologyService getTopologyService()
public java.util.Iterator<Device> queryClassByEntity(IEntityClass clazz, java.util.EnumSet<IDeviceService.DeviceField> keyFields, Entity entity)
public IDevice getDevice(java.lang.Long deviceKey)
IDeviceServicegetDevice in interface IDeviceServicedeviceKey - the key to search forIDevice.getDeviceKey()public IDevice findDevice(long macAddress, java.lang.Short vlan, java.lang.Integer ipv4Address, java.lang.Long switchDPID, java.lang.Integer switchPort) throws java.lang.IllegalArgumentException
IDeviceService
Only the key fields as defined by the IEntityClassifierService will
be important in this search. All key fields MUST be supplied.
IDeviceService.queryDevices(java.lang.Long, java.lang.Short, java.lang.Integer, java.lang.Long, java.lang.Integer) might be more appropriate!
findDevice in interface IDeviceServicemacAddress - The MAC addressvlan - the VLAN. Null means no VLAN and is valid even if VLAN is a key field.ipv4Address - the ipv4 addressswitchDPID - the switch dpidswitchPort - the switch portIDevice or null if no device is found.java.lang.IllegalArgumentException - if not all key fields of the
current IEntityClassifierService are specified.public IDevice findDestDevice(IDevice source, long macAddress, java.lang.Short vlan, java.lang.Integer ipv4Address) throws java.lang.IllegalArgumentException
IDeviceServicefindDestDevice in interface IDeviceServicesource - the source device. The returned destination will be
in the same entity class as the source.macAddress - The MAC address for the destinationvlan - the VLAN if availableipv4Address - The IP address if available.IDevice or null if no device is found.java.lang.IllegalArgumentException - if not all key fields of the
source's IEntityClass are specified.IDeviceService.findDevice(long, Short, Integer, Long, Integer)public java.util.Collection<? extends IDevice> getAllDevices()
IDeviceServicegetAllDevices in interface IDeviceServicepublic void addIndex(boolean perClass,
java.util.EnumSet<IDeviceService.DeviceField> keyFields)
IDeviceServiceaddIndex in interface IDeviceServiceperClass - set to true if the index should be maintained for each
entity class separately.keyFields - the set of fields on which to indexpublic java.util.Iterator<? extends IDevice> queryDevices(java.lang.Long macAddress, java.lang.Short vlan, java.lang.Integer ipv4Address, java.lang.Long switchDPID, java.lang.Integer switchPort)
IDeviceServicequeryDevices in interface IDeviceServicemacAddress - The MAC addressvlan - the VLANipv4Address - the ipv4 addressswitchDPID - the switch dpidswitchPort - the switch portpublic java.util.Iterator<? extends IDevice> queryClassDevices(IDevice reference, java.lang.Long macAddress, java.lang.Short vlan, java.lang.Integer ipv4Address, java.lang.Long switchDPID, java.lang.Integer switchPort)
IDeviceServicequeryClassDevices in interface IDeviceServicereference - The reference device to refer to when finding
entity classes.macAddress - The MAC addressvlan - the VLANipv4Address - the ipv4 addressswitchDPID - the switch dpidswitchPort - the switch portpublic void addListener(IDeviceListener listener)
IDeviceServiceaddListener in interface IDeviceServicelistener - The listener that wants the notificationspublic void addSuppressAPs(long swId,
short port)
IDeviceServiceaddSuppressAPs in interface IDeviceServiceswId - a switchidport - a port numberpublic void removeSuppressAPs(long swId,
short port)
IDeviceServiceremoveSuppressAPs in interface IDeviceServiceswId - a switchidport - a port numberpublic void topologyChanged()
ITopologyListenertopologyChanged in interface ITopologyListenerpublic void entityClassChanged(java.util.Set<java.lang.String> entityClassNames)
IEntityClassListenerentityClassChanged in interface IEntityClassListenerentityClassNames - A set of entity classes changedpublic java.util.Map<java.lang.String,java.lang.Object> getInfo(java.lang.String type)
IInfoProvidergetInfo in interface IInfoProviderpublic java.lang.String getName()
IListenerpublic boolean isCallbackOrderingPrereq(org.openflow.protocol.OFType type,
java.lang.String name)
IListenerisCallbackOrderingPrereq in interface IListener<org.openflow.protocol.OFType>type - the message type to which this appliesname - the name of the modulepublic boolean isCallbackOrderingPostreq(org.openflow.protocol.OFType type,
java.lang.String name)
IListenerisCallbackOrderingPostreq in interface IListener<org.openflow.protocol.OFType>type - the message type to which this appliesname - the name of the modulepublic IListener.Command reconcileFlows(java.util.ArrayList<OFMatchReconcile> ofmRcList)
IFlowReconcileListenerreconcileFlows in interface IFlowReconcileListenerofmRcList - input flow matches, to be updated to be consistent with
the policies of this reconciler
Additional OFMatch-es can be added to the "list" as
needed.
For example after a new ACL application, one flow-match
may result in multiple flow-matches
The method must also update the ReconcileAction
member in ofmRcList entries to indicate if the
flow needs to be modified, deleted or left unchanged
OR of a new entry is to be added after flow
reconciliation