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

Merge pull request #547 from oxisto/feature/handle-outgoing

Feature/handle outgoing
parents e85b0bbb 834cf450
No related branches found
No related tags found
No related merge requests found
...@@ -715,6 +715,7 @@ public class OFSwitch implements IOFSwitchBackend { ...@@ -715,6 +715,7 @@ public class OFSwitch implements IOFSwitchBackend {
log.trace("Channel: {}, Connected: {}", connections.get(OFAuxId.MAIN).getRemoteInetAddress(), connections.get(OFAuxId.MAIN).isConnected()); log.trace("Channel: {}, Connected: {}", connections.get(OFAuxId.MAIN).getRemoteInetAddress(), connections.get(OFAuxId.MAIN).isConnected());
if (isActive()) { if (isActive()) {
connections.get(OFAuxId.MAIN).write(m); connections.get(OFAuxId.MAIN).write(m);
switchManager.handleOutgoingMessage(this, m);
} else { } else {
log.warn("Attempted to write to switch {} that is SLAVE.", this.getId().toString()); log.warn("Attempted to write to switch {} that is SLAVE.", this.getId().toString());
} }
...@@ -746,6 +747,7 @@ public class OFSwitch implements IOFSwitchBackend { ...@@ -746,6 +747,7 @@ public class OFSwitch implements IOFSwitchBackend {
public void write(OFMessage m, LogicalOFMessageCategory category) { public void write(OFMessage m, LogicalOFMessageCategory category) {
if (isActive()) { if (isActive()) {
this.getConnection(category).write(m); this.getConnection(category).write(m);
switchManager.handleOutgoingMessage(this, m);
} else { } else {
log.warn("Attempted to write to switch {} that is SLAVE.", this.getId().toString()); log.warn("Attempted to write to switch {} that is SLAVE.", this.getId().toString());
} }
...@@ -755,6 +757,10 @@ public class OFSwitch implements IOFSwitchBackend { ...@@ -755,6 +757,10 @@ public class OFSwitch implements IOFSwitchBackend {
public void write(Iterable<OFMessage> msglist, LogicalOFMessageCategory category) { public void write(Iterable<OFMessage> msglist, LogicalOFMessageCategory category) {
if (isActive()) { if (isActive()) {
this.getConnection(category).write(msglist); this.getConnection(category).write(msglist);
for(OFMessage m : msglist) {
switchManager.handleOutgoingMessage(this, m);
}
} else { } else {
log.warn("Attempted to write to switch {} that is SLAVE.", this.getId().toString()); log.warn("Attempted to write to switch {} that is SLAVE.", this.getId().toString());
} }
...@@ -785,6 +791,10 @@ public class OFSwitch implements IOFSwitchBackend { ...@@ -785,6 +791,10 @@ public class OFSwitch implements IOFSwitchBackend {
public void write(Iterable<OFMessage> msglist) { public void write(Iterable<OFMessage> msglist) {
if (isActive()) { if (isActive()) {
connections.get(OFAuxId.MAIN).write(msglist); connections.get(OFAuxId.MAIN).write(msglist);
for(OFMessage m : msglist) {
switchManager.handleOutgoingMessage(this, m);
}
} else { } else {
log.warn("Attempted to write to switch {} that is SLAVE.", this.getId().toString()); log.warn("Attempted to write to switch {} that is SLAVE.", this.getId().toString());
} }
......
...@@ -5,6 +5,7 @@ import java.util.List; ...@@ -5,6 +5,7 @@ import java.util.List;
import net.floodlightcontroller.core.FloodlightContext; import net.floodlightcontroller.core.FloodlightContext;
import net.floodlightcontroller.core.IOFConnectionBackend; import net.floodlightcontroller.core.IOFConnectionBackend;
import net.floodlightcontroller.core.IOFSwitch.SwitchStatus; import net.floodlightcontroller.core.IOFSwitch.SwitchStatus;
import net.floodlightcontroller.core.IOFSwitch;
import net.floodlightcontroller.core.IOFSwitchBackend; import net.floodlightcontroller.core.IOFSwitchBackend;
import net.floodlightcontroller.core.IOFSwitchDriver; import net.floodlightcontroller.core.IOFSwitchDriver;
import net.floodlightcontroller.core.LogicalOFMessageCategory; import net.floodlightcontroller.core.LogicalOFMessageCategory;
...@@ -55,6 +56,13 @@ public interface IOFSwitchManager { ...@@ -55,6 +56,13 @@ public interface IOFSwitchManager {
* @param bContext the Floodlight context of the message, normally null in this case. * @param bContext the Floodlight context of the message, normally null in this case.
*/ */
void handleMessage(IOFSwitchBackend sw, OFMessage m, FloodlightContext bContext); void handleMessage(IOFSwitchBackend sw, OFMessage m, FloodlightContext bContext);
/**
* Process written messages through the message listeners for the controller
* @param sw The switch being written to
* @param m the message
*/
public void handleOutgoingMessage(IOFSwitch sw, OFMessage m);
/** /**
* Gets an unmodifiable collection of OFSwitchHandshakeHandlers * Gets an unmodifiable collection of OFSwitchHandshakeHandlers
......
...@@ -503,6 +503,11 @@ public class OFSwitchManager implements IOFSwitchManager, INewOFConnectionListen ...@@ -503,6 +503,11 @@ public class OFSwitchManager implements IOFSwitchManager, INewOFConnectionListen
public void handleMessage(IOFSwitchBackend sw, OFMessage m, FloodlightContext bContext) { public void handleMessage(IOFSwitchBackend sw, OFMessage m, FloodlightContext bContext) {
floodlightProvider.handleMessage(sw, m, bContext); floodlightProvider.handleMessage(sw, m, bContext);
} }
@Override
public void handleOutgoingMessage(IOFSwitch sw, OFMessage m) {
floodlightProvider.handleOutgoingMessage(sw, m);
}
@Override @Override
public void addOFSwitchDriver(String manufacturerDescriptionPrefix, public void addOFSwitchDriver(String manufacturerDescriptionPrefix,
......
...@@ -90,6 +90,12 @@ public class MockSwitchManager implements IFloodlightModule, IOFSwitchManager, I ...@@ -90,6 +90,12 @@ public class MockSwitchManager implements IFloodlightModule, IOFSwitchManager, I
// do nothing // do nothing
} }
@Override
public void handleOutgoingMessage(IOFSwitch sw, OFMessage m) {
// do nothing
}
public void setSwitchHandshakeHandlers(Map<DatapathId, OFSwitchHandshakeHandler> handlers) { public void setSwitchHandshakeHandlers(Map<DatapathId, OFSwitchHandshakeHandler> handlers) {
this.switchHandlers = handlers; this.switchHandlers = handlers;
......
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