public final class OFMLearningMac13 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  | 
protected static char[] | 
hexArray  | 
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 | 
version_adaptor_13  | 
controller| Constructor and Description | 
|---|
OFMLearningMac13()
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 
 | 
static java.lang.String | 
bytesToHex(byte[] bytes)  | 
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. 
 | 
boolean | 
processPacketInMessage(Connection conn,
                      MessageContext context,
                      org.openflow.protocol.OFMessage msg,
                      java.util.List<org.openflow.protocol.OFMessage> out)
Processes a OFPacketIn message. 
 | 
private short | 
readShort(byte[] data)  | 
protected void | 
removeFromPortMap(IOFSwitch sw,
                 long mac,
                 short vlan)
Removes a host from the MAC/VLAN->SwitchPort mapping 
 | 
static byte[] | 
toBytes(short s,
       short d)  | 
private void | 
writeFlowMod(IOFSwitch sw,
            short command,
            int bufferId,
            org.openflow.protocol.ver1_3.messages.OFMatchOxm matchOxm,
            short outPort,
            java.util.List<org.openflow.protocol.OFMessage> out)
Writes a OFFlowMod to a switch. 
 | 
private void | 
writePacketOutForPacketIn(IOFSwitch sw,
                         org.openflow.protocol.ver1_3.messages.OFPacketIn packetInMessage,
                         int 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, registerModuleprivate java.util.Map<IOFSwitch,java.util.Map<MacVlanPair,java.lang.Short>> macVlanToSwitchPortMap
private OFProtocol version_adaptor_13
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
protected static final char[] hexArray
public OFMLearningMac13()
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, short command, int bufferId, org.openflow.protocol.ver1_3.messages.OFMatchOxm matchOxm, 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.matchOxm - The OFMatch structure to write.outPort - The switch port to output it to.private void writePacketOutForPacketIn(IOFSwitch sw, org.openflow.protocol.ver1_3.messages.OFPacketIn packetInMessage, int egressPort, short getInputPort, java.util.List<org.openflow.protocol.OFMessage> out)
sw - The switch to write the PacketOut to.packetInMessage - The corresponding PacketIn.getInputPort - input portegressPort - The switchport to output the PacketOutout - messages to send to switchespublic boolean handleMessage(Connection conn, MessageContext context, org.openflow.protocol.OFMessage msg, java.util.List<org.openflow.protocol.OFMessage> outgoing)
handleMessage in class OFModuleconn - 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 OFModuleconn - connection to a switch (just disconnected)public static java.lang.String bytesToHex(byte[] bytes)
public static byte[] toBytes(short s,
             short d)
public 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 short readShort(byte[] data)
protected void initialize()
initialize in class OFModuleprotected boolean handleHandshakedEvent(Connection sw, MessageContext context)
handleHandshakedEvent in class OFModulesw - connection that the event has occurredcontext - message context for the handshaking messages