From e52ceccf30ab951208761ffdc33b1eefe4d56750 Mon Sep 17 00:00:00 2001 From: Martin Fong <mwfong@comcast.net> Date: Thu, 10 Jan 2013 11:47:40 -0800 Subject: [PATCH] * Consolidated write(OFMessage, FloodlightContext) and write(List<OFMessage>, FloodlightContext); the latter now invokes the former. --- .../core/OFSwitchBase.java | 45 +++++++++---------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java b/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java index 8998472cf..409200cd9 100644 --- a/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java +++ b/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java @@ -186,6 +186,12 @@ public abstract class OFSwitchBase implements IOFSwitch { } @Override + @LogMessageDoc(level="WARN", + message="Sending OF message that modifies switch " + + "state while in the slave role: {switch}", + explanation="An application has sent a message to a switch " + + "that is not valid when the switch is in a slave role", + recommendation=LogMessageDoc.REPORT_CONTROLLER_BUG) public void write(OFMessage m, FloodlightContext bc) throws IOException { Map<IOFSwitch,List<OFMessage>> msg_buffer_map = local_msg_buffer.get(); @@ -195,6 +201,20 @@ public abstract class OFSwitchBase implements IOFSwitch { msg_buffer_map.put(this, msg_buffer); } + if (role == Role.SLAVE) { + switch (m.getType()) { + case PACKET_OUT: + case FLOW_MOD: + case PORT_MOD: + log.warn("Sending OF message that modifies switch " + + "state while in the slave role: {}", + m.getType().name()); + break; + default: + break; + } + } + this.floodlightProvider.handleOutgoingMessage(this, m, bc); msg_buffer.add(m); @@ -206,31 +226,10 @@ public abstract class OFSwitchBase implements IOFSwitch { } @Override - @LogMessageDoc(level="WARN", - message="Sending OF message that modifies switch " + - "state while in the slave role: {switch}", - explanation="An application has sent a message to a switch " + - "that is not valid when the switch is in a slave role", - recommendation=LogMessageDoc.REPORT_CONTROLLER_BUG) public void write(List<OFMessage> msglist, FloodlightContext bc) throws IOException { - for (OFMessage m : msglist) { - if (role == Role.SLAVE) { - switch (m.getType()) { - case PACKET_OUT: - case FLOW_MOD: - case PORT_MOD: - log.warn("Sending OF message that modifies switch " + - "state while in the slave role: {}", - m.getType().name()); - break; - default: - break; - } - } - this.floodlightProvider.handleOutgoingMessage(this, m, bc); - } - this.write(msglist); + for (OFMessage m : msglist) + this.write(m, bc); } private void write(List<OFMessage> msglist) throws IOException { -- GitLab