public class OFMDeviceManager extends OFModule implements IDeviceService, ITopologyListener, IEntityClassListener, IInfoProvider, IFlowReconcileListener
Modified the original DeviceManagerImpl class of Floodlight.
IDeviceService.DeviceField
IListener.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
|
protected int |
getInputPort(org.openflow.protocol.interfaces.OFPacketIn pi) |
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,
IOFSwitch sw,
int ofPort)
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.
|
private boolean |
processPacketInMessage(IOFSwitch sw,
org.openflow.protocol.interfaces.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, registerModule
private 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 int getInputPort(org.openflow.protocol.interfaces.OFPacketIn pi)
protected void initialize()
initialize
in class OFModule
private void cleanupEntities()
protected boolean handleHandshakedEvent(Connection conn, MessageContext context)
OFModule
OFModule.processHandshakeFinished(Connection, MessageContext)
.
Normally, most of modules have very simple implementation for this method,
only returning true.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)
OFModule
OFModule.processMessage(Connection, MessageContext, OFMessage, List)
.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 implementationprivate boolean processPacketInMessage(IOFSwitch sw, org.openflow.protocol.interfaces.OFPacketIn pi, MessageContext cntx)
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 occurredprivate Entity getSourceEntityFromPacket(Ethernet eth, IOFSwitch sw, int ofPort)
Ethernet
packet.eth
- the packet to parsesw
- the switch on which the packet arrivedofPort
- 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)
IDeviceService
getDevice
in interface IDeviceService
deviceKey
- 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 IDeviceService
macAddress
- 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
IDeviceService
findDestDevice
in interface IDeviceService
source
- 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()
IDeviceService
getAllDevices
in interface IDeviceService
public void addIndex(boolean perClass, java.util.EnumSet<IDeviceService.DeviceField> keyFields)
IDeviceService
addIndex
in interface IDeviceService
perClass
- 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)
IDeviceService
queryDevices
in interface IDeviceService
macAddress
- 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)
IDeviceService
queryClassDevices
in interface IDeviceService
reference
- 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)
IDeviceService
addListener
in interface IDeviceService
listener
- The listener that wants the notificationspublic void addSuppressAPs(long swId, short port)
IDeviceService
addSuppressAPs
in interface IDeviceService
swId
- a switchidport
- a port numberpublic void removeSuppressAPs(long swId, short port)
IDeviceService
removeSuppressAPs
in interface IDeviceService
swId
- a switchidport
- a port numberpublic void topologyChanged()
ITopologyListener
topologyChanged
in interface ITopologyListener
public void entityClassChanged(java.util.Set<java.lang.String> entityClassNames)
IEntityClassListener
entityClassChanged
in interface IEntityClassListener
entityClassNames
- A set of entity classes changedpublic java.util.Map<java.lang.String,java.lang.Object> getInfo(java.lang.String type)
IInfoProvider
getInfo
in interface IInfoProvider
type
- type of the information (string)public java.lang.String getName()
IListener
public IListener.Command reconcileFlows(java.util.ArrayList<OFMatchReconcile> ofmRcList)
IFlowReconcileListener
reconcileFlows
in interface IFlowReconcileListener
ofmRcList
- 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