public final class OFMLearningMac extends OFModule
Modifier and Type | Field and Description |
---|---|
private static int |
APP_ID_BITS |
private static int |
APP_ID_SHIFT |
private static short |
HARD_TIMEOUT_DEFAULT |
private static short |
IDLE_TIMEOUT_DEFAULT |
private static int |
LEARNING_SWITCH_APP_ID |
private static long |
LEARNING_SWITCH_COOKIE |
private static boolean |
LEARNING_SWITCH_REVERSE_FLOW |
private java.util.Map<IOFSwitch,java.util.Map<MacVlanPair,java.lang.Short>> |
macVlanToSwitchPortMap
Table to save learning result.
|
private static int |
MAX_MACS_PER_SWITCH |
private static short |
PRIORITY_DEFAULT |
private OFProtocol |
protocol |
controller
Constructor and Description |
---|
OFMLearningMac()
Constructor to create learning mac module instance.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addToPortMap(IOFSwitch sw,
long mac,
short vlan,
short portVal)
Adds a host to the MAC/VLAN->SwitchPort mapping
|
void |
clearLearnedTable()
Clears the MAC/VLAN -> SwitchPort map for all switches
|
void |
clearLearnedTable(IOFSwitch sw)
Clears the MAC/VLAN -> SwitchPort map for a single switch
|
java.lang.Short |
getFromPortMap(IOFSwitch sw,
long mac,
short vlan)
Get the port that a MAC/VLAN pair is associated with
|
OFModel[] |
getModels()
As this module have no model, it just returns null
|
java.util.Map<IOFSwitch,java.util.Map<MacVlanPair,java.lang.Short>> |
getTable()
Get all the mappings between MAC/VLAN to switch port.
|
boolean |
handleDisconnect(Connection conn)
Handle disconnection to a switch.
|
protected boolean |
handleHandshakedEvent(Connection sw,
MessageContext context)
As this module does not process handshake event,
it just returns true.
|
boolean |
handleMessage(Connection conn,
MessageContext context,
org.openflow.protocol.OFMessage msg,
java.util.List<org.openflow.protocol.OFMessage> outgoing)
this method is a callback called by controller to request this module to
handle an incoming message.
|
protected void |
initialize()
Initialize this module.
|
byte[] |
longToBytes(long eth) |
private boolean |
processPacketInMessage(Connection conn,
MessageContext context,
org.openflow.protocol.OFMessage msg,
java.util.List<org.openflow.protocol.OFMessage> out)
Processes a OFPacketIn message.
|
protected void |
removeFromPortMap(IOFSwitch sw,
long mac,
short vlan)
Removes a host from the MAC/VLAN->SwitchPort mapping
|
private void |
swap(org.openflow.protocol.interfaces.OFOxm ethSrcOxm,
org.openflow.protocol.interfaces.OFOxm ethDstOxm) |
private void |
writeFlowMod(IOFSwitch sw,
org.openflow.protocol.interfaces.OFFlowModCommand command,
int bufferId,
org.openflow.protocol.interfaces.OFMatch match,
short outPort,
java.util.List<org.openflow.protocol.OFMessage> out)
Writes a OFFlowMod to a switch.
|
private void |
writePacketOutForPacketIn(IOFSwitch sw,
org.openflow.protocol.interfaces.OFPacketIn packetInMessage,
org.openflow.protocol.OFPort egressPort,
short getInputPort,
java.util.List<org.openflow.protocol.OFMessage> out)
Writes an OFPacketOut message to a switch.
|
getController, getModule, init, processDisconnect, processHandshakeFinished, processMessage, registerFilter, registerModule
private java.util.Map<IOFSwitch,java.util.Map<MacVlanPair,java.lang.Short>> macVlanToSwitchPortMap
private OFProtocol protocol
private static final int LEARNING_SWITCH_APP_ID
private static final int APP_ID_BITS
private static final int APP_ID_SHIFT
private static final long LEARNING_SWITCH_COOKIE
private static final short IDLE_TIMEOUT_DEFAULT
private static final short HARD_TIMEOUT_DEFAULT
private static final short PRIORITY_DEFAULT
private static final boolean LEARNING_SWITCH_REVERSE_FLOW
private static final int MAX_MACS_PER_SWITCH
public OFMLearningMac()
protected void addToPortMap(IOFSwitch sw, long mac, short vlan, short portVal)
sw
- The switch to add the mapping tomac
- The MAC address of the host to addvlan
- The VLAN that the host is onportVal
- The switchport that the host is onprotected void removeFromPortMap(IOFSwitch sw, long mac, short vlan)
sw
- The switch to remove the mapping frommac
- The MAC address of the host to removevlan
- The VLAN that the host is onpublic java.lang.Short getFromPortMap(IOFSwitch sw, long mac, short vlan)
sw
- The switch to get the mapping frommac
- The MAC address to getvlan
- The VLAN number to getpublic void clearLearnedTable()
public void clearLearnedTable(IOFSwitch sw)
sw
- The switch to clear the mapping forpublic java.util.Map<IOFSwitch,java.util.Map<MacVlanPair,java.lang.Short>> getTable()
private void writeFlowMod(IOFSwitch sw, org.openflow.protocol.interfaces.OFFlowModCommand command, int bufferId, org.openflow.protocol.interfaces.OFMatch match, short outPort, java.util.List<org.openflow.protocol.OFMessage> out)
sw
- The switch tow rite the flowmod to.command
- The FlowMod actions (add, delete, etc).bufferId
- The buffer ID if the switch has buffered the packet.match
- The OFMatch structure to write.outPort
- The switch port to output it to.private void writePacketOutForPacketIn(IOFSwitch sw, org.openflow.protocol.interfaces.OFPacketIn packetInMessage, org.openflow.protocol.OFPort egressPort, short getInputPort, java.util.List<org.openflow.protocol.OFMessage> out)
sw
- The switch to write the PacketOut to.packetInMessage
- The corresponding PacketIn.egressPort
- The switchport to output the PacketOut.public 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 was receivedcontext
- MessageContext object for the message.msg
- the received messageoutgoing
- list to put some outgoing messages to switch.public boolean handleDisconnect(Connection conn)
handleDisconnect
in class OFModule
conn
- connection to a switch (just disconnected)private boolean processPacketInMessage(Connection conn, MessageContext context, org.openflow.protocol.OFMessage msg, java.util.List<org.openflow.protocol.OFMessage> out)
conn
- Connection objectcontext
- MessageContext objectmsg
- OFMessage object (packet-in)out
- List of outgoing messages to switchprivate void swap(org.openflow.protocol.interfaces.OFOxm ethSrcOxm, org.openflow.protocol.interfaces.OFOxm ethDstOxm)
public final byte[] longToBytes(long eth)
protected void initialize()
initialize
in class OFModule
protected boolean handleHandshakedEvent(Connection sw, MessageContext context)
handleHandshakedEvent
in class OFModule
sw
- connection that the event has occurredcontext
- message context for the handshaking messages