Skip to content
Snippets Groups Projects
Commit a2292465 authored by Ryan Izard's avatar Ryan Izard
Browse files

Quick fix for OF1.0. Should find a way so that all modules don't have to worry...

Quick fix for OF1.0. Should find a way so that all modules don't have to worry about how to get Match from PI. OF1.0-1.2 use pi.getInPort(); OF1.3 uses pi.getMatch(MatchField.IN_PORT). Workaroud is: (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT))
parent 87b907ef
No related branches found
No related tags found
No related merge requests found
...@@ -179,8 +179,8 @@ public class Controller implements IFloodlightProviderService, IStorageSourceLis ...@@ -179,8 +179,8 @@ public class Controller implements IFloodlightProviderService, IStorageSourceLis
FLOW_COLUMN_CORE_PRIORITY FLOW_COLUMN_CORE_PRIORITY
}; };
private static short DEFAULT_ACCESS_PRIORITY = 10; // TODO @Ryan delete? not referenced anywhere private static short DEFAULT_ACCESS_PRIORITY = 10;
private static short DEFAULT_CORE_PRIORITY = 1000; // TODO @Ryan delete? not referenced anywhere private static short DEFAULT_CORE_PRIORITY = 1000;
// Perf. related configuration // Perf. related configuration
protected static final int SEND_BUFFER_SIZE = 128 * 1024; protected static final int SEND_BUFFER_SIZE = 128 * 1024;
...@@ -833,10 +833,10 @@ public class Controller implements IFloodlightProviderService, IStorageSourceLis ...@@ -833,10 +833,10 @@ public class Controller implements IFloodlightProviderService, IStorageSourceLis
String primary_key = (String) row.get(FLOW_COLUMN_PRIMARY_KEY); String primary_key = (String) row.get(FLOW_COLUMN_PRIMARY_KEY);
if (primary_key.equals(FLOW_VALUE_PRIMARY_KEY)) { if (primary_key.equals(FLOW_VALUE_PRIMARY_KEY)) {
if (row.containsKey(FLOW_COLUMN_ACCESS_PRIORITY)) { if (row.containsKey(FLOW_COLUMN_ACCESS_PRIORITY)) {
DEFAULT_ACCESS_PRIORITY = Short.valueOf((String) row.get(FLOW_COLUMN_ACCESS_PRIORITY)); //TODO @Ryan delete? Not referenced anywhere DEFAULT_ACCESS_PRIORITY = Short.valueOf((String) row.get(FLOW_COLUMN_ACCESS_PRIORITY));
} }
if (row.containsKey(FLOW_COLUMN_CORE_PRIORITY)) { if (row.containsKey(FLOW_COLUMN_CORE_PRIORITY)) {
DEFAULT_CORE_PRIORITY = Short.valueOf((String) row.get(FLOW_COLUMN_CORE_PRIORITY)); //TODO @Ryan delete? Not referenced anywhere DEFAULT_CORE_PRIORITY = Short.valueOf((String) row.get(FLOW_COLUMN_CORE_PRIORITY));
} }
} }
} }
......
...@@ -31,9 +31,7 @@ import net.floodlightcontroller.core.module.FloodlightModuleException; ...@@ -31,9 +31,7 @@ import net.floodlightcontroller.core.module.FloodlightModuleException;
import net.floodlightcontroller.core.module.IFloodlightModule; import net.floodlightcontroller.core.module.IFloodlightModule;
import net.floodlightcontroller.core.module.IFloodlightService; import net.floodlightcontroller.core.module.IFloodlightService;
import org.projectfloodlight.openflow.protocol.OFFactories;
import org.projectfloodlight.openflow.protocol.OFFlowAdd; import org.projectfloodlight.openflow.protocol.OFFlowAdd;
import org.projectfloodlight.openflow.protocol.OFFlowMod;
import org.projectfloodlight.openflow.protocol.OFMessage; import org.projectfloodlight.openflow.protocol.OFMessage;
import org.projectfloodlight.openflow.protocol.OFPacketIn; import org.projectfloodlight.openflow.protocol.OFPacketIn;
import org.projectfloodlight.openflow.protocol.OFPacketOut; import org.projectfloodlight.openflow.protocol.OFPacketOut;
...@@ -41,23 +39,18 @@ import org.projectfloodlight.openflow.protocol.OFType; ...@@ -41,23 +39,18 @@ import org.projectfloodlight.openflow.protocol.OFType;
import org.projectfloodlight.openflow.protocol.OFVersion; import org.projectfloodlight.openflow.protocol.OFVersion;
import org.projectfloodlight.openflow.protocol.action.OFAction; import org.projectfloodlight.openflow.protocol.action.OFAction;
import org.projectfloodlight.openflow.protocol.action.OFActionOutput; import org.projectfloodlight.openflow.protocol.action.OFActionOutput;
import org.projectfloodlight.openflow.protocol.match.Match;
import org.projectfloodlight.openflow.protocol.match.MatchField; import org.projectfloodlight.openflow.protocol.match.MatchField;
import org.projectfloodlight.openflow.types.OFBufferId; import org.projectfloodlight.openflow.types.OFBufferId;
import org.projectfloodlight.openflow.types.OFPort; import org.projectfloodlight.openflow.types.OFPort;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sun.awt.OrientableFlowLayout;
/** /**
* *
* @author David Erickson (daviderickson@cs.stanford.edu) - 04/04/10 * @author David Erickson (daviderickson@cs.stanford.edu) - 04/04/10
*/ */
public class Hub implements IFloodlightModule, IOFMessageListener { public class Hub implements IFloodlightModule, IOFMessageListener {
protected static Logger log = LoggerFactory.getLogger(Hub.class); private enum HubType {USE_PACKET_OUT, USE_FLOW_MOD};
protected IFloodlightProviderService floodlightProvider; private IFloodlightProviderService floodlightProvider;
/** /**
* @param floodlightProvider the floodlightProvider to set * @param floodlightProvider the floodlightProvider to set
...@@ -72,8 +65,17 @@ public class Hub implements IFloodlightModule, IOFMessageListener { ...@@ -72,8 +65,17 @@ public class Hub implements IFloodlightModule, IOFMessageListener {
} }
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) { public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
//OFMessage outMessage = createHubPacketOut(sw, msg); OFMessage outMessage;
OFMessage outMessage = createHubFlowMod(sw, msg); HubType ht = HubType.USE_FLOW_MOD;
switch (ht) {
case USE_FLOW_MOD:
outMessage = createHubFlowMod(sw, msg);
break;
default:
case USE_PACKET_OUT:
outMessage = createHubPacketOut(sw, msg);
break;
}
sw.write(outMessage); sw.write(outMessage);
return Command.CONTINUE; return Command.CONTINUE;
...@@ -81,33 +83,30 @@ public class Hub implements IFloodlightModule, IOFMessageListener { ...@@ -81,33 +83,30 @@ public class Hub implements IFloodlightModule, IOFMessageListener {
private OFMessage createHubFlowMod(IOFSwitch sw, OFMessage msg) { private OFMessage createHubFlowMod(IOFSwitch sw, OFMessage msg) {
OFPacketIn pi = (OFPacketIn) msg; OFPacketIn pi = (OFPacketIn) msg;
OFFlowAdd.Builder fmb = /*sw.getOFFactory()*/OFFactories.getFactory(OFVersion.OF_13).buildFlowAdd(); OFFlowAdd.Builder fmb = sw.getOFFactory().buildFlowAdd();
//Match.Builder mb = OFFactories.getFactory(OFVersion.OF_13).buildMatch();
fmb.setBufferId(pi.getBufferId()) fmb.setBufferId(pi.getBufferId())
.setXid(pi.getXid()) .setXid(pi.getXid());
/*.setMatch(pi.getMatch())*/;
// set actions // set actions
OFActionOutput.Builder actionBuilder = /*sw.getOFFactory()*/OFFactories.getFactory(OFVersion.OF_13).actions().buildOutput(); OFActionOutput.Builder actionBuilder = sw.getOFFactory().actions().buildOutput();
actionBuilder.setPort(OFPort.ALL); actionBuilder.setPort(OFPort.FLOOD);
fmb.setActions(Collections.singletonList((OFAction) actionBuilder.build())); fmb.setActions(Collections.singletonList((OFAction) actionBuilder.build()));
fmb.setOutPort(OFPort.ALL);
return fmb.build(); return fmb.build();
} }
private OFMessage createHubPacketOut(IOFSwitch sw, OFMessage msg) { private OFMessage createHubPacketOut(IOFSwitch sw, OFMessage msg) {
OFPacketIn pi = (OFPacketIn) msg; OFPacketIn pi = (OFPacketIn) msg;
OFPacketOut.Builder pob = /*sw.getOFFactory()*/OFFactories.getFactory(OFVersion.OF_13).buildPacketOut(); OFPacketOut.Builder pob = sw.getOFFactory().buildPacketOut();
pob.setBufferId(pi.getBufferId()).setXid(pi.getXid()).setInPort(pi.getMatch().get(MatchField.IN_PORT)); pob.setBufferId(pi.getBufferId()).setXid(pi.getXid()).setInPort((pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)));
// set actions // set actions
OFActionOutput.Builder actionBuilder = /*sw.getOFFactory()*/OFFactories.getFactory(OFVersion.OF_13).actions().buildOutput(); OFActionOutput.Builder actionBuilder = sw.getOFFactory().actions().buildOutput();
actionBuilder.setPort(OFPort.FLOOD); actionBuilder.setPort(OFPort.FLOOD);
pob.setActions(Collections.singletonList((OFAction) actionBuilder.build())); pob.setActions(Collections.singletonList((OFAction) actionBuilder.build()));
// set data if is is included in the packetin // set data if it is included in the packetin
if (pi.getBufferId() == OFBufferId.NO_BUFFER) { if (pi.getBufferId() == OFBufferId.NO_BUFFER) {
byte[] packetData = pi.getData(); byte[] packetData = pi.getData();
pob.setData(packetData); pob.setData(packetData);
...@@ -152,8 +151,7 @@ public class Hub implements IFloodlightModule, IOFMessageListener { ...@@ -152,8 +151,7 @@ public class Hub implements IFloodlightModule, IOFMessageListener {
@Override @Override
public void init(FloodlightModuleContext context) public void init(FloodlightModuleContext context)
throws FloodlightModuleException { throws FloodlightModuleException {
floodlightProvider = floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class);
context.getServiceImpl(IFloodlightProviderService.class);
} }
@Override @Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment